kibi-cli 2.1.0 → 2.2.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-protocol.d.ts.map +1 -1
- package/dist/cli-protocol.js +3 -2
- package/dist/commands/aggregated-checks.d.ts +7 -0
- package/dist/commands/aggregated-checks.d.ts.map +1 -1
- package/dist/commands/aggregated-checks.js +25 -1
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +21 -13
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +105 -24
- package/dist/commands/github-init.d.ts +1 -1
- package/dist/commands/github-init.d.ts.map +1 -1
- package/dist/commands/github-init.js +1 -1
- package/dist/commands/init-helpers.d.ts +17 -2
- package/dist/commands/init-helpers.d.ts.map +1 -1
- package/dist/commands/init-helpers.js +123 -23
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +110 -15
- package/dist/commands/prove.d.ts.map +1 -1
- package/dist/commands/prove.js +10 -18
- package/dist/commands/sync/cache.d.ts +20 -1
- package/dist/commands/sync/cache.d.ts.map +1 -1
- package/dist/commands/sync/cache.js +51 -2
- package/dist/commands/sync/discovery.d.ts.map +1 -1
- package/dist/commands/sync/discovery.js +1 -1
- package/dist/commands/sync/persistence.d.ts.map +1 -1
- package/dist/commands/sync/persistence.js +8 -0
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +11 -3
- package/dist/engine.d.ts +26 -0
- package/dist/engine.d.ts.map +1 -1
- package/dist/engine.js +126 -29
- package/dist/extractors/manifest.d.ts.map +1 -1
- package/dist/extractors/manifest.js +66 -28
- package/dist/extractors/markdown.d.ts +2 -0
- package/dist/extractors/markdown.d.ts.map +1 -1
- package/dist/extractors/markdown.js +14 -3
- package/dist/extractors/relationships.d.ts.map +1 -1
- package/dist/extractors/relationships.js +1 -0
- package/dist/intent-search.d.ts.map +1 -1
- package/dist/intent-search.js +68 -29
- package/dist/operations/bootstrap/generate.d.ts.map +1 -1
- package/dist/operations/bootstrap/generate.js +4 -3
- package/dist/operations/modeling/model-requirement.d.ts +1 -1
- package/dist/operations/modeling/model-requirement.d.ts.map +1 -1
- package/dist/operations/modeling/model-requirement.js +176 -10
- package/dist/operations/modeling/predicate-applyplan.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-applyplan.js +14 -2
- package/dist/operations/modeling/predicate-loader.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-loader.js +24 -0
- package/dist/operations/modeling/predicate-types.d.ts +4 -0
- package/dist/operations/modeling/predicate-types.d.ts.map +1 -1
- package/dist/operations/modeling/predicate-vocabulary.d.ts +54 -0
- package/dist/operations/modeling/predicate-vocabulary.d.ts.map +1 -0
- package/dist/operations/modeling/predicate-vocabulary.js +169 -0
- package/dist/operations/modeling/requirement-types.d.ts +5 -0
- package/dist/operations/modeling/requirement-types.d.ts.map +1 -1
- package/dist/operations/modeling/vocabulary-alignment.d.ts +60 -0
- package/dist/operations/modeling/vocabulary-alignment.d.ts.map +1 -0
- package/dist/operations/modeling/vocabulary-alignment.js +178 -0
- package/dist/operations/mutation/contradictions.d.ts +3 -0
- package/dist/operations/mutation/contradictions.d.ts.map +1 -1
- package/dist/operations/mutation/contradictions.js +29 -0
- package/dist/operations/mutation/delete.d.ts.map +1 -1
- package/dist/operations/mutation/delete.js +33 -1
- package/dist/operations/mutation/predicate-vocabulary-guard.d.ts +8 -0
- package/dist/operations/mutation/predicate-vocabulary-guard.d.ts.map +1 -0
- package/dist/operations/mutation/predicate-vocabulary-guard.js +64 -0
- package/dist/operations/mutation/relationships.d.ts +1 -1
- package/dist/operations/mutation/relationships.d.ts.map +1 -1
- package/dist/operations/mutation/relationships.js +1 -0
- package/dist/operations/mutation/saga.d.ts +5 -0
- package/dist/operations/mutation/saga.d.ts.map +1 -1
- package/dist/operations/mutation/saga.js +10 -0
- package/dist/operations/mutation/serialization.d.ts.map +1 -1
- package/dist/operations/mutation/serialization.js +2 -0
- package/dist/operations/mutation/source-authoring.d.ts +6 -0
- package/dist/operations/mutation/source-authoring.d.ts.map +1 -1
- package/dist/operations/mutation/source-authoring.js +65 -26
- package/dist/operations/mutation/strict-fact.d.ts.map +1 -1
- package/dist/operations/mutation/strict-fact.js +5 -0
- package/dist/operations/mutation/types.d.ts +17 -0
- package/dist/operations/mutation/types.d.ts.map +1 -1
- package/dist/operations/mutation/upsert.d.ts +6 -0
- package/dist/operations/mutation/upsert.d.ts.map +1 -1
- package/dist/operations/mutation/upsert.js +72 -4
- package/dist/operations/mutation/validate-upsert.d.ts.map +1 -1
- package/dist/operations/mutation/validate-upsert.js +24 -1
- package/dist/operations/mutation/validation.d.ts.map +1 -1
- package/dist/operations/mutation/validation.js +16 -3
- package/dist/operations/planning/apply-plan.d.ts.map +1 -1
- package/dist/operations/planning/apply-plan.js +61 -17
- package/dist/operations/planning/compile-intent.d.ts.map +1 -1
- package/dist/operations/planning/compile-intent.js +3 -1
- package/dist/operations/proof/code-scope.d.ts +17 -0
- package/dist/operations/proof/code-scope.d.ts.map +1 -0
- package/dist/operations/proof/code-scope.js +60 -0
- package/dist/operations/proof/ingest-proof.d.ts +4 -2
- package/dist/operations/proof/ingest-proof.d.ts.map +1 -1
- package/dist/operations/proof/ingest-proof.js +207 -74
- package/dist/operations/proof/migrate-legacy-receipts.d.ts.map +1 -1
- package/dist/operations/proof/migrate-legacy-receipts.js +7 -5
- package/dist/operations/proof/prune-receipts.d.ts.map +1 -1
- package/dist/operations/proof/prune-receipts.js +7 -5
- package/dist/plugins/compose-semantic-classifier.d.ts +6 -1
- package/dist/plugins/compose-semantic-classifier.d.ts.map +1 -1
- package/dist/plugins/compose-semantic-classifier.js +8 -3
- package/dist/plugins/compose-vocabulary-alignment.d.ts +23 -0
- package/dist/plugins/compose-vocabulary-alignment.d.ts.map +1 -0
- package/dist/plugins/compose-vocabulary-alignment.js +141 -0
- package/dist/plugins/external-allowlist.d.ts +7 -0
- package/dist/plugins/external-allowlist.d.ts.map +1 -1
- package/dist/plugins/external-allowlist.js +13 -0
- package/dist/plugins/index.d.ts +2 -0
- package/dist/plugins/index.d.ts.map +1 -1
- package/dist/plugins/index.js +4 -0
- package/dist/plugins/registry.d.ts +2 -1
- package/dist/plugins/registry.d.ts.map +1 -1
- package/dist/plugins/registry.js +22 -1
- package/dist/prolog/codec.d.ts.map +1 -1
- package/dist/prolog/codec.js +2 -0
- package/dist/prolog.d.ts +36 -0
- package/dist/prolog.d.ts.map +1 -1
- package/dist/prolog.js +78 -9
- package/dist/public/diagnostic-usage.d.ts.map +1 -1
- package/dist/public/diagnostic-usage.js +7 -25
- package/dist/public/impact/full-kb-quality.d.ts.map +1 -1
- package/dist/public/impact/full-kb-quality.js +4 -12
- package/dist/public/operations/catalog.d.ts +36 -7
- package/dist/public/operations/catalog.d.ts.map +1 -1
- package/dist/public/operations/check-executor.d.ts.map +1 -1
- package/dist/public/operations/check-executor.js +10 -2
- package/dist/public/operations/check-helpers.d.ts +6 -0
- package/dist/public/operations/check-helpers.d.ts.map +1 -1
- package/dist/public/operations/check-helpers.js +21 -1
- package/dist/public/operations/contracts.d.ts.map +1 -1
- package/dist/public/operations/contracts.js +16 -0
- package/dist/public/operations/discovery-entities.d.ts +42 -2
- package/dist/public/operations/discovery-entities.d.ts.map +1 -1
- package/dist/public/operations/discovery-entities.js +195 -22
- package/dist/public/operations/discovery-executors.d.ts +1 -0
- package/dist/public/operations/discovery-executors.d.ts.map +1 -1
- package/dist/public/operations/discovery-executors.js +75 -46
- package/dist/public/operations/migration-plan.d.ts +2 -0
- package/dist/public/operations/migration-plan.d.ts.map +1 -1
- package/dist/public/operations/migration-plan.js +50 -0
- package/dist/public/operations/predicate-schema-conformance.d.ts +41 -0
- package/dist/public/operations/predicate-schema-conformance.d.ts.map +1 -0
- package/dist/public/operations/predicate-schema-conformance.js +242 -0
- package/dist/public/operations/prolog-json.d.ts.map +1 -1
- package/dist/public/operations/prolog-json.js +9 -3
- package/dist/public/operations/result-envelope.d.ts +34 -1
- package/dist/public/operations/result-envelope.d.ts.map +1 -1
- package/dist/public/operations/result-envelope.js +78 -2
- package/dist/public/operations/runtime-types.d.ts +1 -1
- package/dist/public/operations/runtime-types.d.ts.map +1 -1
- package/dist/public/operations/specs/check-rules.generated.d.ts +1 -1
- package/dist/public/operations/specs/check-rules.generated.d.ts.map +1 -1
- package/dist/public/operations/specs/check-rules.generated.js +8 -1
- package/dist/public/operations/specs/check.d.ts +1 -1
- package/dist/public/operations/specs/discovery.d.ts +7 -1
- package/dist/public/operations/specs/discovery.d.ts.map +1 -1
- package/dist/public/operations/specs/discovery.js +7 -1
- package/dist/public/operations/specs/mutation-schemas.d.ts +27 -4
- package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
- package/dist/public/operations/specs/mutation-schemas.js +21 -3
- package/dist/public/operations/specs/reporting.d.ts +8 -0
- package/dist/public/operations/specs/reporting.d.ts.map +1 -1
- package/dist/public/operations/specs/reporting.js +46 -15
- package/dist/public/operations/specs/upsert.d.ts +28 -5
- package/dist/public/operations/specs/upsert.d.ts.map +1 -1
- package/dist/public/operations/specs/upsert.js +1 -1
- package/dist/public/operations/symbol-repair-plan.d.ts.map +1 -1
- package/dist/public/operations/symbol-repair-plan.js +8 -3
- package/dist/public/schemas/entity.d.ts.map +1 -1
- package/dist/public/schemas/entity.js +22 -0
- package/dist/public/schemas/relationship.d.ts.map +1 -1
- package/dist/public/schemas/relationship.js +1 -0
- package/dist/public/skills/kibi-usage/SKILL.md +7 -3
- package/dist/public/skills/kibi-usage/resources/fact-lanes.md +4 -0
- package/dist/public/skills/kibi-usage/resources/relationship-directions.md +35 -17
- package/dist/public/skills/kibi-usage/resources/source-authoring.md +36 -0
- package/dist/public/skills/kibi-usage/resources/workflows.md +52 -1
- package/dist/public/telemetry-acceptance.d.ts.map +1 -1
- package/dist/public/telemetry-acceptance.js +21 -5
- package/dist/relationships/shards.d.ts +6 -0
- package/dist/relationships/shards.d.ts.map +1 -1
- package/dist/relationships/shards.js +26 -19
- package/dist/schemas/entity.schema.json +32 -0
- package/dist/traceability/staged-diagnostics.d.ts +1 -1
- package/dist/traceability/staged-diagnostics.d.ts.map +1 -1
- package/dist/traceability/staged-entity-id-style.d.ts +12 -0
- package/dist/traceability/staged-entity-id-style.d.ts.map +1 -0
- package/dist/traceability/staged-entity-id-style.js +68 -0
- package/dist/traceability/temp-kb.d.ts.map +1 -1
- package/dist/traceability/temp-kb.js +8 -0
- package/dist/traceability/validate.js +1 -1
- package/dist/types/entities.d.ts +2 -0
- package/dist/types/entities.d.ts.map +1 -1
- package/dist/types/relationships.d.ts +1 -1
- package/dist/types/relationships.d.ts.map +1 -1
- package/dist/utils/entity-id-style.d.ts +27 -0
- package/dist/utils/entity-id-style.d.ts.map +1 -0
- package/dist/utils/entity-id-style.js +81 -0
- package/dist/utils/git-repository-context.d.ts +50 -0
- package/dist/utils/git-repository-context.d.ts.map +1 -0
- package/dist/utils/git-repository-context.js +259 -0
- package/dist/utils/rule-registry.d.ts +5 -0
- package/dist/utils/rule-registry.d.ts.map +1 -1
- package/dist/utils/rule-registry.generated.d.ts +37 -0
- package/dist/utils/rule-registry.generated.d.ts.map +1 -1
- package/dist/utils/rule-registry.generated.js +44 -0
- package/dist/utils/strict-modeling.d.ts +7 -0
- package/dist/utils/strict-modeling.d.ts.map +1 -1
- package/dist/utils/strict-modeling.js +11 -0
- package/package.json +4 -4
- package/schema/entities.pl +60 -1
- package/schema/relationships.pl +17 -4
- package/schema/validation.pl +118 -20
- package/src/public/diagnostic-usage.ts +16 -24
- package/src/public/impact/full-kb-quality.ts +4 -16
- package/src/public/operations/check-executor.ts +12 -1
- package/src/public/operations/check-helpers.ts +27 -1
- package/src/public/operations/contracts.ts +19 -0
- package/src/public/operations/discovery-entities.ts +292 -23
- package/src/public/operations/discovery-executors.ts +91 -55
- package/src/public/operations/migration-plan.ts +57 -0
- package/src/public/operations/predicate-schema-conformance.ts +362 -0
- package/src/public/operations/prolog-json.ts +9 -3
- package/src/public/operations/result-envelope.ts +114 -2
- package/src/public/operations/runtime-types.ts +1 -1
- package/src/public/operations/specs/check-rules.generated.ts +8 -1
- package/src/public/operations/specs/discovery.ts +8 -1
- package/src/public/operations/specs/mutation-schemas.ts +23 -3
- package/src/public/operations/specs/reporting.ts +69 -22
- package/src/public/operations/specs/upsert.ts +1 -1
- package/src/public/operations/symbol-repair-plan.ts +13 -3
- package/src/public/schemas/entity.ts +22 -0
- package/src/public/schemas/relationship.ts +1 -0
- package/src/public/skills/kibi-usage/SKILL.md +7 -3
- package/src/public/skills/kibi-usage/resources/fact-lanes.md +4 -0
- package/src/public/skills/kibi-usage/resources/relationship-directions.md +35 -17
- package/src/public/skills/kibi-usage/resources/source-authoring.md +36 -0
- package/src/public/skills/kibi-usage/resources/workflows.md +52 -1
- package/src/public/telemetry-acceptance.ts +37 -6
- package/src/schemas/entity.schema.json +32 -0
- package/src/schemas/relationship.schema.json +1 -0
package/dist/commands/sync.js
CHANGED
|
@@ -30,12 +30,15 @@ import { PrologProcess } from "../prolog.js";
|
|
|
30
30
|
import { resolveBranchAttachment } from "../utils/branch-resolver.js";
|
|
31
31
|
import { branchStoreManifestPath, branchStorePath, ensureBranchStoreManifest, expectedBranchStoreManifest, } from "../utils/branch-store-locator.js";
|
|
32
32
|
import { loadEntityPaths } from "../utils/config.js";
|
|
33
|
-
import { SYNC_CACHE_TTL_MS, SYNC_CACHE_VERSION, hashFile, hashManifestWithCoordinates, hashNormalized, readSyncCache, toCacheKey, writeSyncCache, } from "./sync/cache.js";
|
|
33
|
+
import { SYNC_CACHE_TTL_MS, SYNC_CACHE_VERSION, SYNC_COMPILER_FINGERPRINT, hashFile, hashManifestWithCoordinates, hashNormalized, readSyncCache, toCacheKey, writeSyncCache, } from "./sync/cache.js";
|
|
34
34
|
import { clearRecoveredPendingSourceReceipts, discoverSourceFiles, } from "./sync/discovery.js";
|
|
35
35
|
import { normalizeExtractionSources, processExtractions, } from "./sync/extraction.js";
|
|
36
36
|
import { refreshManifestCoordinates } from "./sync/manifest.js";
|
|
37
37
|
import { persistEntities, persistRelationships, retractEntitiesById, retractEntitiesForSources, retractEntityRelationshipsById, retractRelationships, } from "./sync/persistence.js";
|
|
38
38
|
import { atomicPublish, atomicPublishGeneration, cleanupStaging, createUniqueStagingPath, prepareStagingEnvironment, } from "./sync/staging.js";
|
|
39
|
+
// Manual deletion of a written-but-unstaged source leaves a recovery receipt
|
|
40
|
+
// behind; sync refuses to guess, so the error must name the way out.
|
|
41
|
+
const PENDING_SOURCE_RECOVERY_HINT = " If the file was deleted on purpose, run 'kibi branch recover --apply' to rebuild the branch KB from the sources that remain.";
|
|
39
42
|
export class SyncError extends Error {
|
|
40
43
|
constructor(message) {
|
|
41
44
|
super(message);
|
|
@@ -130,7 +133,7 @@ export function trackedRelationshipFiles(workspaceRoot, relationshipsDir, recove
|
|
|
130
133
|
}
|
|
131
134
|
continue;
|
|
132
135
|
}
|
|
133
|
-
throw new SyncError(`Pending source is missing: ${relative}`);
|
|
136
|
+
throw new SyncError(`Pending source is missing: ${relative}.${PENDING_SOURCE_RECOVERY_HINT}`);
|
|
134
137
|
}
|
|
135
138
|
const actual = createHash("sha256")
|
|
136
139
|
.update(readFileSync(absolute))
|
|
@@ -365,7 +368,9 @@ export async function syncCommand(options = {}, runtime = {}) {
|
|
|
365
368
|
}
|
|
366
369
|
const sourceFiles = [...markdownFiles, ...manifestFiles].sort();
|
|
367
370
|
const cachePath = path.join(livePathForEngine, "sync-cache.json");
|
|
368
|
-
const syncCache = readSyncCache(cachePath
|
|
371
|
+
const syncCache = readSyncCache(cachePath, undefined, {
|
|
372
|
+
compilerFingerprint: SYNC_COMPILER_FINGERPRINT,
|
|
373
|
+
});
|
|
369
374
|
const nowIso = new Date().toISOString();
|
|
370
375
|
const nowMs = Date.now();
|
|
371
376
|
const currentSourceKeys = new Set(sourceFiles.map((file) => toCacheKey(workspaceRoot, file)));
|
|
@@ -725,6 +730,7 @@ export async function syncCommand(options = {}, runtime = {}) {
|
|
|
725
730
|
seenAt: evictedSeenAt,
|
|
726
731
|
semanticHashes: evictedSemanticHashes,
|
|
727
732
|
semanticContracts: evictedSemanticContracts,
|
|
733
|
+
compilerFingerprint: SYNC_COMPILER_FINGERPRINT,
|
|
728
734
|
});
|
|
729
735
|
console.log("✓ Imported 0 entities, 0 relationships (no changes)");
|
|
730
736
|
return withOptionalCommit({
|
|
@@ -870,6 +876,7 @@ export async function syncCommand(options = {}, runtime = {}) {
|
|
|
870
876
|
seenAt: evictedSeenAt,
|
|
871
877
|
semanticHashes: evictedSemanticHashes,
|
|
872
878
|
semanticContracts: evictedSemanticContracts,
|
|
879
|
+
compilerFingerprint: SYNC_COMPILER_FINGERPRINT,
|
|
873
880
|
});
|
|
874
881
|
published = true;
|
|
875
882
|
if (performedFullReindex &&
|
|
@@ -1062,6 +1069,7 @@ export async function syncCommand(options = {}, runtime = {}) {
|
|
|
1062
1069
|
seenAt: evictedSeenAt,
|
|
1063
1070
|
semanticHashes: evictedSemanticHashes,
|
|
1064
1071
|
semanticContracts: evictedSemanticContracts,
|
|
1072
|
+
compilerFingerprint: SYNC_COMPILER_FINGERPRINT,
|
|
1065
1073
|
});
|
|
1066
1074
|
published = true;
|
|
1067
1075
|
maybePushDocsNotIndexedDiagnostic(diagnostics, performedFullReindex, markdownFiles.length, entityCount);
|
package/dist/engine.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { EngineAttachmentIdentity, EngineCommandV1 } from "./engine-types.js";
|
|
2
|
+
import { PrologProcess } from "./prolog.js";
|
|
2
3
|
import type { PrologQueryResult } from "./public/operations/runtime-types.js";
|
|
3
4
|
import type { PrologEntityQueryInput, PrologEntityQueryResult, PrologSearchQueryInput, PrologSearchQueryResult } from "./public/operations/runtime-types.js";
|
|
4
5
|
export type { EngineAttachmentIdentity, EngineCommandV1, EngineRequest, } from "./engine-types.js";
|
|
@@ -68,6 +69,7 @@ export declare class EngineClient {
|
|
|
68
69
|
command<T = PrologQueryResult>(command: EngineCommandV1, signal?: AbortSignal): Promise<T>;
|
|
69
70
|
queryBatch(goals: readonly string[]): Promise<PrologQueryResult>;
|
|
70
71
|
queryEntities(input: PrologEntityQueryInput, signal?: AbortSignal): Promise<PrologEntityQueryResult>;
|
|
72
|
+
private queryEntityChunk;
|
|
71
73
|
searchEntities(input: PrologSearchQueryInput, signal?: AbortSignal): Promise<PrologSearchQueryResult>;
|
|
72
74
|
/** Best-effort cancellation for a queued request. */
|
|
73
75
|
cancel(requestId: number): void;
|
|
@@ -88,9 +90,33 @@ export declare class EngineClient {
|
|
|
88
90
|
terminate(): Promise<void>;
|
|
89
91
|
}
|
|
90
92
|
export declare function ensureJournaledBranchStoreAsync(branchPath: string): Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* Owns the daemon's interactive SWI session: the attached branch store plus
|
|
95
|
+
* every module loaded into it. An overflow or timeout terminates the SWI
|
|
96
|
+
* child; the next request recycles the session (restart, reattach, reload
|
|
97
|
+
* modules) instead of letting the port degrade into isolated one-shot
|
|
98
|
+
* processes that have lost the attachment and module state.
|
|
99
|
+
*/
|
|
100
|
+
export declare class EngineSession {
|
|
101
|
+
private readonly prolog;
|
|
102
|
+
private readonly branchPath;
|
|
103
|
+
private readonly modules;
|
|
104
|
+
constructor(prolog: PrologProcess, branchPath: string);
|
|
105
|
+
boot(): Promise<void>;
|
|
106
|
+
/** Remember a successful client module load so a recycle restores it. */
|
|
107
|
+
recordModuleLoad(goal: string, result: PrologQueryResult): void;
|
|
108
|
+
needsRecycle(): boolean;
|
|
109
|
+
/**
|
|
110
|
+
* Restart a lost interactive session. Returns true when a recycle ran. A
|
|
111
|
+
* failed recycle leaves the process stopped so the next request retries.
|
|
112
|
+
*/
|
|
113
|
+
ensureLive(): Promise<boolean>;
|
|
114
|
+
}
|
|
91
115
|
export declare function runEngineDaemon(options: {
|
|
92
116
|
readonly workspaceRoot: string;
|
|
93
117
|
readonly branch: string;
|
|
94
118
|
readonly socketPath: string;
|
|
119
|
+
/** Test seam: bounded Prolog output per query (defaults to 8 MiB). */
|
|
120
|
+
readonly maxOutputBytes?: number;
|
|
95
121
|
}): Promise<void>;
|
|
96
122
|
//# sourceMappingURL=engine.d.ts.map
|
package/dist/engine.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EACV,wBAAwB,EACxB,eAAe,EAEhB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"engine.d.ts","sourceRoot":"","sources":["../src/engine.ts"],"names":[],"mappings":"AA8BA,OAAO,KAAK,EACV,wBAAwB,EACxB,eAAe,EAEhB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,aAAa,EAAmB,MAAM,aAAa,CAAC;AAI7D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sCAAsC,CAAC;AAC9E,OAAO,KAAK,EACV,sBAAsB,EACtB,uBAAuB,EACvB,sBAAsB,EACtB,uBAAuB,EACxB,MAAM,sCAAsC,CAAC;AAO9C,YAAY,EACV,wBAAwB,EACxB,eAAe,EACf,aAAa,GACd,MAAM,mBAAmB,CAAC;AAE3B,eAAO,MAAM,uBAAuB,IAAI,CAAC;AACzC,eAAO,MAAM,sBAAsB,QAAiB,CAAC;AACrD,eAAO,MAAM,uBAAuB,QACY,CAAC;AAOjD,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,MAAM,OAAO,GACtB,MAAM,IAAI,CAIZ;AAED,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAKhE;AAED,wBAAgB,4BAA4B,CAC1C,UAAU,EAAE,MAAM,GACjB,wBAAwB,GAAG,IAAI,CAgBjC;AAED,wBAAgB,6BAA6B,CAC3C,UAAU,EAAE,MAAM,GAAG,SAAS,GAC7B,wBAAwB,GAAG,IAAI,CAyBjC;AAED,wBAAgB,sBAAsB,CACpC,QAAQ,EAAE,wBAAw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,EAAE;IAC7C,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,sEAAsE;IACtE,QAAQ,CAAC,cAAc,CAAC,EAAE,MAAM,CAAC;CAClC,GAAG,OAAO,CAAC,IAAI,CAAC,CAooBhB"}
|
package/dist/engine.js
CHANGED
|
@@ -15,6 +15,7 @@ import { fileURLToPath } from "node:url";
|
|
|
15
15
|
import { PrologProcess, resolveKbPlPath } from "./prolog.js";
|
|
16
16
|
import { parseEntityFromList, parseListOfLists } from "./prolog/codec.js";
|
|
17
17
|
import { retryAttachAfterBreakingStaleLock } from "./prolog/store-lock.js";
|
|
18
|
+
import { queryEntityChunks } from "./public/operations/discovery-entities.js";
|
|
18
19
|
import { isValidBranchName } from "./utils/branch-resolver.js";
|
|
19
20
|
import { branchStorePath, ensureBranchStoreManifest, } from "./utils/branch-store-locator.js";
|
|
20
21
|
export const ENGINE_PROTOCOL_VERSION = 1;
|
|
@@ -219,11 +220,19 @@ function frame(value) {
|
|
|
219
220
|
header.writeUInt32BE(payload.byteLength, 0);
|
|
220
221
|
return Buffer.concat([header, payload]);
|
|
221
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* Swallow a write failure for a peer that is already gone.
|
|
225
|
+
*
|
|
226
|
+
* A socket write reports EPIPE/ECONNRESET asynchronously, so a surrounding
|
|
227
|
+
* try/catch cannot see it and Node raises it as an unhandled error. Passing a
|
|
228
|
+
* callback keeps the failure local to this write.
|
|
229
|
+
*/
|
|
230
|
+
function ignoreWriteFailure() { }
|
|
222
231
|
function writeSocketFrame(socket, value) {
|
|
223
232
|
if (socket.destroyed || !socket.writable)
|
|
224
233
|
return;
|
|
225
234
|
try {
|
|
226
|
-
socket.write(frame(value));
|
|
235
|
+
socket.write(frame(value), ignoreWriteFailure);
|
|
227
236
|
}
|
|
228
237
|
catch {
|
|
229
238
|
// A client may disconnect while a queued request is finishing. The
|
|
@@ -852,7 +861,7 @@ export class EngineClient {
|
|
|
852
861
|
packageVersions: ENGINE_PACKAGE_VERSIONS,
|
|
853
862
|
workspaceRoot: this.workspaceRoot,
|
|
854
863
|
branch: this.branch,
|
|
855
|
-
}));
|
|
864
|
+
}), ignoreWriteFailure);
|
|
856
865
|
}
|
|
857
866
|
catch (error) {
|
|
858
867
|
const pending = this.pending.get(id);
|
|
@@ -897,6 +906,11 @@ export class EngineClient {
|
|
|
897
906
|
return this.query(`rdf_transaction((${normalized.join(", ")}))`);
|
|
898
907
|
}
|
|
899
908
|
async queryEntities(input, signal) {
|
|
909
|
+
// Full entities carry receipt histories; a caller-sized page (up to 100k
|
|
910
|
+
// rows) is split into bounded engine requests.
|
|
911
|
+
return queryEntityChunks((chunk) => this.queryEntityChunk(chunk, signal), input);
|
|
912
|
+
}
|
|
913
|
+
async queryEntityChunk(input, signal) {
|
|
900
914
|
const result = await this.command({
|
|
901
915
|
version: 1,
|
|
902
916
|
kind: "entities",
|
|
@@ -956,7 +970,7 @@ export class EngineClient {
|
|
|
956
970
|
packageVersions: ENGINE_PACKAGE_VERSIONS,
|
|
957
971
|
workspaceRoot: this.workspaceRoot,
|
|
958
972
|
branch: this.branch,
|
|
959
|
-
}));
|
|
973
|
+
}), ignoreWriteFailure);
|
|
960
974
|
}
|
|
961
975
|
async nextSolution() {
|
|
962
976
|
const result = this.lastResult;
|
|
@@ -1286,6 +1300,92 @@ function recoverInterruptedGeneration(branchPath) {
|
|
|
1286
1300
|
}
|
|
1287
1301
|
}
|
|
1288
1302
|
}
|
|
1303
|
+
function isEngineLifecycleRequest(request) {
|
|
1304
|
+
if (request.method === "stop" || request.method === "cancel")
|
|
1305
|
+
return true;
|
|
1306
|
+
const kind = request.command?.kind;
|
|
1307
|
+
return (request.method === "command" &&
|
|
1308
|
+
(kind === "stop" || kind === "cancel" || kind === "lifecycle"));
|
|
1309
|
+
}
|
|
1310
|
+
const ENGINE_PRELOADED_MODULES = [
|
|
1311
|
+
["status.pl", "status"],
|
|
1312
|
+
["discovery.pl", "discovery"],
|
|
1313
|
+
];
|
|
1314
|
+
const USE_MODULE_GOAL = /^use_module\('(?:[^']|'')*'\)$/u;
|
|
1315
|
+
/**
|
|
1316
|
+
* Owns the daemon's interactive SWI session: the attached branch store plus
|
|
1317
|
+
* every module loaded into it. An overflow or timeout terminates the SWI
|
|
1318
|
+
* child; the next request recycles the session (restart, reattach, reload
|
|
1319
|
+
* modules) instead of letting the port degrade into isolated one-shot
|
|
1320
|
+
* processes that have lost the attachment and module state.
|
|
1321
|
+
*/
|
|
1322
|
+
// implements REQ-core-journaled-engine-persistence
|
|
1323
|
+
export class EngineSession {
|
|
1324
|
+
prolog;
|
|
1325
|
+
branchPath;
|
|
1326
|
+
modules = [];
|
|
1327
|
+
constructor(prolog, branchPath) {
|
|
1328
|
+
this.prolog = prolog;
|
|
1329
|
+
this.branchPath = branchPath;
|
|
1330
|
+
const coreModuleDir = path.dirname(resolveKbPlPath());
|
|
1331
|
+
for (const [fileName, label] of ENGINE_PRELOADED_MODULES) {
|
|
1332
|
+
const modulePath = path.join(coreModuleDir, fileName);
|
|
1333
|
+
this.modules.push({
|
|
1334
|
+
goal: `use_module('${quoteProlog(modulePath.replaceAll("\\", "/"))}')`,
|
|
1335
|
+
label,
|
|
1336
|
+
});
|
|
1337
|
+
}
|
|
1338
|
+
}
|
|
1339
|
+
async boot() {
|
|
1340
|
+
await this.prolog.start();
|
|
1341
|
+
const attached = await this.prolog.query(`kb_attach('${quoteProlog(this.branchPath)}')`);
|
|
1342
|
+
if (!attached.success) {
|
|
1343
|
+
// The daemon hosts the branch store for every later request, so a
|
|
1344
|
+
// store-locked startup with a provably dead holder is auto-healed here
|
|
1345
|
+
// exactly like the CLI runtime path; live holders abort the startup
|
|
1346
|
+
// with the holder identity surfaced.
|
|
1347
|
+
const recovered = await retryAttachAfterBreakingStaleLock(this.prolog, this.branchPath, attached);
|
|
1348
|
+
if (!recovered.success)
|
|
1349
|
+
throw new Error(recovered.error ?? "Failed to attach branch KB");
|
|
1350
|
+
}
|
|
1351
|
+
for (const { goal, label } of this.modules) {
|
|
1352
|
+
const loaded = await this.prolog.query(goal);
|
|
1353
|
+
if (!loaded.success) {
|
|
1354
|
+
throw new Error(loaded.error ?? `Failed to load Kibi ${label} module`);
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1358
|
+
/** Remember a successful client module load so a recycle restores it. */
|
|
1359
|
+
recordModuleLoad(goal, result) {
|
|
1360
|
+
const normalized = goal.trim().replace(/\.+\s*$/u, "");
|
|
1361
|
+
if (result.success &&
|
|
1362
|
+
USE_MODULE_GOAL.test(normalized) &&
|
|
1363
|
+
!this.modules.some((module) => module.goal === normalized)) {
|
|
1364
|
+
this.modules.push({ goal: normalized, label: "client-loaded" });
|
|
1365
|
+
}
|
|
1366
|
+
}
|
|
1367
|
+
needsRecycle() {
|
|
1368
|
+
return this.prolog.needsRestart();
|
|
1369
|
+
}
|
|
1370
|
+
/**
|
|
1371
|
+
* Restart a lost interactive session. Returns true when a recycle ran. A
|
|
1372
|
+
* failed recycle leaves the process stopped so the next request retries.
|
|
1373
|
+
*/
|
|
1374
|
+
async ensureLive() {
|
|
1375
|
+
if (!this.prolog.needsRestart())
|
|
1376
|
+
return false;
|
|
1377
|
+
console.error("[KIBI] engine Prolog session was lost (output overflow, timeout, or crash); restarting and reattaching the branch store");
|
|
1378
|
+
try {
|
|
1379
|
+
await this.boot();
|
|
1380
|
+
}
|
|
1381
|
+
catch (error) {
|
|
1382
|
+
await this.prolog.terminate().catch(() => undefined);
|
|
1383
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
1384
|
+
throw new Error(`Kibi engine failed to recycle its Prolog session: ${message}`);
|
|
1385
|
+
}
|
|
1386
|
+
return true;
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1289
1389
|
// implements REQ-core-journaled-engine-lifecycle
|
|
1290
1390
|
export async function runEngineDaemon(options) {
|
|
1291
1391
|
if (!isValidBranchName(options.branch)) {
|
|
@@ -1293,30 +1393,16 @@ export async function runEngineDaemon(options) {
|
|
|
1293
1393
|
}
|
|
1294
1394
|
const branchPath = ensureBranchStoreManifest(options.workspaceRoot, options.branch);
|
|
1295
1395
|
await ensureJournaledBranchStoreAsync(branchPath);
|
|
1296
|
-
const prolog = new PrologProcess({
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
throw new Error(recovered.error ?? "Failed to attach branch KB");
|
|
1307
|
-
}
|
|
1308
|
-
const attachedIdentity = readEngineAttachmentIdentity(branchPath);
|
|
1309
|
-
const coreModuleDir = path.dirname(resolveKbPlPath());
|
|
1310
|
-
for (const [fileName, label] of [
|
|
1311
|
-
["status.pl", "status"],
|
|
1312
|
-
["discovery.pl", "discovery"],
|
|
1313
|
-
]) {
|
|
1314
|
-
const modulePath = path.join(coreModuleDir, fileName);
|
|
1315
|
-
const loaded = await prolog.query(`use_module('${quoteProlog(modulePath.replaceAll("\\", "/"))}')`);
|
|
1316
|
-
if (!loaded.success) {
|
|
1317
|
-
throw new Error(loaded.error ?? `Failed to load Kibi ${label} module`);
|
|
1318
|
-
}
|
|
1319
|
-
}
|
|
1396
|
+
const prolog = new PrologProcess({
|
|
1397
|
+
timeout: 120_000,
|
|
1398
|
+
oneShot: false,
|
|
1399
|
+
...(options.maxOutputBytes === undefined
|
|
1400
|
+
? {}
|
|
1401
|
+
: { maxOutputBytes: options.maxOutputBytes }),
|
|
1402
|
+
});
|
|
1403
|
+
const session = new EngineSession(prolog, branchPath);
|
|
1404
|
+
await session.boot();
|
|
1405
|
+
let attachedIdentity = readEngineAttachmentIdentity(branchPath);
|
|
1320
1406
|
mkdirSync(path.dirname(options.socketPath), { recursive: true, mode: 0o700 });
|
|
1321
1407
|
if (existsSync(options.socketPath)) {
|
|
1322
1408
|
const isLivePeerSignal = (error) => {
|
|
@@ -1440,7 +1526,8 @@ export async function runEngineDaemon(options) {
|
|
|
1440
1526
|
idleCompactionQueued = true;
|
|
1441
1527
|
queue = queue
|
|
1442
1528
|
.then(async () => {
|
|
1443
|
-
|
|
1529
|
+
// A lost session is recycled by the next request, not by idle work.
|
|
1530
|
+
if (activeClients === 0 && !session.needsRecycle()) {
|
|
1444
1531
|
await prolog.query("kb_storage_compact_if_needed");
|
|
1445
1532
|
}
|
|
1446
1533
|
})
|
|
@@ -1470,6 +1557,13 @@ export async function runEngineDaemon(options) {
|
|
|
1470
1557
|
request.branch !== options.branch) {
|
|
1471
1558
|
throw new Error("Kibi engine workspace identity mismatch");
|
|
1472
1559
|
}
|
|
1560
|
+
if (!isEngineLifecycleRequest(request) && (await session.ensureLive())) {
|
|
1561
|
+
// A recycled session re-read the store; nothing cached from the lost
|
|
1562
|
+
// session may be served, and the attachment identity may have moved.
|
|
1563
|
+
queryCache.clear();
|
|
1564
|
+
freshnessCache = null;
|
|
1565
|
+
attachedIdentity = readEngineAttachmentIdentity(branchPath);
|
|
1566
|
+
}
|
|
1473
1567
|
switch (request.method) {
|
|
1474
1568
|
case "entities": {
|
|
1475
1569
|
const limit = request.limit ?? 100;
|
|
@@ -1679,6 +1773,7 @@ export async function runEngineDaemon(options) {
|
|
|
1679
1773
|
return cached;
|
|
1680
1774
|
}
|
|
1681
1775
|
const result = await prolog.query(request.goal);
|
|
1776
|
+
session.recordModuleLoad(request.goal, result);
|
|
1682
1777
|
if (result.success && mutatingEngineGoal(request.goal)) {
|
|
1683
1778
|
fsyncJournaledBranchStore(branchPath);
|
|
1684
1779
|
}
|
|
@@ -1741,7 +1836,9 @@ export async function runEngineDaemon(options) {
|
|
|
1741
1836
|
if (idleTimer)
|
|
1742
1837
|
clearTimeout(idleTimer);
|
|
1743
1838
|
clearInterval(workspaceWatchdog);
|
|
1744
|
-
const saved =
|
|
1839
|
+
const saved = session.needsRecycle()
|
|
1840
|
+
? null
|
|
1841
|
+
: await prolog.query("kb_save").catch(() => null);
|
|
1745
1842
|
if (saved?.success) {
|
|
1746
1843
|
try {
|
|
1747
1844
|
fsyncJournaledBranchStore(branchPath);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/extractors/manifest.ts"],"names":[],"mappings":"AA6BA,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,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B;AAED,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,eAAe,CAAC;IACxB,aAAa,EAAE,qBAAqB,EAAE,CAAC;IACvC,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;
|
|
1
|
+
{"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../src/extractors/manifest.ts"],"names":[],"mappings":"AA6BA,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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ALID_RELATIONSHIP_TYPES = new Set([
|
|
|
37
37
|
"publishes",
|
|
38
38
|
"consumes",
|
|
39
39
|
"supersedes",
|
|
40
|
+
"restates",
|
|
40
41
|
"relates_to",
|
|
41
42
|
]);
|
|
42
43
|
const VALID_RELATIONSHIP_DIRECTIONS = [
|
|
@@ -60,6 +61,7 @@ const VALID_RELATIONSHIP_DIRECTIONS = [
|
|
|
60
61
|
{ type: "consumes", from: "symbol", to: "event" },
|
|
61
62
|
{ type: "supersedes", from: "adr", to: "adr" },
|
|
62
63
|
{ type: "supersedes", from: "req", to: "req" },
|
|
64
|
+
{ type: "restates", from: "req", to: "req" },
|
|
63
65
|
];
|
|
64
66
|
const RELATIONSHIP_TYPE_DISPLAY_LIST = Array.from(VALID_RELATIONSHIP_TYPES)
|
|
65
67
|
.sort()
|
|
@@ -325,46 +327,82 @@ export function readManifestWithCoordinateOverlay(manifestPath, coordinatesPath)
|
|
|
325
327
|
});
|
|
326
328
|
}
|
|
327
329
|
/**
|
|
328
|
-
* Resolve the code scope of a receipt binding: for each
|
|
329
|
-
* its
|
|
330
|
-
* editing
|
|
331
|
-
* (per-contract binding mode).
|
|
330
|
+
* Resolve the code scope of a receipt binding: for each scoped symbol, the
|
|
331
|
+
* content hash of its current source file. A receipt's binding covers these,
|
|
332
|
+
* so editing code a test depends on stales only that test's receipts
|
|
333
|
+
* (per-contract binding mode). Hashes come from the live file, not the
|
|
334
|
+
* coordinate artifact: an edit must stale the receipt whether or not
|
|
335
|
+
* coordinates were refreshed. A scoped symbol whose file is gone hashes as
|
|
336
|
+
* "missing", so deleting it stales the receipt too; symbols without a
|
|
337
|
+
* source file cannot be hashed and are left out.
|
|
332
338
|
*/
|
|
333
339
|
// implements REQ-kibi-verification-evidence-contract
|
|
334
|
-
//
|
|
335
|
-
//
|
|
336
|
-
// manifest state
|
|
337
|
-
const
|
|
338
|
-
|
|
339
|
-
|
|
340
|
+
// Scope reads run once per proof-bearing test and a campaign touches
|
|
341
|
+
// dozens-to-hundreds of tests, so the manifest's symbol -> source mapping is
|
|
342
|
+
// memoized per manifest state and file hashes per file state (mtime + size).
|
|
343
|
+
const scopeSourceFileCache = new Map();
|
|
344
|
+
const scopeFileHashCache = new Map();
|
|
345
|
+
function fileStamp(filePath) {
|
|
340
346
|
try {
|
|
341
|
-
const stats = statSync(
|
|
342
|
-
|
|
347
|
+
const stats = statSync(filePath);
|
|
348
|
+
return `${stats.mtimeMs}:${stats.size}`;
|
|
343
349
|
}
|
|
344
350
|
catch {
|
|
345
|
-
|
|
351
|
+
return null;
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
function scopeSourceFiles(manifestPath) {
|
|
355
|
+
const stamp = fileStamp(manifestPath) ?? "missing";
|
|
356
|
+
const hit = scopeSourceFileCache.get(manifestPath);
|
|
357
|
+
if (hit && hit.stamp === stamp)
|
|
358
|
+
return hit.sourceFiles;
|
|
359
|
+
const sourceFiles = new Map();
|
|
360
|
+
if (stamp !== "missing") {
|
|
361
|
+
const records = extractManifestSymbolRecordsString(readFileSync(manifestPath, "utf8"), manifestPath);
|
|
362
|
+
for (const record of records) {
|
|
363
|
+
const sourceFile = typeof record.sourceFile === "string" && record.sourceFile !== ""
|
|
364
|
+
? record.sourceFile
|
|
365
|
+
: typeof record.source === "string" && record.source !== ""
|
|
366
|
+
? record.source
|
|
367
|
+
: undefined;
|
|
368
|
+
if (typeof record.id === "string" && sourceFile !== undefined) {
|
|
369
|
+
sourceFiles.set(record.id, sourceFile);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
346
372
|
}
|
|
347
|
-
|
|
373
|
+
scopeSourceFileCache.set(manifestPath, { stamp, sourceFiles });
|
|
374
|
+
return sourceFiles;
|
|
375
|
+
}
|
|
376
|
+
function scopeFileHash(absolutePath) {
|
|
377
|
+
const stamp = fileStamp(absolutePath);
|
|
378
|
+
if (stamp === null)
|
|
379
|
+
return "missing";
|
|
380
|
+
const hit = scopeFileHashCache.get(absolutePath);
|
|
348
381
|
if (hit && hit.stamp === stamp)
|
|
349
|
-
return hit.
|
|
350
|
-
const
|
|
351
|
-
|
|
352
|
-
|
|
382
|
+
return hit.hash;
|
|
383
|
+
const hash = createHash("sha256")
|
|
384
|
+
.update(readFileSync(absolutePath))
|
|
385
|
+
.digest("hex");
|
|
386
|
+
scopeFileHashCache.set(absolutePath, { stamp, hash });
|
|
387
|
+
return hash;
|
|
353
388
|
}
|
|
354
389
|
export function resolveBoundSymbolScope(manifestPath, symbolIds) {
|
|
355
|
-
const wanted = new Set(symbolIds);
|
|
356
|
-
if (wanted.
|
|
390
|
+
const wanted = [...new Set(symbolIds)];
|
|
391
|
+
if (wanted.length === 0)
|
|
357
392
|
return [];
|
|
358
|
-
const
|
|
393
|
+
const sourceFiles = scopeSourceFiles(manifestPath);
|
|
394
|
+
// The manifest lives at <workspace>/.kb/symbols.yaml; source files are
|
|
395
|
+
// workspace-relative.
|
|
396
|
+
const workspaceRoot = path.dirname(path.dirname(path.resolve(manifestPath)));
|
|
359
397
|
const scope = [];
|
|
360
|
-
for (const
|
|
361
|
-
const
|
|
362
|
-
if (
|
|
398
|
+
for (const symbolId of wanted) {
|
|
399
|
+
const sourceFile = sourceFiles.get(symbolId);
|
|
400
|
+
if (sourceFile === undefined)
|
|
363
401
|
continue;
|
|
364
|
-
const
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
}
|
|
402
|
+
const absolute = path.isAbsolute(sourceFile)
|
|
403
|
+
? sourceFile
|
|
404
|
+
: path.resolve(workspaceRoot, sourceFile);
|
|
405
|
+
scope.push({ symbolId, sourceHash: scopeFileHash(absolute) });
|
|
368
406
|
}
|
|
369
407
|
scope.sort((left, right) => left.symbolId.localeCompare(right.symbolId));
|
|
370
408
|
return scope;
|
|
@@ -61,6 +61,8 @@ export interface ExtractedEntity {
|
|
|
61
61
|
examples?: string[];
|
|
62
62
|
predicate_args?: string[];
|
|
63
63
|
rule_ir?: Record<string, unknown>;
|
|
64
|
+
argument_constants?: Record<string, string[]>;
|
|
65
|
+
argument_aliases?: Record<string, Record<string, string>>;
|
|
64
66
|
rule_hash?: string;
|
|
65
67
|
rule_schema_id?: string;
|
|
66
68
|
rule_name?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/extractors/markdown.ts"],"names":[],"mappings":"AAuBA,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,aAAa,EACnB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,KAAK,YAAY,EAElB,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"markdown.d.ts","sourceRoot":"","sources":["../../src/extractors/markdown.ts"],"names":[],"mappings":"AAuBA,OAAO,EAGL,KAAK,YAAY,EACjB,KAAK,aAAa,EACnB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,KAAK,YAAY,EAElB,MAAM,4BAA4B,CAAC;AAsEpC,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,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,0BAA0B,CAAC,EAAE,4BAA4B,CAAC;IAC1D,qBAAqB,CAAC,EAAE,eAAe,GAAG,UAAU,GAAG,OAAO,CAAC;IAC/D,oBAAoB,CAAC,EAAE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hash",
|
|
46
48
|
"rule_schema_id",
|
|
47
49
|
"rule_name",
|
|
@@ -77,7 +79,13 @@ const TEST_ENUM_FIELDS = [
|
|
|
77
79
|
"proof_receipts",
|
|
78
80
|
];
|
|
79
81
|
const ajv = new Ajv({ strict: false, allErrors: true });
|
|
80
|
-
|
|
82
|
+
// Compiled on first extraction: every CLI command imports this module, and
|
|
83
|
+
// most never extract Markdown entities.
|
|
84
|
+
let extractedEntityValidator;
|
|
85
|
+
function validateExtractedEntity() {
|
|
86
|
+
extractedEntityValidator ??= ajv.compile(entitySchema);
|
|
87
|
+
return extractedEntityValidator;
|
|
88
|
+
}
|
|
81
89
|
const DEFAULT_STATUS_BY_TYPE = {
|
|
82
90
|
req: "open",
|
|
83
91
|
scenario: "draft",
|
|
@@ -105,6 +113,7 @@ const VALID_RELATIONSHIP_TYPES = new Set([
|
|
|
105
113
|
"publishes",
|
|
106
114
|
"consumes",
|
|
107
115
|
"supersedes",
|
|
116
|
+
"restates",
|
|
108
117
|
"relates_to",
|
|
109
118
|
]);
|
|
110
119
|
const VALID_RELATIONSHIP_DIRECTIONS = [
|
|
@@ -129,6 +138,7 @@ const VALID_RELATIONSHIP_DIRECTIONS = [
|
|
|
129
138
|
{ type: "consumes", from: "symbol", to: "event" },
|
|
130
139
|
{ type: "supersedes", from: "adr", to: "adr" },
|
|
131
140
|
{ type: "supersedes", from: "req", to: "req" },
|
|
141
|
+
{ type: "restates", from: "req", to: "req" },
|
|
132
142
|
];
|
|
133
143
|
const RELATIONSHIP_TYPE_DISPLAY_LIST = Array.from(VALID_RELATIONSHIP_TYPES)
|
|
134
144
|
.sort()
|
|
@@ -577,8 +587,9 @@ function extractFromMarkdownContent(content, filePath) {
|
|
|
577
587
|
if (type === "req" && Array.isArray(data.semantic_inventory)) {
|
|
578
588
|
entity.semantic_inventory = data.semantic_inventory.filter((value) => isObjectRecord(value));
|
|
579
589
|
}
|
|
580
|
-
|
|
581
|
-
|
|
590
|
+
const validateEntity = validateExtractedEntity();
|
|
591
|
+
if (!validateEntity(entity)) {
|
|
592
|
+
const messages = (validateEntity.errors || [])
|
|
582
593
|
.map((e) => `${e.instancePath || "root"}: ${e.message}`)
|
|
583
594
|
.join("; ");
|
|
584
595
|
throw new FrontmatterError(`Entity validation failed: ${messages}`, filePath, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relationships.d.ts","sourceRoot":"","sources":["../../src/extractors/relationships.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,KAAK,kBAAkB,EAAa,MAAM,4BAA4B,CAAC;AAEhF,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,CAAC,EAAE;QACT,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AAED,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,qBAAqB,EAAE,CAAC;CACxC;
|
|
1
|
+
{"version":3,"file":"relationships.d.ts","sourceRoot":"","sources":["../../src/extractors/relationships.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,KAAK,kBAAkB,EAAa,MAAM,4BAA4B,CAAC;AAEhF,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,CAAC,EAAE;QACT,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,UAAU,CAAC,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AAED,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,aAAa,EAAE,qBAAqB,EAAE,CAAC;CACxC;AA0BD;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAC3C,gBAAgB,EAAE,MAAM,GACvB,qBAAqB,EAAE,CAmBzB;AAED,gFAAgF;AAChF,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,MAAM,GAChB,qBAAqB,CAiBvB;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,MAAM,EAAE,kBAAkB,GACzB,qBAAqB,GAAG,IAAI,CAyC9B;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,qBAAqB,EAAE,GAC/B,qBAAqB,EAAE,CAEzB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,qBAAqB,EAAE,EACtC,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,GAC1B,KAAK,CAAC;IACP,YAAY,EAAE,qBAAqB,CAAC;IACpC,KAAK,EAAE,cAAc,GAAG,YAAY,CAAC;CACtC,CAAC,CAgBD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intent-search.d.ts","sourceRoot":"","sources":["../src/intent-search.ts"],"names":[],"mappings":"AAGA,OAAO,
|
|
1
|
+
{"version":3,"file":"intent-search.d.ts","sourceRoot":"","sources":["../src/intent-search.ts"],"names":[],"mappings":"AAGA,OAAO,EAEL,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,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