kibi-cli 2.19.0 → 2.21.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/cli-register-maintenance.js +1 -1
- package/dist/commands/engine.d.ts +2 -1
- package/dist/commands/engine.d.ts.map +1 -1
- package/dist/commands/engine.js +6 -1
- package/dist/commands/migrate.d.ts +2 -0
- package/dist/commands/migrate.d.ts.map +1 -1
- package/dist/commands/migrate.js +32 -6
- package/dist/commands/sync/discovery.d.ts.map +1 -1
- package/dist/commands/sync/discovery.js +14 -2
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +24 -6
- package/dist/extractors/markdown.d.ts.map +1 -1
- package/dist/extractors/markdown.js +2 -1
- package/dist/intent-search.d.ts +7 -0
- package/dist/intent-search.d.ts.map +1 -1
- package/dist/intent-search.js +66 -4
- 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/modeling/predicate-applicability.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-applicability.js +10 -4
- package/dist/operations/modeling/predicate-applyplan.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-applyplan.js +16 -5
- package/dist/operations/modeling/predicate-catalog-4.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-catalog-4.js +3 -0
- package/dist/operations/modeling/predicate-inference-1.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-inference-1.js +34 -7
- package/dist/operations/modeling/predicate-score-3.js +1 -1
- package/dist/operations/modeling/predicate-types.d.ts +6 -0
- 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 +111 -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 +26 -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 +8 -2
- package/dist/operations/mutation/validate-upsert.d.ts.map +1 -1
- package/dist/operations/mutation/validate-upsert.js +116 -4
- package/dist/operations/mutation/validation.d.ts.map +1 -1
- package/dist/operations/mutation/validation.js +2 -1
- package/dist/operations/mutation/warnings.d.ts +10 -0
- package/dist/operations/mutation/warnings.d.ts.map +1 -1
- package/dist/operations/mutation/warnings.js +26 -0
- package/dist/operations/mutation/what-if.d.ts +25 -0
- package/dist/operations/mutation/what-if.d.ts.map +1 -0
- package/dist/operations/mutation/what-if.js +59 -0
- package/dist/operations/planning/compile-intent.d.ts +15 -20
- package/dist/operations/planning/compile-intent.d.ts.map +1 -1
- package/dist/operations/planning/compile-intent.js +64 -53
- 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 +32 -7
- package/dist/prolog/janitor.d.ts +26 -2
- package/dist/prolog/janitor.d.ts.map +1 -1
- package/dist/prolog/janitor.js +55 -3
- package/dist/prolog/store-lock.d.ts +28 -3
- package/dist/prolog/store-lock.d.ts.map +1 -1
- package/dist/prolog/store-lock.js +103 -12
- package/dist/public/operations/catalog.d.ts +49 -5
- package/dist/public/operations/catalog.d.ts.map +1 -1
- package/dist/public/operations/check-executor.d.ts +2 -2
- package/dist/public/operations/check-executor.d.ts.map +1 -1
- package/dist/public/operations/check-executor.js +35 -0
- package/dist/public/operations/check-format-shared.d.ts +16 -0
- package/dist/public/operations/check-format-shared.d.ts.map +1 -1
- package/dist/public/operations/check-format-shared.js +19 -0
- package/dist/public/operations/contracts.d.ts.map +1 -1
- package/dist/public/operations/contracts.js +10 -0
- package/dist/public/operations/discovery-executors.d.ts +3 -0
- package/dist/public/operations/discovery-executors.d.ts.map +1 -1
- package/dist/public/operations/discovery-executors.js +7 -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/composite.d.ts +1 -1
- package/dist/public/operations/specs/composite.js +1 -1
- package/dist/public/operations/specs/discovery.d.ts +2 -2
- package/dist/public/operations/specs/discovery.d.ts.map +1 -1
- package/dist/public/operations/specs/discovery.js +2 -2
- package/dist/public/operations/specs/mutation-schemas.d.ts +2 -2
- package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
- package/dist/public/operations/specs/mutation-schemas.js +8 -17
- package/dist/public/operations/specs/upsert.d.ts +46 -2
- package/dist/public/operations/specs/upsert.d.ts.map +1 -1
- package/dist/public/operations/specs/upsert.js +14 -0
- package/dist/public/schemas/entity.d.ts.map +1 -1
- package/dist/public/schemas/entity.js +2 -13
- package/dist/public/skills/kibi-usage/SKILL.md +38 -1
- package/dist/public/skills/kibi-usage/resources/fact-lanes.md +5 -3
- 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/schemas/entity.schema.json +2 -25
- package/dist/search-answer.d.ts +13 -0
- package/dist/search-answer.d.ts.map +1 -1
- package/dist/search-answer.js +45 -4
- package/dist/utils/branch-store.d.ts.map +1 -1
- package/dist/utils/branch-store.js +4 -2
- package/package.json +3 -3
- package/src/public/operations/check-executor.ts +44 -1
- package/src/public/operations/check-format-shared.ts +35 -1
- package/src/public/operations/contracts.ts +11 -0
- package/src/public/operations/discovery-executors.ts +12 -2
- package/src/public/operations/migration-plan.ts +41 -9
- package/src/public/operations/specs/composite.ts +1 -1
- package/src/public/operations/specs/discovery.ts +3 -2
- package/src/public/operations/specs/mutation-schemas.ts +8 -17
- package/src/public/operations/specs/upsert.ts +15 -0
- package/src/public/schemas/entity.ts +2 -13
- package/src/public/skills/kibi-usage/SKILL.md +38 -1
- package/src/public/skills/kibi-usage/resources/fact-lanes.md +5 -3
- 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 +2 -25
|
@@ -59,7 +59,7 @@ export declare const CLI_OPERATION_METADATA: readonly [{
|
|
|
59
59
|
}, {
|
|
60
60
|
readonly name: "kb_model";
|
|
61
61
|
readonly cliName: "model";
|
|
62
|
-
readonly description: "Turn requirement prose into checkable structure without writing the KB. mode:analyze returns the semantic advisor receipt: the clause ledger, what is grounded, what is ambiguous and suggested modeling (pass clauses for compound prose and optional typed kibi.logic.v1 interpretations). mode:requirement converts one claim (subjectKey, propertyKey, operator, value, or typed logic) into a strict-lane write set and applyPlan. mode:predicates ranks ontology predicate schemas and returns an applicable predicate-fact plan only for reviewed bindings, otherwise an ontology-gap observation.
|
|
62
|
+
readonly description: "Turn requirement prose into checkable structure without writing the KB. mode:analyze returns the semantic advisor receipt: the clause ledger, what is grounded, what is ambiguous and suggested modeling (pass clauses for compound prose and optional typed kibi.logic.v1 interpretations). mode:requirement converts one claim (subjectKey, propertyKey, operator, value, or typed logic) into a strict-lane write set and applyPlan. mode:predicates ranks ontology predicate schemas and returns an applicable predicate-fact plan only for reviewed bindings, otherwise an ontology-gap observation. With requirementId, mode:predicates also returns a hash-bound plan (fact write plus requires_predicate link) for kb_apply_plan, whose contradictionAnalysis is the what-if over the current KB; other returned plans apply with kb_upsert, and kb_upsert dryRun with plannedFacts previews a requirement before its facts exist.";
|
|
63
63
|
}, {
|
|
64
64
|
readonly name: "kb_plan_bootstrap";
|
|
65
65
|
readonly cliName: "plan-bootstrap";
|
|
@@ -70,7 +70,7 @@ export const CLI_OPERATION_METADATA = [
|
|
|
70
70
|
{
|
|
71
71
|
name: "kb_model",
|
|
72
72
|
cliName: "model",
|
|
73
|
-
description: "Turn requirement prose into checkable structure without writing the KB. mode:analyze returns the semantic advisor receipt: the clause ledger, what is grounded, what is ambiguous and suggested modeling (pass clauses for compound prose and optional typed kibi.logic.v1 interpretations). mode:requirement converts one claim (subjectKey, propertyKey, operator, value, or typed logic) into a strict-lane write set and applyPlan. mode:predicates ranks ontology predicate schemas and returns an applicable predicate-fact plan only for reviewed bindings, otherwise an ontology-gap observation.
|
|
73
|
+
description: "Turn requirement prose into checkable structure without writing the KB. mode:analyze returns the semantic advisor receipt: the clause ledger, what is grounded, what is ambiguous and suggested modeling (pass clauses for compound prose and optional typed kibi.logic.v1 interpretations). mode:requirement converts one claim (subjectKey, propertyKey, operator, value, or typed logic) into a strict-lane write set and applyPlan. mode:predicates ranks ontology predicate schemas and returns an applicable predicate-fact plan only for reviewed bindings, otherwise an ontology-gap observation. With requirementId, mode:predicates also returns a hash-bound plan (fact write plus requires_predicate link) for kb_apply_plan, whose contradictionAnalysis is the what-if over the current KB; other returned plans apply with kb_upsert, and kb_upsert dryRun with plannedFacts previews a requirement before its facts exist.",
|
|
74
74
|
},
|
|
75
75
|
{
|
|
76
76
|
name: "kb_plan_bootstrap",
|
|
@@ -14,7 +14,7 @@ export function registerMaintenanceCommands(program) {
|
|
|
14
14
|
.action(async () => (await import("./commands/engine.js")).engineStopCommand());
|
|
15
15
|
engine
|
|
16
16
|
.command("janitor")
|
|
17
|
-
.description("Classify and clean stale engine daemons
|
|
17
|
+
.description("Classify and clean stale engine daemons, branch-store locks and expired lock-takeover records (crashed engines, removed worktrees)")
|
|
18
18
|
.option("--all", "Also sweep runtime-directory daemon sockets from other workspaces", false)
|
|
19
19
|
.option("--apply", "Execute cleanups (default: report only)", false)
|
|
20
20
|
.option("--format <format>", "Output format: json|table", "table")
|
|
@@ -9,7 +9,8 @@ export interface EngineJanitorOptions {
|
|
|
9
9
|
/**
|
|
10
10
|
* Classify and (optionally) clean stale engine daemons and branch-store
|
|
11
11
|
* locks: crashed engines leave ownership journals behind, worktree removals
|
|
12
|
-
* strand live daemons, dead daemons leave sockets
|
|
12
|
+
* strand live daemons, dead daemons leave sockets, and stale-lock takeover
|
|
13
|
+
* records outlive the window kb_status reports them for. Report-only by default;
|
|
13
14
|
`--apply` executes the clean actions.
|
|
14
15
|
*/
|
|
15
16
|
export declare function engineJanitorCommand(options: EngineJanitorOptions): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../src/commands/engine.ts"],"names":[],"mappings":"AAuCA,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CA4BzD;AAED,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAWvD;AAED,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CAE1D;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../../src/commands/engine.ts"],"names":[],"mappings":"AAuCA,wBAAsB,mBAAmB,IAAI,OAAO,CAAC,IAAI,CAAC,CA4BzD;AAED,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAWvD;AAED,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CAE1D;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IACzB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED;;;;;;GAMG;AAEH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,IAAI,CAAC,CAiDf;AAED,wBAAsB,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC,CAkB3D;AAED,wBAAsB,oBAAoB,CAAC,OAAO,EAAE;IAClD,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,IAAI,CAAC,CAWhB"}
|
package/dist/commands/engine.js
CHANGED
|
@@ -74,7 +74,8 @@ export async function storageStatusCommand() {
|
|
|
74
74
|
/**
|
|
75
75
|
* Classify and (optionally) clean stale engine daemons and branch-store
|
|
76
76
|
* locks: crashed engines leave ownership journals behind, worktree removals
|
|
77
|
-
* strand live daemons, dead daemons leave sockets
|
|
77
|
+
* strand live daemons, dead daemons leave sockets, and stale-lock takeover
|
|
78
|
+
* records outlive the window kb_status reports them for. Report-only by default;
|
|
78
79
|
`--apply` executes the clean actions.
|
|
79
80
|
*/
|
|
80
81
|
// implements REQ-core-journaled-engine-persistence
|
|
@@ -98,6 +99,10 @@ export async function engineJanitorCommand(options) {
|
|
|
98
99
|
return;
|
|
99
100
|
}
|
|
100
101
|
for (const finding of findings) {
|
|
102
|
+
if (finding.kind === "takeover-record") {
|
|
103
|
+
console.log(`[${finding.action}] takeover record ${finding.recordPath} at=${finding.at} (past the kb_status notice window)`);
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
101
106
|
const holder = "pid" in finding && finding.pid !== undefined
|
|
102
107
|
? ` pid=${finding.pid}`
|
|
103
108
|
: "";
|
|
@@ -5,6 +5,8 @@ interface MigrateOptions {
|
|
|
5
5
|
applySafe?: boolean;
|
|
6
6
|
approvedPlanHash?: string;
|
|
7
7
|
approvedActionIds?: string[];
|
|
8
|
+
/** `--approved-action <id>` as the CLI parser spells it; same as approvedActionIds. */
|
|
9
|
+
approvedAction?: string[];
|
|
8
10
|
workspaceRoot?: string;
|
|
9
11
|
/** Internal migration-plan executor: create only the canonical baseline manifest. */
|
|
10
12
|
initializeMissingConfig?: boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"migrate.d.ts","sourceRoot":"","sources":["../../src/commands/migrate.ts"],"names":[],"mappings":"AAiEA,UAAU,cAAc;IACtB,MAAM,CAAC,EAAE,OAAO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AAI;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAKtE;AAGD,wBAAsB,cAAc,CAClC,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,CAAC,CAiW/B"}
|
package/dist/commands/migrate.js
CHANGED
|
@@ -761,20 +761,47 @@ async function buildWorkspaceMigrationPlan(workspaceRoot = process.cwd()) {
|
|
|
761
761
|
}
|
|
762
762
|
return mergeMigrationPlans(plans);
|
|
763
763
|
}
|
|
764
|
+
/**
|
|
765
|
+
* The action ids approved on the command line. The CLI parser stores
|
|
766
|
+
* `--approved-action` as `approvedAction`; in-process callers pass
|
|
767
|
+
* `approvedActionIds`. Either spelling limits `--apply-safe` to those ids.
|
|
768
|
+
*/
|
|
769
|
+
// implements REQ-cli-schema-migration
|
|
770
|
+
function approvedActionIdsOf(options) {
|
|
771
|
+
const ids = [
|
|
772
|
+
...(options.approvedActionIds ?? []),
|
|
773
|
+
...(options.approvedAction ?? []),
|
|
774
|
+
]
|
|
775
|
+
.map((id) => id.trim())
|
|
776
|
+
.filter((id) => id.length > 0);
|
|
777
|
+
return [...new Set(ids)];
|
|
778
|
+
}
|
|
764
779
|
async function migratePlanCommand(options) {
|
|
765
780
|
const workspaceRoot = path.resolve(options.workspaceRoot ?? process.cwd());
|
|
766
781
|
const plan = await buildWorkspaceMigrationPlan(workspaceRoot);
|
|
767
|
-
|
|
768
|
-
|
|
782
|
+
// `--yes` with JSON output applies every ready automatic action of the plan
|
|
783
|
+
// it would otherwise only print; `--dry-run` still only prints it.
|
|
784
|
+
const approveWholePlan = options.applySafe !== true &&
|
|
785
|
+
options.yes === true &&
|
|
786
|
+
options.dryRun !== true &&
|
|
787
|
+
options.format === "json";
|
|
788
|
+
if (options.applySafe === true || approveWholePlan) {
|
|
789
|
+
const approvedPlanHash = approveWholePlan
|
|
790
|
+
? plan.planHash
|
|
791
|
+
: options.approvedPlanHash;
|
|
792
|
+
if (!approvedPlanHash) {
|
|
769
793
|
console.error("--apply-safe requires --approved-plan-hash <sha256>.");
|
|
770
794
|
return { exitCode: 2 };
|
|
771
795
|
}
|
|
772
|
-
if (
|
|
796
|
+
if (approvedPlanHash !== plan.planHash) {
|
|
773
797
|
console.error("Migration plan changed; regenerate the plan and approve its current hash.");
|
|
774
798
|
return { exitCode: 2 };
|
|
775
799
|
}
|
|
776
|
-
const
|
|
777
|
-
?
|
|
800
|
+
const explicitActionIds = approveWholePlan
|
|
801
|
+
? []
|
|
802
|
+
: approvedActionIdsOf(options);
|
|
803
|
+
const approvedActionIds = explicitActionIds.length > 0
|
|
804
|
+
? explicitActionIds
|
|
778
805
|
: plan.actions
|
|
779
806
|
.filter((action) => action.state === "ready" && action.autoApplicable)
|
|
780
807
|
.map((action) => action.id);
|
|
@@ -788,7 +815,6 @@ async function migratePlanCommand(options) {
|
|
|
788
815
|
import("../public/operations/specs/planning.js"),
|
|
789
816
|
import("../cli-json-command.js"),
|
|
790
817
|
]);
|
|
791
|
-
const approvedPlanHash = options.approvedPlanHash;
|
|
792
818
|
const execute = () => executeOperation(createCliRuntime({ workspaceRoot }), applyPlanSpec, {
|
|
793
819
|
plan,
|
|
794
820
|
approvedPlanHash,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/discovery.ts"],"names":[],"mappings":"AAkCA,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACtC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,+EAA+E;IAC/E,6BAA6B,CAAC,EAAE,OAAO,CAAC;CACzC,CAAC,CAAC;AAEH;;;;;;;GAOG;AACH,MAAM,MAAM,4BAA4B,GAAG,QAAQ,CAAC;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../../src/commands/sync/discovery.ts"],"names":[],"mappings":"AAkCA,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACtC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,4BAA4B,CAAC,EAAE,OAAO,CAAC;IACvC,+EAA+E;IAC/E,6BAA6B,CAAC,EAAE,OAAO,CAAC;CACzC,CAAC,CAAC;AAEH;;;;;;;GAOG;AACH,MAAM,MAAM,4BAA4B,GAAG,QAAQ,CAAC;IAClD,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC,CAAC;AAwGH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAOlD;AAED,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAShE;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAUxD;AAED,wBAAgB,mCAAmC,CACjD,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,SAAS,4BAA4B,EAAE,GAChD,IAAI,CA6CN;AAsBD,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,MAAM,GAAG,SAAS,GAC1B,MAAM,GAAG,IAAI,CAIf;AAED,wBAAsB,mBAAmB,CACvC,GAAG,EAAE,MAAM,EACX,OAAO,GAAE,gBAAqB,GAC7B,OAAO,CAAC;IACT,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;IACzB,4BAA4B,EAAE,4BAA4B,EAAE,CAAC;CAC9D,CAAC,CAgGD"}
|
|
@@ -34,7 +34,14 @@ async function gitTrackedPaths(cwd) {
|
|
|
34
34
|
.filter(Boolean)
|
|
35
35
|
.map((value) => value.replaceAll("\\", "/")));
|
|
36
36
|
}
|
|
37
|
-
|
|
37
|
+
/**
|
|
38
|
+
* The sources bound by pending receipts. A receipt whose file Git now tracks
|
|
39
|
+
* is kept as an input but not compared, whatever its hash says: the tracked
|
|
40
|
+
* bytes are the authored input, and the caller retires that receipt. Only a
|
|
41
|
+
* receipt for a still-untracked file can refuse the sync on hash drift.
|
|
42
|
+
*/
|
|
43
|
+
// implements REQ-core-atomic-upsert-persistence
|
|
44
|
+
function pendingSourcePaths(cwd, recoverMissing, tracked = new Set()) {
|
|
38
45
|
const root = path.join(cwd, ".kb", "recovery", "pending-sources");
|
|
39
46
|
if (!existsSync(root)) {
|
|
40
47
|
return { paths: new Map(), recoveredReceipts: [] };
|
|
@@ -53,6 +60,11 @@ function pendingSourcePaths(cwd, recoverMissing) {
|
|
|
53
60
|
typeof receipt.afterHash === "string" &&
|
|
54
61
|
/^[a-f0-9]{64}$/i.test(receipt.afterHash)) {
|
|
55
62
|
const relative = receipt.path.replaceAll("\\", "/");
|
|
63
|
+
if (tracked.has(relative)) {
|
|
64
|
+
// Still an authored input; only the stale hash is ignored.
|
|
65
|
+
paths.set(relative, receipt.afterHash);
|
|
66
|
+
continue;
|
|
67
|
+
}
|
|
56
68
|
const absolute = path.resolve(cwd, relative);
|
|
57
69
|
if (!absolute.startsWith(`${path.resolve(cwd)}${path.sep}`)) {
|
|
58
70
|
throw new Error(`Pending source receipt escapes workspace: ${relative}`);
|
|
@@ -199,7 +211,7 @@ export async function discoverSourceFiles(cwd, options = {}) {
|
|
|
199
211
|
const recoveredPendingReceiptPaths = [];
|
|
200
212
|
if (options.trackedOnly) {
|
|
201
213
|
const tracked = await gitTrackedPaths(cwd);
|
|
202
|
-
const pending = pendingSourcePaths(cwd, options.recoverMissingPendingSources === true);
|
|
214
|
+
const pending = pendingSourcePaths(cwd, options.recoverMissingPendingSources === true, tracked);
|
|
203
215
|
recoveredPendingReceiptPaths.push(...pending.recoveredReceipts);
|
|
204
216
|
entityMarkdownFiles = filterTracked(cwd, entityMarkdownFiles, tracked, new Set(pending.paths.keys()));
|
|
205
217
|
manifestFiles = filterTracked(cwd, manifestFiles, tracked, new Set(pending.paths.keys()));
|
package/dist/engine.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAgCA,OAAO,EAEL,KAAK,iBAAiB,EAMvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EACV,wBAAwB,EACxB,eAAe,EAEhB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,aAAa,EAAmB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AAgCA,OAAO,EAEL,KAAK,iBAAiB,EAMvB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EACV,wBAAwB,EACxB,eAAe,EAEhB,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EAAE,aAAa,EAAmB,MAAM,aAAa,CAAC;AAa7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,KAAK,EACV,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACxB,MAAM,sCAAsC,CAAC;AAQ9C,YAAY,EACV,wBAAwB,EACxB,eAAe,EACf,aAAa,GACd,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,qBAAqB,EACrB,yBAAyB,EACzB,oBAAoB,GACrB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAU5B,eAAO,MAAM,uBAAuB,IAAI,CAAC;AACzC,eAAO,MAAM,sBAAsB,QAAiB,CAAC;AACrD,2EAA2E;AAC3E,eAAO,MAAM,6BAA6B,QAAY,CAAC;AAC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c,CAAC,EAAE,MAAM,CAAC;CAClC,GAAG,OAAO,CAAC,IAAI,CAAC,CA0wBhB"}
|
package/dist/engine.js
CHANGED
|
@@ -18,7 +18,7 @@ import { kibiPackageVersions } from "./package-versions.js";
|
|
|
18
18
|
import { writePerformanceTraceEvent } from "./performance-trace.js";
|
|
19
19
|
import { PrologProcess, resolveKbPlPath } from "./prolog.js";
|
|
20
20
|
import { parseEntityFromList, parseListOfLists } from "./prolog/codec.js";
|
|
21
|
-
import { decideStoreLockTakeover, isProcessAlive, noteDeadHolderBeforeAttach, readRdfLockPid, recordStoreLockTakeover, retryAttachAfterBreakingStaleLock, } from "./prolog/store-lock.js";
|
|
21
|
+
import { decideStoreLockTakeover, isProcessAlive, noteDeadHolderBeforeAttach, readRdfLockPid, readStoreLockOwner, recordStoreLockTakeover, retryAttachAfterBreakingStaleLock, } from "./prolog/store-lock.js";
|
|
22
22
|
import { resolveSwipl, swiplIdentity } from "./prolog/swipl-resolver.js";
|
|
23
23
|
import { queryEntityChunks } from "./public/operations/discovery-entities.js";
|
|
24
24
|
import { isValidBranchName } from "./utils/branch-resolver.js";
|
|
@@ -632,17 +632,35 @@ function releaseStartLock(lockPath, descriptor) {
|
|
|
632
632
|
// Another starter may already have cleaned the lock.
|
|
633
633
|
}
|
|
634
634
|
}
|
|
635
|
+
// implements REQ-core-journaled-engine-persistence
|
|
635
636
|
function recoverStaleJournalLock(branchPath) {
|
|
636
637
|
const lockPath = path.join(branchPath, "rdf", "lock");
|
|
637
638
|
if (!existsSync(lockPath))
|
|
638
639
|
return;
|
|
639
640
|
const pid = readRdfLockPid(lockPath);
|
|
640
|
-
if (pid === null || pid === process.pid
|
|
641
|
+
if (pid === null || pid === process.pid)
|
|
641
642
|
return;
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
643
|
+
let reason;
|
|
644
|
+
if (!isProcessAlive(pid)) {
|
|
645
|
+
reason = decideStoreLockTakeover({ pid }).reason;
|
|
646
|
+
}
|
|
647
|
+
else {
|
|
648
|
+
// A live pid still loses the lock when the lock and its journal were
|
|
649
|
+
// copied in from another workspace: that pid holds the original store,
|
|
650
|
+
// never this copy.
|
|
651
|
+
const journal = readStoreLockOwner(branchPath)?.owner ?? null;
|
|
652
|
+
if (journal === null || journal.pid !== pid)
|
|
653
|
+
return;
|
|
654
|
+
const decision = decideStoreLockTakeover(journal, {
|
|
655
|
+
storePath: branchPath,
|
|
656
|
+
});
|
|
657
|
+
if (decision.action !== "break")
|
|
658
|
+
return;
|
|
659
|
+
reason = decision.reason;
|
|
660
|
+
}
|
|
661
|
+
// Breaking a stale holder's lock is a takeover; record it for kb_status
|
|
662
|
+
// and kibi doctor instead of healing silently.
|
|
663
|
+
recordStoreLockTakeover(branchPath, pid, reason);
|
|
646
664
|
try {
|
|
647
665
|
rmSync(lockPath, { force: true });
|
|
648
666
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/extractors/markdown.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/extractors/markdown.ts"],"names":[],"mappings":"AA2BA,OAAO,EACL,KAAK,YAAY,EAElB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,aAAa,EACnB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,KAAK,YAAY,EAElB,MAAM,4BAA4B,CAAC;AAuEpC,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf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6B,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQlE;AAED;;;;;GAKG;AAEH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE5D;AAkBD,wBAAgB,sBAAsB,CAEpC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,UAAU,EAAE,MAAM,GACjB,MAAM,EAAE,CAkDV;AA4hBD,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,MAAM,GACf,gBAAgB,CAElB;AAGD,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,gBAAgB,CAatE;AAED,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CASjE;AASD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAQpE"}
|
|
@@ -20,7 +20,7 @@ import { readFileSync } from "node:fs";
|
|
|
20
20
|
import Ajv from "ajv";
|
|
21
21
|
import { load as yamlLoad } from "js-yaml";
|
|
22
22
|
import { withoutContextSections } from "../entity-body-context.js";
|
|
23
|
-
import { semanticClaimKey } from "../operations/semantic-advisor/clauses.js";
|
|
23
|
+
import { deriveFactClaimKey, semanticClaimKey, } from "../operations/semantic-advisor/clauses.js";
|
|
24
24
|
import { normalizeEntityOrigin, } from "../public/entity-origin.js";
|
|
25
25
|
import { PROOF_BINDINGS_SCHEMA, PROOF_CONTRACT_SCHEMA, } from "../public/proof-protocol.js";
|
|
26
26
|
import { proofReceiptHistoryErrors, } from "../public/proof-receipt.js";
|
|
@@ -671,6 +671,7 @@ function extractFromMarkdownContent(content, filePath) {
|
|
|
671
671
|
hint: "Fix the entity fields so they match the public schema.",
|
|
672
672
|
});
|
|
673
673
|
}
|
|
674
|
+
deriveFactClaimKey(entity);
|
|
674
675
|
if (entity.type === "fact" &&
|
|
675
676
|
entity.claim_key !== undefined &&
|
|
676
677
|
entity.claim_text !== undefined) {
|
package/dist/intent-search.d.ts
CHANGED
|
@@ -42,6 +42,13 @@ export type IntentSearchAnalysis = Readonly<{
|
|
|
42
42
|
acceptedCount: number;
|
|
43
43
|
topScore: number | null;
|
|
44
44
|
topTwoMargin: number | null;
|
|
45
|
+
/**
|
|
46
|
+
* Margin between the top match and the best match it is not linked to in
|
|
47
|
+
* the traceability graph. A requirement and its own scenario, facts or
|
|
48
|
+
* tests tie without competing, so `ambiguous` reads this margin, not
|
|
49
|
+
* `topTwoMargin`.
|
|
50
|
+
*/
|
|
51
|
+
topRivalMargin: number | null;
|
|
45
52
|
abstained: boolean;
|
|
46
53
|
ambiguous: boolean;
|
|
47
54
|
}>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intent-search.d.ts","sourceRoot":"","sources":["../src/intent-search.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,KAAK,kBAAkB,EAIxB,MAAM,2CAA2C,CAAC;AACnD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAIvD,MAAM,MAAM,qBAAqB,GAC7B,QAAQ,GACR,SAAS,GACT,SAAS,GACT,aAAa,GACb,SAAS,CAAC;AAGd,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CACvC,OAAO,CAAC,MAAM,CAAC,qBAAqB,EAAE,SAAS,MAAM,EAAE,CAAC,CAAC,CAC1D,CAAC;AAGF,MAAM,MAAM,cAAc,GAAG,QAAQ,CAAC;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC,CAAC;AAGH,MAAM,MAAM,mBAAmB,GAAG,QAAQ,CAAC;IACzC,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,C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AAM,GAAG,IAAI,CAAC;IAC5B;;;;;OAKG;IACH,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC,CAAC;AAGH,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC;IACxC,OAAO,EAAE,SAAS,iBAAiB,EAAE,CAAC;IACtC,QAAQ,EAAE,oBAAoB,CAAC;CAChC,CAAC,CAAC;AAEH,KAAK,SAAS,GAAG,QAAQ,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC,CAAC;AA2bH,2EAA2E;AAE3E,MAAM,MAAM,iBAAiB,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;AA8B3D,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,EAC5C,OAAO,EAAE,mBAAmB,EAC5B,aAAa,EAAE,MAAM,EACrB,UAAU,GAAE,SAAS,SAAS,EAAO,EACrC,SAAS,GAAE,iBAA6B,GACvC,OAAO,CAAC,kBAAkB,CAAC,CA8I7B;AAoCD,wBAAgB,SAAS,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC,GAAG,MAAM,CAO1E;AA8FD,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,mBAAmB,EAC5B,MAAM,EAAE,UAAU,EAClB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,kBAAkB,CAAC,CAoD7B;AAGD,wBAAgB,yBAAyB,CAAC,KAAK,EAAE,mBAAmB,GAAG,IAAI,CA0C1E"}
|
package/dist/intent-search.js
CHANGED
|
@@ -417,9 +417,13 @@ export async function rankIntentEntities(entities, options, workspaceRoot, graph
|
|
|
417
417
|
toPaths.push(pathValue);
|
|
418
418
|
graphByEntity.set(edge.to, toPaths);
|
|
419
419
|
}
|
|
420
|
+
const inheritedSource = inheritedSourceMatches(entities, options.sourceLocations ?? [], graphEdges);
|
|
420
421
|
for (const entity of entities) {
|
|
421
|
-
const sourceEvidence = sourceMatches(entity, options.sourceLocations ?? []);
|
|
422
422
|
const entityId = String(entity.id ?? "");
|
|
423
|
+
const ownSource = sourceMatches(entity, options.sourceLocations ?? []);
|
|
424
|
+
const sourceEvidence = ownSource.length > 0
|
|
425
|
+
? ownSource
|
|
426
|
+
: (inheritedSource.get(entityId) ?? ownSource);
|
|
423
427
|
// Keep evidence useful for agents and bounded for transport. The score is
|
|
424
428
|
// already capped; unbounded parallel paths only add noise to receipts.
|
|
425
429
|
const graphEvidence = (graphByEntity.get(entityId) ?? []).slice(0, 8);
|
|
@@ -430,10 +434,15 @@ export async function rankIntentEntities(entities, options, workspaceRoot, graph
|
|
|
430
434
|
const snippet = body === null
|
|
431
435
|
? undefined
|
|
432
436
|
: bodySnippetLine(String(entity.type ?? ""), body, entity);
|
|
437
|
+
// Inherited source evidence says so, instead of claiming the entity
|
|
438
|
+
// itself sits at the location.
|
|
439
|
+
const reasons = scored.reasons.map((reason) => reason === "source location match" && ownSource.length === 0
|
|
440
|
+
? "implemented at the source location"
|
|
441
|
+
: reason);
|
|
433
442
|
ranked.push({
|
|
434
443
|
entity,
|
|
435
444
|
score: scored.score,
|
|
436
|
-
reasons: Array.from(new Set(
|
|
445
|
+
reasons: Array.from(new Set(reasons)),
|
|
437
446
|
...(snippet !== undefined ? { snippet } : {}),
|
|
438
447
|
evidence: {
|
|
439
448
|
normalizedScore: scored.score,
|
|
@@ -464,6 +473,23 @@ export async function rankIntentEntities(entities, options, workspaceRoot, graph
|
|
|
464
473
|
const topTwoMargin = first !== undefined && second !== undefined
|
|
465
474
|
? first.score - second.score
|
|
466
475
|
: null;
|
|
476
|
+
// A requirement and its own scenario, facts or tests score alike on the
|
|
477
|
+
// same words without being rival answers: the rival is the best match the
|
|
478
|
+
// top match is not linked to.
|
|
479
|
+
const topId = String(first?.entity.id ?? "");
|
|
480
|
+
const linkedToTop = new Set();
|
|
481
|
+
for (const edge of graphEdges) {
|
|
482
|
+
if (edge.from === topId)
|
|
483
|
+
linkedToTop.add(edge.to);
|
|
484
|
+
if (edge.to === topId)
|
|
485
|
+
linkedToTop.add(edge.from);
|
|
486
|
+
}
|
|
487
|
+
const rival = ranked
|
|
488
|
+
.slice(1)
|
|
489
|
+
.find((match) => !linkedToTop.has(String(match.entity.id ?? "")));
|
|
490
|
+
const topRivalMargin = first !== undefined && rival !== undefined
|
|
491
|
+
? first.score - rival.score
|
|
492
|
+
: null;
|
|
467
493
|
return {
|
|
468
494
|
matches: ranked,
|
|
469
495
|
analysis: {
|
|
@@ -472,12 +498,48 @@ export async function rankIntentEntities(entities, options, workspaceRoot, graph
|
|
|
472
498
|
acceptedCount: ranked.length,
|
|
473
499
|
topScore,
|
|
474
500
|
topTwoMargin,
|
|
501
|
+
topRivalMargin,
|
|
475
502
|
abstained: ranked.length === 0,
|
|
476
|
-
// Two leading matches this close are not a confident single
|
|
477
|
-
|
|
503
|
+
// Two leading rival matches this close are not a confident single
|
|
504
|
+
// answer.
|
|
505
|
+
ambiguous: topRivalMargin !== null && topRivalMargin < AMBIGUOUS_MARGIN,
|
|
478
506
|
},
|
|
479
507
|
};
|
|
480
508
|
}
|
|
509
|
+
// implements REQ-kibi-intent-aware-source-discovery
|
|
510
|
+
/**
|
|
511
|
+
* Source evidence a requirement inherits from the symbols that implement it:
|
|
512
|
+
* a changed file's symbols are source matches, and the requirements they
|
|
513
|
+
* `implements` are what that file is for, even when the question shares no
|
|
514
|
+
* word with them. Each inherited match names the implementing symbol.
|
|
515
|
+
*/
|
|
516
|
+
function inheritedSourceMatches(entities, locations, graphEdges) {
|
|
517
|
+
const inherited = new Map();
|
|
518
|
+
if (locations.length === 0 || graphEdges.length === 0)
|
|
519
|
+
return inherited;
|
|
520
|
+
const matchedSymbols = new Map();
|
|
521
|
+
for (const entity of entities) {
|
|
522
|
+
if (String(entity.type ?? "") !== "symbol")
|
|
523
|
+
continue;
|
|
524
|
+
const matches = sourceMatches(entity, locations);
|
|
525
|
+
if (matches.length > 0)
|
|
526
|
+
matchedSymbols.set(String(entity.id ?? ""), matches);
|
|
527
|
+
}
|
|
528
|
+
if (matchedSymbols.size === 0)
|
|
529
|
+
return inherited;
|
|
530
|
+
for (const edge of graphEdges) {
|
|
531
|
+
if (edge.relationship !== "implements")
|
|
532
|
+
continue;
|
|
533
|
+
const matches = matchedSymbols.get(edge.from);
|
|
534
|
+
if (matches === undefined)
|
|
535
|
+
continue;
|
|
536
|
+
const rows = inherited.get(edge.to) ?? [];
|
|
537
|
+
for (const match of matches)
|
|
538
|
+
rows.push({ path: match.path, symbolId: edge.from, distance: 3 });
|
|
539
|
+
inherited.set(edge.to, rows);
|
|
540
|
+
}
|
|
541
|
+
return inherited;
|
|
542
|
+
}
|
|
481
543
|
export function graphGoal(seedIds, depth) {
|
|
482
544
|
const ids = seedIds.map((id) => `'${escapeAtom(id)}'`).join(",");
|
|
483
545
|
const relationships = GRAPH_RELATIONSHIPS.join(",");
|
|
@@ -47,7 +47,11 @@ export declare function withTopLevelField(content: string, key: string, value: s
|
|
|
47
47
|
* change (the key gone, every other key parsing identically).
|
|
48
48
|
*/
|
|
49
49
|
export declare function withoutTopLevelField(content: string, key: string): string | null;
|
|
50
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* Replace a file's bytes atomically. A migration rewrite of an untracked
|
|
52
|
+
* `.kb/` source also rebinds its pending-source receipt, so the next sync
|
|
53
|
+
* reads the rewritten file instead of refusing it as hash drift.
|
|
54
|
+
*/
|
|
51
55
|
export declare function writeFileAtomically(filePath: string, content: string): void;
|
|
52
56
|
export declare function readText(filePath: string): string | null;
|
|
53
57
|
//# sourceMappingURL=kb-sources.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kb-sources.d.ts","sourceRoot":"","sources":["../../../src/operations/migration/kb-sources.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"kb-sources.d.ts","sourceRoot":"","sources":["../../../src/operations/migration/kb-sources.ts"],"names":[],"mappings":"AA+BA,OAAO,EAEL,KAAK,UAAU,EAEhB,MAAM,yBAAyB,CAAC;AAGjC,yEAAyE;AAEzE,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACtC,IAAI,EAAE,UAAU,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,yCAAyC;IACzC,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC,CAAC;AAuBH,0EAA0E;AAE1E,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,MAAM,EACrB,KAAK,GAAE,SAAS,UAAU,EAAiB,GAC1C,gBAAgB,EAAE,CAkBpB;AAED,6DAA6D;AAE7D,MAAM,MAAM,gBAAgB,GAAG,QAAQ,CAAC;IACtC,6DAA6D;IAC7D,MAAM,EAAE,MAAM,CAAC;IACf,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,2CAA2C;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,EAAE,IAAI,GAAG,MAAM,CAAC;CACpB,CAAC,CAAC;AAEH;;;;;GAKG;AAEH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI,CAczE;AAUD;;;;;GAKG;AAEH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAe3E;AAeD;;;;;GAKG;AAEH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,GACZ,MAAM,GAAG,IAAI,CAyBf;AAQD;;;;;;GAMG;AAEH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,GACV,MAAM,GAAG,IAAI,CAsBf;AAID;;;;GAIG;AAEH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAY3E;AAqBD,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMxD"}
|
|
@@ -15,11 +15,13 @@
|
|
|
15
15
|
You should have received a copy of the GNU Affero General Public License
|
|
16
16
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
17
|
*/
|
|
18
|
+
import { createHash } from "node:crypto";
|
|
18
19
|
import { existsSync, mkdirSync, readFileSync, readdirSync, renameSync, writeFileSync, } from "node:fs";
|
|
19
20
|
import path from "node:path";
|
|
20
21
|
import { isDeepStrictEqual } from "node:util";
|
|
21
22
|
import { load as loadYaml } from "js-yaml";
|
|
22
23
|
import { ENTITY_LANES, KB_PATHS, } from "../../utils/kb-paths.js";
|
|
24
|
+
import { republishPendingSourceReceipt } from "../mutation/source-authoring.js";
|
|
23
25
|
function walkMarkdown(directory, files) {
|
|
24
26
|
let entries;
|
|
25
27
|
try {
|
|
@@ -214,13 +216,38 @@ export function withoutTopLevelField(content, key) {
|
|
|
214
216
|
}
|
|
215
217
|
return match === null ? content : `${slice.prefix}${text}${slice.suffix}`;
|
|
216
218
|
}
|
|
217
|
-
|
|
219
|
+
const KB_ROOT_DIRNAME = ".kb";
|
|
220
|
+
/**
|
|
221
|
+
* Replace a file's bytes atomically. A migration rewrite of an untracked
|
|
222
|
+
* `.kb/` source also rebinds its pending-source receipt, so the next sync
|
|
223
|
+
* reads the rewritten file instead of refusing it as hash drift.
|
|
224
|
+
*/
|
|
218
225
|
// implements REQ-cli-schema-migration
|
|
219
226
|
export function writeFileAtomically(filePath, content) {
|
|
220
227
|
mkdirSync(path.dirname(filePath), { recursive: true });
|
|
221
228
|
const tempPath = `${filePath}.kibi-migrate-${process.pid}-${Date.now()}`;
|
|
222
229
|
writeFileSync(tempPath, content, "utf8");
|
|
223
230
|
renameSync(tempPath, filePath);
|
|
231
|
+
const source = kbSourceLocation(filePath);
|
|
232
|
+
if (source === null)
|
|
233
|
+
return;
|
|
234
|
+
republishPendingSourceReceipt(source.workspaceRoot, source.relativePath, createHash("sha256").update(content, "utf8").digest("hex"));
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* The workspace root and workspace-relative path of a file under `.kb/`, or
|
|
238
|
+
* `null` for a file outside any knowledge root.
|
|
239
|
+
*/
|
|
240
|
+
function kbSourceLocation(filePath) {
|
|
241
|
+
const absolute = path.resolve(filePath);
|
|
242
|
+
const segments = absolute.split(path.sep);
|
|
243
|
+
const index = segments.lastIndexOf(KB_ROOT_DIRNAME);
|
|
244
|
+
if (index <= 0)
|
|
245
|
+
return null;
|
|
246
|
+
const workspaceRoot = segments.slice(0, index).join(path.sep) || path.sep;
|
|
247
|
+
return {
|
|
248
|
+
workspaceRoot,
|
|
249
|
+
relativePath: segments.slice(index).join("/"),
|
|
250
|
+
};
|
|
224
251
|
}
|
|
225
252
|
// implements REQ-cli-schema-migration
|
|
226
253
|
export function readText(filePath) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"predicate-applicability.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-applicability.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,EAE3B,MAAM,uBAAuB,CAAC;AAG/B,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAC5C,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAC9C,eAAO,MAAM,qBAAqB,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"predicate-applicability.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-applicability.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,qBAAqB,EAE3B,MAAM,uBAAuB,CAAC;AAG/B,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAC5C,eAAO,MAAM,0BAA0B,MAAM,CAAC;AAC9C,eAAO,MAAM,qBAAqB,OAAO,CAAC;AAoX1C,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,kBAAkB,EAAE,MAAM,CAAC;CACrC;AAED;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC3C,MAAM,EAAE,qBAAqB,EAC7B,IAAI,EAAE,MAAM,GACX,qBAAqB,CA2EvB"}
|
|
@@ -4,8 +4,10 @@ export const STRONG_APPLICABILITY_SCORE = 0.8;
|
|
|
4
4
|
export const WEAK_CANDIDATE_MARGIN = 0.06;
|
|
5
5
|
// A bare permission modal ("coaches can read", "users may export", "are
|
|
6
6
|
// permitted to") states a permission as much as "allowed" does, so it must
|
|
7
|
-
// reach the permission_rule intent rule instead of being rejected here.
|
|
8
|
-
|
|
7
|
+
// reach the permission_rule intent rule instead of being rejected here. The
|
|
8
|
+
// same holds for a capability grant ("must be able to", "are able to", "have
|
|
9
|
+
// permission to", "are entitled to"), the wording product owners use most.
|
|
10
|
+
const NORMATIVE_OR_VALIDITY_PATTERN = /\b(?:must|shall|should|required|requires?|may\s+only|only\s+.+?\s+(?:may|can)|(?:can|may)\s+(?:not\s+)?(?:only\s+)?\w+|(?:is|are)\s+(?:not\s+)?(?:allowed|permitted|entitled|able)\s+to|ha(?:s|ve)\s+permission\s+to|permitted|must\s+not|shall\s+not|cannot|can't|allowed|denied|forbidden|prohibited|invalid|unresolved|reject(?:s|ed|ion)?|fail(?:s|ed|ure)?\s+(?:clearly|explicitly|with)|defaults?\s+to|states?\s+are|owned\s+by|initializes?\s+after|before|unless|when|if|(?:exception|exempt)\s+(?:to|from|when|if|unless))\b/i;
|
|
9
11
|
function expressesNormativeOrValidityIntent(text) {
|
|
10
12
|
return /^\s*no\b/i.test(text) || NORMATIVE_OR_VALIDITY_PATTERN.test(text);
|
|
11
13
|
}
|
|
@@ -98,13 +100,17 @@ const INTENT_RULES = {
|
|
|
98
100
|
},
|
|
99
101
|
permission_rule: {
|
|
100
102
|
allOf: [
|
|
101
|
-
[
|
|
103
|
+
[
|
|
104
|
+
// "must be able to", "are able to", "have permission to" and "are
|
|
105
|
+
// entitled to" grant a permission in the same sense as "allowed".
|
|
106
|
+
/only|may|can|allowed|permitted|denied|forbidden|must\s+not|cannot|(?:must|shall|should)\s+be\s+able\s+to|(?:is|are)\s+(?:able|entitled)\s+to|ha(?:s|ve)\s+permission\s+to/i,
|
|
107
|
+
],
|
|
102
108
|
[
|
|
103
109
|
/delete|export|access|read|write|update|remove|manage|permission/i,
|
|
104
110
|
// A common action verb counts only right after the permission modal
|
|
105
111
|
// ("must not publish", "may approve"), so a quota such as "uploads
|
|
106
112
|
// must not exceed 10 MB" does not read as a permission.
|
|
107
|
-
/\b(?:may|can|cannot|can't|must\s+(?:not|never)|never|(?:is|are)\s+(?:not\s+)?(?:allowed|permitted|forbidden)\s+to)\s+(?:only\s+)?(?:publish|unpublish|approve|assign|view|see|edit|modify|create|submit|share|invite|upload|download|comment|post|complete|archive|restore|grant|revoke|purchase|cancel|execute|invoke|configure|moderate|ban|join|book|reserve|transfer|close|reopen|merge)\b/i,
|
|
113
|
+
/\b(?:may|can|cannot|can't|must\s+(?:not|never)|never|(?:is|are)\s+(?:not\s+)?(?:allowed|permitted|forbidden|entitled|able)\s+to|(?:must|shall|should)\s+be\s+able\s+to|ha(?:s|ve)\s+permission\s+to)\s+(?:only\s+)?(?:publish|unpublish|approve|assign|view|see|edit|modify|create|submit|share|invite|upload|download|comment|post|complete|archive|restore|grant|revoke|purchase|cancel|execute|invoke|configure|moderate|ban|join|book|reserve|transfer|close|reopen|merge)\b/i,
|
|
108
114
|
],
|
|
109
115
|
],
|
|
110
116
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"predicate-applyplan.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-applyplan.ts"],"names":[],"mappings":"AAWA,OAAO,KAA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,GAAG,UAAU,CAAC;IACtC,gBAAgB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IACrC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,eAAe,CAAC,EAAE,wBAAwB,CAAC;IAC3C,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;;;OAIG;IACH,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CACzC,GACA,mBAAmB,CAuLrB;AAGD,wBAAgB,uBAAuB,CACrC,UAAU,EAAE,mBAAmB,EAC/B,IAAI,EAAE,qBAAqB,GAC1B,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA0ChC;AAGD,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,MAAM,GAAG,SAAS,EAC1B,aAAa,EAAE,MAAM,GAAG,SAAS,EACjC,SAAS,CAAC,EAAE,MAAM,EAClB,mBAAmB,GAAE,SAAS,MAAM,EAAO,GAC1C,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAuBhC;AAoBD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,qBAAqB,GAC1B,KAAK,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAwBhC;AAED;;;GAGG;AACH,wBAAgB,yBAAyB,CACvC,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,MAAM,GACd,0BAA0B,CAoE5B"}
|
|
@@ -111,12 +111,23 @@ export function buildSuggestion(schema, text, subject, score, argumentBindings =
|
|
|
111
111
|
const canonicalKey = `${schema.predicate_name}(${predicateArgs.join(",")})`;
|
|
112
112
|
// Permission-style inference carries the deontic decision as its final
|
|
113
113
|
// argument. Preserve that polarity in the typed suggestion instead of
|
|
114
|
-
// silently turning a prohibition into an assertion.
|
|
114
|
+
// silently turning a prohibition into an assertion. A reviewed decision
|
|
115
|
+
// binding is the authority over the prose: "must be able to read … and
|
|
116
|
+
// must not delete" grounds an allow fact for read and a deny fact for
|
|
117
|
+
// delete from the same sentence.
|
|
118
|
+
const decisionArgument = schema.argument_names.indexOf("decision");
|
|
119
|
+
const reviewedDecision = decisionArgument >= 0 && bindingProvenanceByArgument.decision === "explicit"
|
|
120
|
+
? predicateArgs[decisionArgument]
|
|
121
|
+
: undefined;
|
|
115
122
|
const polarity = polarityHint ??
|
|
116
|
-
(
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
123
|
+
(reviewedDecision !== undefined
|
|
124
|
+
? reviewedDecision === "deny"
|
|
125
|
+
? "deny"
|
|
126
|
+
: "assert"
|
|
127
|
+
: predicateArgs.at(-1) === "deny" ||
|
|
128
|
+
/\b(?:must\s+not|shall\s+not|never|cannot|can't|forbidden|prohibited)\b/i.test(text)
|
|
129
|
+
? "deny"
|
|
130
|
+
: "assert");
|
|
120
131
|
return {
|
|
121
132
|
id: hashId("SUGGEST", [schema.id, canonicalKey, text]),
|
|
122
133
|
predicate_name: schema.predicate_name,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"predicate-catalog-4.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-catalog-4.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAGrE,eAAO,MAAM,mBAAmB,EAAE,wBAAwB,
|
|
1
|
+
{"version":3,"file":"predicate-catalog-4.d.ts","sourceRoot":"","sources":["../../../src/operations/modeling/predicate-catalog-4.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,sBAAsB,CAAC;AAGrE,eAAO,MAAM,mBAAmB,EAAE,wBAAwB,EA4TzD,CAAC"}
|