kibi-cli 2.39.0 → 2.40.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-register-foundation.js +2 -2
- package/dist/commands/check.d.ts.map +1 -1
- package/dist/commands/check.js +33 -9
- package/dist/commands/doctor.d.ts.map +1 -1
- package/dist/commands/doctor.js +15 -0
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +4 -0
- package/dist/commands/migrate-plan-record.d.ts +18 -0
- package/dist/commands/migrate-plan-record.d.ts.map +1 -0
- package/dist/commands/migrate-plan-record.js +112 -0
- package/dist/commands/migrate.d.ts +11 -2
- package/dist/commands/migrate.d.ts.map +1 -1
- package/dist/commands/migrate.js +53 -7
- package/dist/commands/prove.d.ts.map +1 -1
- package/dist/commands/prove.js +18 -3
- package/dist/commands/sync/manifest.d.ts.map +1 -1
- package/dist/commands/sync/manifest.js +17 -4
- package/dist/commands/sync.d.ts.map +1 -1
- package/dist/commands/sync.js +8 -0
- package/dist/commands/telemetry.d.ts.map +1 -1
- package/dist/commands/telemetry.js +12 -2
- package/dist/extractors/symbol-title-match.d.ts +31 -0
- package/dist/extractors/symbol-title-match.d.ts.map +1 -0
- package/dist/extractors/symbol-title-match.js +133 -0
- package/dist/extractors/symbols-coordinator.d.ts.map +1 -1
- package/dist/extractors/symbols-coordinator.js +81 -12
- package/dist/operations/bootstrap/discovery-evidence.js +2 -2
- package/dist/operations/bootstrap/guidance-actions.d.ts.map +1 -1
- package/dist/operations/bootstrap/guidance-actions.js +12 -1
- package/dist/operations/bootstrap/plugin-offers.d.ts +7 -1
- package/dist/operations/bootstrap/plugin-offers.d.ts.map +1 -1
- package/dist/operations/bootstrap/plugin-offers.js +73 -3
- package/dist/operations/modeling/logic-modeling.d.ts.map +1 -1
- package/dist/operations/modeling/logic-modeling.js +2 -1
- package/dist/operations/modeling/model-requirement.d.ts.map +1 -1
- package/dist/operations/modeling/model-requirement.js +2 -1
- package/dist/operations/mutation/symbol-refresh.d.ts +2 -0
- package/dist/operations/mutation/symbol-refresh.d.ts.map +1 -1
- package/dist/operations/mutation/symbol-refresh.js +6 -1
- package/dist/operations/mutation/upsert.d.ts.map +1 -1
- package/dist/operations/mutation/upsert.js +7 -0
- package/dist/operations/planning/compile-intent.d.ts.map +1 -1
- package/dist/operations/planning/compile-intent.js +2 -1
- package/dist/operations/proof/claim-bindings.d.ts +11 -0
- package/dist/operations/proof/claim-bindings.d.ts.map +1 -1
- package/dist/operations/proof/claim-bindings.js +144 -1
- package/dist/operations/proof/code-certificates.d.ts +10 -3
- package/dist/operations/proof/code-certificates.d.ts.map +1 -1
- package/dist/operations/proof/code-certificates.js +65 -13
- package/dist/operations/proof/code-languages.d.ts +104 -0
- package/dist/operations/proof/code-languages.d.ts.map +1 -0
- package/dist/operations/proof/code-languages.js +119 -0
- package/dist/operations/proof/code-models.d.ts +2 -0
- package/dist/operations/proof/code-models.d.ts.map +1 -1
- package/dist/operations/proof/code-models.js +11 -5
- package/dist/operations/proof/code-runner.d.ts +12 -9
- package/dist/operations/proof/code-runner.d.ts.map +1 -1
- package/dist/operations/proof/code-runner.js +81 -38
- package/dist/operations/proof/code-scope.d.ts +8 -0
- package/dist/operations/proof/code-scope.d.ts.map +1 -1
- package/dist/operations/proof/code-scope.js +30 -1
- package/dist/operations/proof/explain.d.ts +13 -0
- package/dist/operations/proof/explain.d.ts.map +1 -1
- package/dist/operations/proof/explain.js +66 -0
- package/dist/operations/proof/ingest-proof.d.ts +2 -0
- package/dist/operations/proof/ingest-proof.d.ts.map +1 -1
- package/dist/operations/proof/ingest-proof.js +1 -0
- package/dist/operations/proof/java-package-shadow.d.ts +14 -0
- package/dist/operations/proof/java-package-shadow.d.ts.map +1 -0
- package/dist/operations/proof/java-package-shadow.js +389 -0
- package/dist/operations/proof/prolog-evaluator.d.ts +14 -0
- package/dist/operations/proof/prolog-evaluator.d.ts.map +1 -0
- package/dist/operations/proof/prolog-evaluator.js +247 -0
- package/dist/operations/proof/prolog-source-reader.d.ts +20 -0
- package/dist/operations/proof/prolog-source-reader.d.ts.map +1 -0
- package/dist/operations/proof/prolog-source-reader.js +1123 -0
- package/dist/operations/proof/source-code-readers.d.ts +6 -0
- package/dist/operations/proof/source-code-readers.d.ts.map +1 -1
- package/dist/operations/proof/source-code-readers.js +879 -75
- package/dist/plugins/approved-source-analyzers.generated.d.ts +13 -35
- package/dist/plugins/approved-source-analyzers.generated.d.ts.map +1 -1
- package/dist/plugins/approved-source-analyzers.generated.js +13 -35
- package/dist/plugins/plugin-install-check.d.ts +21 -0
- package/dist/plugins/plugin-install-check.d.ts.map +1 -0
- package/dist/plugins/plugin-install-check.js +62 -0
- package/dist/plugins/proof-reference-extractors.d.ts +20 -0
- package/dist/plugins/proof-reference-extractors.d.ts.map +1 -0
- package/dist/plugins/proof-reference-extractors.js +104 -0
- package/dist/plugins/reference-language-suggestion.d.ts +51 -0
- package/dist/plugins/reference-language-suggestion.d.ts.map +1 -0
- package/dist/plugins/reference-language-suggestion.js +277 -0
- package/dist/plugins/registry.d.ts.map +1 -1
- package/dist/plugins/registry.js +3 -1
- package/dist/plugins/source-analysis-service.d.ts.map +1 -1
- package/dist/plugins/source-analysis-service.js +4 -0
- package/dist/plugins/source-change-analysis.d.ts +26 -1
- package/dist/plugins/source-change-analysis.d.ts.map +1 -1
- package/dist/plugins/source-change-analysis.js +77 -5
- package/dist/plugins/source-classification.d.ts.map +1 -1
- package/dist/plugins/source-classification.js +23 -3
- package/dist/public/operations/catalog.d.ts +32 -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 +3 -0
- package/dist/public/operations/evidence-floor.d.ts +8 -0
- package/dist/public/operations/evidence-floor.d.ts.map +1 -1
- package/dist/public/operations/evidence-floor.js +19 -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 +2 -1
- package/dist/public/operations/specs/check.d.ts +1 -1
- package/dist/public/operations/specs/mutation-schemas.d.ts +31 -6
- package/dist/public/operations/specs/mutation-schemas.d.ts.map +1 -1
- 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 +26 -3
- package/dist/public/operations/specs/semantic.d.ts.map +1 -1
- package/dist/public/operations/specs/semantic.js +2 -1
- package/dist/public/operations/specs/upsert.d.ts +31 -6
- package/dist/public/operations/specs/upsert.d.ts.map +1 -1
- package/dist/public/operations/symbol-coordinates-check.d.ts +11 -0
- package/dist/public/operations/symbol-coordinates-check.d.ts.map +1 -0
- package/dist/public/operations/symbol-coordinates-check.js +66 -0
- package/dist/public/proof-protocol.d.ts +31 -6
- package/dist/public/proof-protocol.d.ts.map +1 -1
- package/dist/public/proof-protocol.js +45 -15
- package/dist/public/proof-sources.d.ts +4 -2
- package/dist/public/proof-sources.d.ts.map +1 -1
- package/dist/public/proof-sources.js +43 -4
- package/dist/public/skills/kibi-usage/SKILL.md +6 -3
- package/dist/public/skills/kibi-usage/resources/prolog-proofs.md +207 -0
- package/dist/public/skills/kibi-usage/resources/proof.md +44 -3
- package/dist/schemas/entity.schema.json +34 -6
- package/dist/traceability/analysis-gate.d.ts +3 -1
- package/dist/traceability/analysis-gate.d.ts.map +1 -1
- package/dist/traceability/analysis-gate.js +9 -1
- package/dist/traceability/staged-file-coverage.d.ts.map +1 -1
- package/dist/traceability/staged-file-coverage.js +7 -2
- package/dist/traceability/symbol-extract.d.ts +17 -0
- package/dist/traceability/symbol-extract.d.ts.map +1 -1
- package/dist/traceability/symbol-extract.js +69 -15
- package/dist/traceability/validate.d.ts.map +1 -1
- package/dist/traceability/validate.js +5 -7
- package/dist/utils/first-sentence.d.ts +9 -0
- package/dist/utils/first-sentence.d.ts.map +1 -0
- package/dist/utils/first-sentence.js +52 -0
- package/dist/utils/rule-registry.generated.d.ts +6 -0
- package/dist/utils/rule-registry.generated.d.ts.map +1 -1
- package/dist/utils/rule-registry.generated.js +7 -0
- package/package.json +5 -5
- package/src/public/operations/check-executor.ts +8 -0
- package/src/public/operations/evidence-floor.ts +29 -1
- package/src/public/operations/specs/check-rules.generated.ts +2 -1
- package/src/public/operations/specs/reporting.ts +38 -3
- package/src/public/operations/specs/semantic.ts +2 -1
- package/src/public/operations/symbol-coordinates-check.ts +79 -0
- package/src/public/proof-protocol-types.d.ts +22 -5
- package/src/public/proof-protocol.ts +78 -19
- package/src/public/proof-sources.ts +51 -3
- package/src/public/skills/kibi-usage/SKILL.md +6 -3
- package/src/public/skills/kibi-usage/resources/prolog-proofs.md +207 -0
- package/src/public/skills/kibi-usage/resources/proof.md +44 -3
- package/src/schemas/entity.schema.json +34 -6
|
@@ -148,6 +148,7 @@ export function projectRequirementExplain(proof) {
|
|
|
148
148
|
}),
|
|
149
149
|
}
|
|
150
150
|
: {}),
|
|
151
|
+
...refutationFields(proof, stages),
|
|
151
152
|
...claimFields(proof),
|
|
152
153
|
scenarios,
|
|
153
154
|
...negativePathField(stages.negativePath),
|
|
@@ -314,6 +315,51 @@ function renderNegativePath(view) {
|
|
|
314
315
|
}
|
|
315
316
|
return lines;
|
|
316
317
|
}
|
|
318
|
+
// implements REQ-kibi-claim-bound-proofs
|
|
319
|
+
function refutationFields(proof, stages) {
|
|
320
|
+
const refutations = Array.isArray(proof.claimBindingRejections)
|
|
321
|
+
? proof.claimBindingRejections.map((row) => {
|
|
322
|
+
const entry = asRecord(row);
|
|
323
|
+
return {
|
|
324
|
+
test: asString(entry.test),
|
|
325
|
+
claimKey: asString(entry.claimKey),
|
|
326
|
+
reason: asString(entry.reason),
|
|
327
|
+
};
|
|
328
|
+
})
|
|
329
|
+
: [];
|
|
330
|
+
const missing = asStringArray(asRecord(stages.sourceCoordinates).missingSymbols);
|
|
331
|
+
return {
|
|
332
|
+
...(refutations.length > 0 ? { refutations } : {}),
|
|
333
|
+
...(missing.length > 0 ? { missingCoordinateSymbols: missing } : {}),
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
/** Why each gap keeps a requirement from being tested end to end. */
|
|
337
|
+
const GAP_REASONS = {
|
|
338
|
+
missing_passing_e2e: "no scenario-backed test has a passing end-to-end receipt (a test whose verification_scope is not end_to_end does not count)",
|
|
339
|
+
missing_proof_receipt: "a scenario-backed test has no proof receipt yet",
|
|
340
|
+
stale_proof_receipt: "a proof receipt is older than the current code",
|
|
341
|
+
failed_proof_receipt: "a proof receipt records a failed run",
|
|
342
|
+
invalid_proof_receipt: "a proof receipt cannot be checked",
|
|
343
|
+
proof_contract_mismatch: "a proof receipt was recorded for an older proof contract",
|
|
344
|
+
missing_production_symbol: "no production symbol implements the requirement",
|
|
345
|
+
missing_production_symbol_coverage: "a production symbol is not covered by a qualifying end-to-end test (a test whose verification_scope is not end_to_end does not qualify)",
|
|
346
|
+
missing_executable_test_symbol: "a scenario test has no test code linked executable_for",
|
|
347
|
+
missing_scenario: "the requirement has no scenario",
|
|
348
|
+
missing_scenario_test: "a scenario has no test",
|
|
349
|
+
happy_path_only: "no scenario exercises the failure side",
|
|
350
|
+
uncovered_case: "an edge case of the claim has no scenario",
|
|
351
|
+
};
|
|
352
|
+
/** One plain clause per gap, naming what it is about where Kibi knows. */
|
|
353
|
+
// implements REQ-kibi-claim-bound-proofs
|
|
354
|
+
export function gapReason(gap, view) {
|
|
355
|
+
if (gap === "missing_symbol_coordinates") {
|
|
356
|
+
const symbols = view.missingCoordinateSymbols ?? [];
|
|
357
|
+
const named = symbols.length > 0 ? `${symbols.slice(0, 3).join(", ")} ` : "a symbol ";
|
|
358
|
+
return `${gap}: ${named}${symbols.length > 1 ? "have" : "has"} no source coordinates, so Kibi cannot tie the proof to its code (kibi sync --refresh-symbol-coordinates places ${symbols.length > 1 ? "them" : "it"}; kibi check says why a symbol cannot be placed)`;
|
|
359
|
+
}
|
|
360
|
+
const reason = GAP_REASONS[gap];
|
|
361
|
+
return reason ? `${gap}: ${reason}` : gap;
|
|
362
|
+
}
|
|
317
363
|
function claimFields(proof) {
|
|
318
364
|
const summary = asRecord(proof.claimSummary);
|
|
319
365
|
const count = (key) => typeof summary[key] === "number" ? summary[key] : 0;
|
|
@@ -344,6 +390,9 @@ function claimFields(proof) {
|
|
|
344
390
|
...(typeof entry.blocker === "string"
|
|
345
391
|
? { blocker: entry.blocker }
|
|
346
392
|
: {}),
|
|
393
|
+
...(typeof entry.notProved === "string"
|
|
394
|
+
? { notProved: entry.notProved }
|
|
395
|
+
: {}),
|
|
347
396
|
bindings: (Array.isArray(entry.bindings)
|
|
348
397
|
? entry.bindings
|
|
349
398
|
: []).map((raw) => {
|
|
@@ -364,6 +413,19 @@ function claimFields(proof) {
|
|
|
364
413
|
: {}),
|
|
365
414
|
};
|
|
366
415
|
}
|
|
416
|
+
/** Gaps a refuted claim leaves that a derived proof would have covered. */
|
|
417
|
+
const CERTIFIED_GAPS = new Set(["happy_path_only", "uncovered_case"]);
|
|
418
|
+
// implements REQ-kibi-claim-bound-proofs
|
|
419
|
+
function renderRefutations(view) {
|
|
420
|
+
const refutations = view.refutations ?? [];
|
|
421
|
+
if (refutations.length === 0)
|
|
422
|
+
return [];
|
|
423
|
+
const lines = refutations.map((row) => `refuted: ${row.test} refutes ${row.claimKey}: ${row.reason}. The code breaks the claim, so it is not proved; fix the code (or, with the person who owns the rule, the requirement) and run kibi prove`);
|
|
424
|
+
const covered = view.proofGaps.filter((gap) => CERTIFIED_GAPS.has(gap));
|
|
425
|
+
if (covered.length > 0)
|
|
426
|
+
lines.push(` ${covered.join(" and ")} ${covered.length > 1 ? "follow" : "follows"} from the refutation: a proof that derives the claim covers its failure side and edge cases, a refuted one covers none`);
|
|
427
|
+
return lines;
|
|
428
|
+
}
|
|
367
429
|
function renderClaims(view) {
|
|
368
430
|
if (view.claims === undefined)
|
|
369
431
|
return [];
|
|
@@ -382,6 +444,9 @@ function renderClaims(view) {
|
|
|
382
444
|
: ` ${claim.claimKey} not applicable (${claim.status})`);
|
|
383
445
|
for (const binding of claim.bindings)
|
|
384
446
|
lines.push(` ${binding.test} ${binding.kind}: ${binding.binding}${binding.binding === "derived" ? ` (${binding.scope})` : ""}${binding.reason ? `: ${binding.reason}` : ""}`);
|
|
447
|
+
// implements REQ-kibi-claim-bound-proofs
|
|
448
|
+
if (claim.notProved === "requirement_not_tested")
|
|
449
|
+
lines.push(` not proved: the certificate derives the claim, but a claim is proved only once the requirement is tested end to end, and it is not (proofStatus ${view.proofStatus})${view.proofGaps.length > 0 ? `: ${view.proofGaps.map((gap) => gapReason(gap, view)).join("; ")}` : ""}`);
|
|
385
450
|
}
|
|
386
451
|
return lines;
|
|
387
452
|
}
|
|
@@ -417,6 +482,7 @@ function renderRequirementExplain(view) {
|
|
|
417
482
|
? []
|
|
418
483
|
: [`evidenceLevel: ${view.evidenceLevel}`]),
|
|
419
484
|
...(view.certificateRejections ?? []).map((row) => `certificate rejected for ${row.test}: ${row.reason}`),
|
|
485
|
+
...renderRefutations(view),
|
|
420
486
|
...renderClaims(view),
|
|
421
487
|
"",
|
|
422
488
|
"Scenarios",
|
|
@@ -24,6 +24,8 @@ export type IngestProofTestResult = Readonly<{
|
|
|
24
24
|
evidenceLevel?: string;
|
|
25
25
|
/** Why the test's certificate did not re-check, for a certificate kind. */
|
|
26
26
|
certificateRejection?: string;
|
|
27
|
+
/** The receipt's verification scope (unit, integration or end_to_end). */
|
|
28
|
+
scope?: string;
|
|
27
29
|
}>;
|
|
28
30
|
export type IngestProofResult = Readonly<{
|
|
29
31
|
artifactDigest: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ingest-proof.d.ts","sourceRoot":"","sources":["../../../src/operations/proof/ingest-proof.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,KAAK,QAAQ,EAEd,MAAM,yBAAyB,CAAC;AAOjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAkBjF,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,YAAY,EAGlB,MAAM,+BAA+B,CAAC;AAoBvC,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC5C,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC7B,CAAC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,QAAQ,CAAC;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,0EAA0E;IAC1E,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,SAAS,QAAQ,EAAE,CAAC;IAC1B,4EAA4E;IAC5E,aAAa,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;IACxC,oEAAoE;IACpE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,2EAA2E;IAC3E,oBAAoB,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"ingest-proof.d.ts","sourceRoot":"","sources":["../../../src/operations/proof/ingest-proof.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,KAAK,QAAQ,EAEd,MAAM,yBAAyB,CAAC;AAOjC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAkBjF,OAAO,EAEL,KAAK,YAAY,EACjB,KAAK,YAAY,EAGlB,MAAM,+BAA+B,CAAC;AAoBvC,MAAM,MAAM,eAAe,GAAG,QAAQ,CAAC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;IAC5C,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC7B,CAAC,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,QAAQ,CAAC;IAC3C,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,YAAY,CAAC,SAAS,CAAC,CAAC;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,0EAA0E;IAC1E,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,SAAS,QAAQ,EAAE,CAAC;IAC1B,4EAA4E;IAC5E,aAAa,CAAC,EAAE,SAAS,YAAY,EAAE,CAAC;IACxC,oEAAoE;IACpE,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iEAAiE;IACjE,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,2EAA2E;IAC3E,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,0EAA0E;IAC1E,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC,CAAC;AAGH,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IACvC,cAAc,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,SAAS,qBAAqB,EAAE,CAAC;CAC3C,CAAC,CAAC;AAEH,KAAK,iBAAiB,GAAG;IACvB,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,iBAAiB,EAAE,iBAAiB,CAAC;CACtC,CAAC;AA+nBF,wBAAsB,kBAAkB,CACtC,IAAI,EAAE,eAAe,EACrB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,iBAAiB,CAAC,CAuC5B"}
|
|
@@ -328,6 +328,7 @@ async function executeIngestProofUnlocked(args, context, lifecycle) {
|
|
|
328
328
|
...(typeof entry.receipt.certificate_rejection === "string"
|
|
329
329
|
? { certificateRejection: entry.receipt.certificate_rejection }
|
|
330
330
|
: {}),
|
|
331
|
+
scope: entry.receipt.scope,
|
|
331
332
|
},
|
|
332
333
|
]));
|
|
333
334
|
const pendingCommits = [];
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
interface Row {
|
|
2
|
+
readonly line: number;
|
|
3
|
+
readonly text: string;
|
|
4
|
+
}
|
|
5
|
+
/** Java source with comments, string, char and text-block contents removed. */
|
|
6
|
+
export declare function javaCode(text: string): string;
|
|
7
|
+
/**
|
|
8
|
+
* A filter for one read: keeps every row, except a marked row whose
|
|
9
|
+
* declaration the project's files rule out. Directory scans are shared by
|
|
10
|
+
* the files of the read.
|
|
11
|
+
*/
|
|
12
|
+
export declare function createShadowRowFilter(workspaceRoot: string): (file: string, rows: readonly Row[]) => Row[];
|
|
13
|
+
export {};
|
|
14
|
+
//# sourceMappingURL=java-package-shadow.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"java-package-shadow.d.ts","sourceRoot":"","sources":["../../../src/operations/proof/java-package-shadow.ts"],"names":[],"mappings":"AAoDA,UAAU,GAAG;IACX,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;CACvB;AAgBD,+EAA+E;AAC/E,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CA8B7C;AAmND;;;;GAIG;AACH,wBAAgB,qBAAqB,CAAC,aAAa,EAAE,MAAM,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,GAAG,EAAE,KAAK,GAAG,EAAE,CAgG1G"}
|
|
@@ -0,0 +1,389 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Kibi — repo-local, per-branch, queryable long-term memory for software projects
|
|
3
|
+
Copyright (C) 2026 Piotr Franczyk
|
|
4
|
+
|
|
5
|
+
This program is free software: you can redistribute it and/or modify
|
|
6
|
+
it under the terms of the GNU Affero General Public License as published by
|
|
7
|
+
the Free Software Foundation, either version 3 of the License, or
|
|
8
|
+
(at your option) any later version.
|
|
9
|
+
|
|
10
|
+
This program is distributed in the hope that it will be useful,
|
|
11
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
12
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
13
|
+
GNU Affero General Public License for more details.
|
|
14
|
+
|
|
15
|
+
You should have received a copy of the GNU Affero General Public License
|
|
16
|
+
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
18
|
+
/**
|
|
19
|
+
* Names another file of the project may bind instead of the standard one.
|
|
20
|
+
* The tree-sitter reference reader reads one file at a time, so it marks:
|
|
21
|
+
*
|
|
22
|
+
* - a bare Java `System` or `Runtime` ("System may be a class of package
|
|
23
|
+
* p: ..."): a top-level type of that name in another file of the package
|
|
24
|
+
* would be used instead of java.lang's;
|
|
25
|
+
* - a bare Rust standard macro ("println may be a macro_rules! macro of the
|
|
26
|
+
* crate: ..."): a `macro_rules! println` elsewhere in the crate, in
|
|
27
|
+
* textual scope through `#[macro_use]`, would be expanded instead;
|
|
28
|
+
* - a C# System type spelled bare ("Environment may be a type of the
|
|
29
|
+
* project: ..."): a type of that name in the file's namespace, an
|
|
30
|
+
* enclosing one or the global namespace, declared in any file of the
|
|
31
|
+
* project, or a `global using` alias of that name, would bind instead of
|
|
32
|
+
* System's;
|
|
33
|
+
* - a Go name the file uses but does not declare ("getenv may be declared in
|
|
34
|
+
* another file of the package: ..."), for env: another file of the package
|
|
35
|
+
* may hold a getter or a wrapper of one;
|
|
36
|
+
* - a Go name the file calls but does not declare ("command may be a
|
|
37
|
+
* function of another file of the package: ..."), for calls: another file
|
|
38
|
+
* of the package may bind it to a function value (`var command =
|
|
39
|
+
* exec.Command`), so the call is that function's;
|
|
40
|
+
* - a Go import ("config may be a package of the project: ..."), for env: a
|
|
41
|
+
* package of the project may wrap a getter (`config.Get("X")`, `var Get =
|
|
42
|
+
* os.Getenv`) or read the environment at init.
|
|
43
|
+
*
|
|
44
|
+
* The host drops such a row only after it has looked at those files and
|
|
45
|
+
* found no such declaration. When it finds one, or cannot read the files,
|
|
46
|
+
* the row stays and the read is refused.
|
|
47
|
+
*/
|
|
48
|
+
import { readdirSync, readFileSync, statSync } from "node:fs";
|
|
49
|
+
import path from "node:path";
|
|
50
|
+
const JAVA_ROW = /^(System|Runtime) may be a class of (?:package ([\w.]+)|the default package): /;
|
|
51
|
+
const RUST_ROW = /^(\w+) may be a macro_rules! macro of the crate: /;
|
|
52
|
+
const CSHARP_ROW = /^(\w+) may be a type of the project: /;
|
|
53
|
+
const GO_ROW = /^(\w+) may be declared in another file of the package: /;
|
|
54
|
+
const GO_IMPORT_ROW = /^\S+ may be a package of the project: /;
|
|
55
|
+
const GO_CALL_ROW = /^(\w+) may be a function of another file of the package: /;
|
|
56
|
+
/**
|
|
57
|
+
* What in Go source may read the environment: a getter of os, syscall or
|
|
58
|
+
* x/sys (also as a value, or through an alias or a dot import), cgo, and a
|
|
59
|
+
* `//go:linkname`, which binds a local name to any function.
|
|
60
|
+
*/
|
|
61
|
+
const GO_ENV_SOURCE = /\b(?:Getenv|LookupEnv|Environ|ExpandEnv|Expand)\b|"C"|go:linkname/;
|
|
62
|
+
/** Java source with comments, string, char and text-block contents removed. */
|
|
63
|
+
export function javaCode(text) {
|
|
64
|
+
let out = "";
|
|
65
|
+
let index = 0;
|
|
66
|
+
while (index < text.length) {
|
|
67
|
+
const rest = text.slice(index, index + 3);
|
|
68
|
+
if (rest.startsWith("//")) {
|
|
69
|
+
const end = text.indexOf("\n", index);
|
|
70
|
+
index = end === -1 ? text.length : end;
|
|
71
|
+
out += " ";
|
|
72
|
+
}
|
|
73
|
+
else if (rest.startsWith("/*")) {
|
|
74
|
+
const end = text.indexOf("*/", index + 2);
|
|
75
|
+
index = end === -1 ? text.length : end + 2;
|
|
76
|
+
out += " ";
|
|
77
|
+
}
|
|
78
|
+
else if (rest === '"""') {
|
|
79
|
+
const end = text.indexOf('"""', index + 3);
|
|
80
|
+
index = end === -1 ? text.length : end + 3;
|
|
81
|
+
out += '""';
|
|
82
|
+
}
|
|
83
|
+
else if (rest[0] === '"' || rest[0] === "'") {
|
|
84
|
+
const quote = rest[0];
|
|
85
|
+
index += 1;
|
|
86
|
+
while (index < text.length && text[index] !== quote && text[index] !== "\n")
|
|
87
|
+
index += text[index] === "\\" ? 2 : 1;
|
|
88
|
+
index += 1;
|
|
89
|
+
out += `${quote}${quote}`;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
out += text[index];
|
|
93
|
+
index += 1;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return out;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Java source with its Unicode escapes decoded (`q` is `q`), as the
|
|
100
|
+
* compiler reads it before anything else; a backslash escaped by another
|
|
101
|
+
* starts no escape.
|
|
102
|
+
*/
|
|
103
|
+
function javaUnicode(text) {
|
|
104
|
+
return text.replace(/(\\+)u+([0-9a-fA-F]{4})/g, (escape, slashes, hex) => slashes.length % 2 === 1 ? `${slashes.slice(1)}${String.fromCharCode(Number.parseInt(hex, 16))}` : escape);
|
|
105
|
+
}
|
|
106
|
+
/** The package a Java file declares, "" for the default package. */
|
|
107
|
+
function javaPackage(text) {
|
|
108
|
+
const declared = /\bpackage\s+([\w$.\s]+?)\s*;/.exec(javaCode(javaUnicode(text)));
|
|
109
|
+
return declared === null ? "" : declared[1].replace(/\s+/g, "");
|
|
110
|
+
}
|
|
111
|
+
/** Whether Java source declares a type of that name (any nesting). */
|
|
112
|
+
function javaDeclares(text, name) {
|
|
113
|
+
// A Unicode escape may spell any identifier: the file is not ruled out.
|
|
114
|
+
if (text.includes("\\u"))
|
|
115
|
+
return true;
|
|
116
|
+
return new RegExp(`(?:^|[^\\w$.])(?:class|interface|enum|record)\\s+${name}(?![\\w$])`).test(javaCode(text));
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Source files with an extension under a directory, skipping dot folders,
|
|
120
|
+
* node_modules and the named build folders.
|
|
121
|
+
*/
|
|
122
|
+
function sourceFiles(directory, extension, skipped = []) {
|
|
123
|
+
const files = [];
|
|
124
|
+
for (const entry of readdirSync(directory, { withFileTypes: true })) {
|
|
125
|
+
if (entry.name.startsWith(".") || entry.name === "node_modules" || skipped.includes(entry.name))
|
|
126
|
+
continue;
|
|
127
|
+
const full = path.join(directory, entry.name);
|
|
128
|
+
if (entry.isDirectory())
|
|
129
|
+
files.push(...sourceFiles(full, extension, skipped));
|
|
130
|
+
else if (entry.name.endsWith(extension))
|
|
131
|
+
files.push(full);
|
|
132
|
+
}
|
|
133
|
+
return files;
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Whether C# source may declare a type, namespace or `global using` alias of
|
|
137
|
+
* that name. Comments and strings are not stripped (a mention there keeps
|
|
138
|
+
* the row too), and an identifier spelled with a Unicode escape may be any
|
|
139
|
+
* name.
|
|
140
|
+
*/
|
|
141
|
+
function csharpDeclares(text, name) {
|
|
142
|
+
const id = `@?${name}(?![\\w\\\\])`;
|
|
143
|
+
return (new RegExp(`\\b(?:class|struct|interface|enum|record)\\s+(?:(?:class|struct)\\s+)?${id}`).test(text) ||
|
|
144
|
+
new RegExp(`\\bdelegate\\s+[^;{}()]*?[\\s>\\]?]${id}\\s*[<(]`).test(text) ||
|
|
145
|
+
new RegExp(`\\bnamespace\\s+(?:[\\w@]+\\s*\\.\\s*)*${id}`).test(text) ||
|
|
146
|
+
new RegExp(`\\bglobal\\s+using\\s+${id}\\s*=`).test(text) ||
|
|
147
|
+
/\b(?:class|struct|interface|enum|record|delegate)\b[^;{}]*?\\[uU]/.test(text));
|
|
148
|
+
}
|
|
149
|
+
/** Go string literals, interpreted and raw: every import path a file may spell. */
|
|
150
|
+
function goStrings(text) {
|
|
151
|
+
return [...text.matchAll(/"((?:[^"\\\n]|\\.)*)"|`([^`]*)`/g)].map((match) => match[1] ?? match[2] ?? "");
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* The project's Go modules: each go.mod's module path at its folder (which
|
|
155
|
+
* covers the modules of a go.work), and each replace with a local folder.
|
|
156
|
+
*/
|
|
157
|
+
function goModules(workspaceRoot) {
|
|
158
|
+
const modules = [];
|
|
159
|
+
for (const file of sourceFiles(workspaceRoot, "go.mod", ["vendor"])) {
|
|
160
|
+
if (path.basename(file) !== "go.mod")
|
|
161
|
+
continue;
|
|
162
|
+
const dir = path.dirname(file);
|
|
163
|
+
const text = readFileSync(file, "utf8").replace(/\/\/[^\n]*/g, "");
|
|
164
|
+
const name = /^\s*module\s+"?([^\s"]+)"?/m.exec(text);
|
|
165
|
+
if (name !== null)
|
|
166
|
+
modules.push({ path: name[1], dir });
|
|
167
|
+
// `replace a v1 => ../a`, alone or in a `replace ( ... )` block.
|
|
168
|
+
for (const replace of text.matchAll(/^\s*(?:replace\s+)?"?([^\s"(]+)"?(?:\s+\S+)?\s*=>\s*"?((?:\.\.?|\/)[^\s"]*)"?/gm))
|
|
169
|
+
modules.push({ path: replace[1], dir: path.resolve(dir, replace[2]) });
|
|
170
|
+
}
|
|
171
|
+
return modules;
|
|
172
|
+
}
|
|
173
|
+
/** Whether a go.mod at or above `directory`, within the workspace, puts it in module mode. */
|
|
174
|
+
function goModuleMode(workspaceRoot, directory) {
|
|
175
|
+
for (let current = directory;; current = path.dirname(current)) {
|
|
176
|
+
try {
|
|
177
|
+
if (statSync(path.join(current, "go.mod")).isFile())
|
|
178
|
+
return true;
|
|
179
|
+
}
|
|
180
|
+
catch {
|
|
181
|
+
// no go.mod here
|
|
182
|
+
}
|
|
183
|
+
if (path.relative(workspaceRoot, current) === "" || path.dirname(current) === current)
|
|
184
|
+
return false;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Which Go packages are the project's, and whether one can read the
|
|
189
|
+
* environment. Folder scans and go.mod files are read once per filter.
|
|
190
|
+
*/
|
|
191
|
+
function createGoReach(workspaceRoot) {
|
|
192
|
+
let modules;
|
|
193
|
+
const reached = new Map();
|
|
194
|
+
/**
|
|
195
|
+
* The folder an import path names when it is the project's: relative,
|
|
196
|
+
* under a module path or local replace of the project (the longest
|
|
197
|
+
* wins), or, without a go.mod (GOPATH mode), that path under one of the
|
|
198
|
+
* importer's enclosing folders. Null for another package (the standard
|
|
199
|
+
* library's, a third-party one); "" when the project's go.mod files
|
|
200
|
+
* cannot be read.
|
|
201
|
+
*/
|
|
202
|
+
const resolve = (spelled, from) => {
|
|
203
|
+
if (/^\.\.?(?:\/|$)/.test(spelled))
|
|
204
|
+
return path.resolve(from, spelled);
|
|
205
|
+
if (goModuleMode(workspaceRoot, from)) {
|
|
206
|
+
if (modules === undefined) {
|
|
207
|
+
try {
|
|
208
|
+
modules = goModules(workspaceRoot);
|
|
209
|
+
}
|
|
210
|
+
catch {
|
|
211
|
+
modules = null;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
if (modules === null)
|
|
215
|
+
return "";
|
|
216
|
+
let best = null;
|
|
217
|
+
for (const module of modules)
|
|
218
|
+
if ((spelled === module.path || spelled.startsWith(`${module.path}/`)) &&
|
|
219
|
+
(best === null || module.path.length > best.path.length))
|
|
220
|
+
best = module;
|
|
221
|
+
return best === null ? null : path.join(best.dir, spelled.slice(best.path.length));
|
|
222
|
+
}
|
|
223
|
+
for (let current = from;; current = path.dirname(current)) {
|
|
224
|
+
const candidate = path.join(current, spelled);
|
|
225
|
+
try {
|
|
226
|
+
if (statSync(candidate).isDirectory())
|
|
227
|
+
return candidate;
|
|
228
|
+
}
|
|
229
|
+
catch {
|
|
230
|
+
// not here
|
|
231
|
+
}
|
|
232
|
+
if (path.relative(workspaceRoot, current) === "" || path.dirname(current) === current)
|
|
233
|
+
return null;
|
|
234
|
+
}
|
|
235
|
+
};
|
|
236
|
+
/**
|
|
237
|
+
* Whether a package of the project can read the environment: one of its
|
|
238
|
+
* files (not its tests, which an importer does not compile) spells a
|
|
239
|
+
* getter, cgo or a linkname, or imports a package of the project that
|
|
240
|
+
* can. A folder that cannot be read, or holds no Go file, can.
|
|
241
|
+
*/
|
|
242
|
+
const reaches = (dir) => {
|
|
243
|
+
const known = reached.get(dir);
|
|
244
|
+
if (known !== undefined)
|
|
245
|
+
return known;
|
|
246
|
+
// An import cycle reads nothing by itself.
|
|
247
|
+
reached.set(dir, false);
|
|
248
|
+
let result;
|
|
249
|
+
try {
|
|
250
|
+
const texts = readdirSync(dir)
|
|
251
|
+
.filter((name) => name.endsWith(".go") && !name.endsWith("_test.go"))
|
|
252
|
+
.map((name) => readFileSync(path.join(dir, name), "utf8"));
|
|
253
|
+
result = texts.some((text) => GO_ENV_SOURCE.test(text) || importsReach(text, dir));
|
|
254
|
+
}
|
|
255
|
+
catch (error) {
|
|
256
|
+
// No such folder: no package of the project, so the path is not an
|
|
257
|
+
// import of it (an import of it would not build), only a string.
|
|
258
|
+
const code = error.code;
|
|
259
|
+
result = code !== "ENOENT" && code !== "ENOTDIR";
|
|
260
|
+
}
|
|
261
|
+
reached.set(dir, result);
|
|
262
|
+
return result;
|
|
263
|
+
};
|
|
264
|
+
/** Whether Go source imports a package of the project that can read the environment. */
|
|
265
|
+
const importsReach = (text, from) => goStrings(text).some((spelled) => {
|
|
266
|
+
const target = resolve(spelled, from);
|
|
267
|
+
return target === "" || (target !== null && target !== from && reaches(target));
|
|
268
|
+
});
|
|
269
|
+
return { importsReach };
|
|
270
|
+
}
|
|
271
|
+
/** The nearest folder holding Cargo.toml at or above `directory`, within the workspace. */
|
|
272
|
+
function crateRoot(workspaceRoot, directory) {
|
|
273
|
+
for (let current = directory;; current = path.dirname(current)) {
|
|
274
|
+
try {
|
|
275
|
+
if (statSync(path.join(current, "Cargo.toml")).isFile())
|
|
276
|
+
return current;
|
|
277
|
+
}
|
|
278
|
+
catch {
|
|
279
|
+
// no manifest here
|
|
280
|
+
}
|
|
281
|
+
if (path.relative(workspaceRoot, current) === "" || path.dirname(current) === current)
|
|
282
|
+
return workspaceRoot;
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Whether Rust source may define a macro of that name for the crate: a
|
|
287
|
+
* `macro_rules!` of it (comments allowed between the tokens), a
|
|
288
|
+
* `macro_rules!` whose name is a macro variable, or `#[macro_use] extern
|
|
289
|
+
* crate`, which brings another crate's macros in.
|
|
290
|
+
*/
|
|
291
|
+
function rustDefines(text, name) {
|
|
292
|
+
const gap = String.raw `(?:\s|\/\*[\s\S]*?\*\/|\/\/[^\n]*)*`;
|
|
293
|
+
return (new RegExp(`macro_rules${gap}!${gap}(?:r#)?${name}(?!\\w)`).test(text) ||
|
|
294
|
+
new RegExp(`macro_rules${gap}!${gap}\\$`).test(text) ||
|
|
295
|
+
new RegExp(`#${gap}\\[${gap}macro_use${gap}\\]${gap}(?:pub${gap})?extern${gap}crate\\b`).test(text));
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* A filter for one read: keeps every row, except a marked row whose
|
|
299
|
+
* declaration the project's files rule out. Directory scans are shared by
|
|
300
|
+
* the files of the read.
|
|
301
|
+
*/
|
|
302
|
+
export function createShadowRowFilter(workspaceRoot) {
|
|
303
|
+
const sources = new Map();
|
|
304
|
+
const read = (key, list) => {
|
|
305
|
+
if (!sources.has(key)) {
|
|
306
|
+
try {
|
|
307
|
+
sources.set(key, list().map((file) => readFileSync(file, "utf8")));
|
|
308
|
+
}
|
|
309
|
+
catch {
|
|
310
|
+
sources.set(key, null);
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
return sources.get(key) ?? null;
|
|
314
|
+
};
|
|
315
|
+
const go = createGoReach(workspaceRoot);
|
|
316
|
+
return (file, rows) => {
|
|
317
|
+
const directory = path.dirname(path.join(workspaceRoot, file));
|
|
318
|
+
return rows.filter((row) => {
|
|
319
|
+
const java = JAVA_ROW.exec(row.text);
|
|
320
|
+
if (java !== null) {
|
|
321
|
+
const texts = read(`java:${directory}`, () => readdirSync(directory)
|
|
322
|
+
.filter((name) => name.endsWith(".java"))
|
|
323
|
+
.map((name) => path.join(directory, name)));
|
|
324
|
+
const type = java[1];
|
|
325
|
+
if (texts === null || texts.some((text) => javaDeclares(text, type)))
|
|
326
|
+
return true;
|
|
327
|
+
// A package spans source roots (src/main/java beside generated or
|
|
328
|
+
// test sources), and a file's package is what it declares, not its
|
|
329
|
+
// folder: every .java file of the project declaring the package is
|
|
330
|
+
// read too.
|
|
331
|
+
const all = read("java:*", () => sourceFiles(workspaceRoot, ".java"));
|
|
332
|
+
const pkg = java[2] ?? "";
|
|
333
|
+
return all === null || all.some((text) => javaPackage(text) === pkg && javaDeclares(text, type));
|
|
334
|
+
}
|
|
335
|
+
const rust = RUST_ROW.exec(row.text);
|
|
336
|
+
if (rust !== null) {
|
|
337
|
+
const root = crateRoot(workspaceRoot, directory);
|
|
338
|
+
const texts = read(`rust:${root}`, () => sourceFiles(root, ".rs", ["target"]));
|
|
339
|
+
return texts === null || texts.some((text) => rustDefines(text, rust[1]));
|
|
340
|
+
}
|
|
341
|
+
if (GO_IMPORT_ROW.test(row.text)) {
|
|
342
|
+
// The row's text may be cut short, so the import is read from the
|
|
343
|
+
// file's line; every path spelled there is checked.
|
|
344
|
+
const texts = read(`file:${file}`, () => [path.join(workspaceRoot, file)]);
|
|
345
|
+
const line = texts?.[0]?.split("\n")[row.line - 1];
|
|
346
|
+
return line === undefined || goStrings(line).length === 0 || go.importsReach(line, directory);
|
|
347
|
+
}
|
|
348
|
+
const goCall = GO_CALL_ROW.exec(row.text);
|
|
349
|
+
if (goCall !== null) {
|
|
350
|
+
const own = path.basename(file);
|
|
351
|
+
const test = own.endsWith("_test.go");
|
|
352
|
+
const texts = read(`go:${file}`, () => readdirSync(directory)
|
|
353
|
+
.filter((name) => name.endsWith(".go") && name !== own && (test || !name.endsWith("_test.go")))
|
|
354
|
+
.map((name) => path.join(directory, name)));
|
|
355
|
+
// A function declared in another file is the package's own function;
|
|
356
|
+
// a variable of that name may hold any function value.
|
|
357
|
+
const name = goCall[1];
|
|
358
|
+
const variable = new RegExp(`\\bvar\\s+${name}\\b|\\b${name}\\s*(?:,\\s*\\w+\\s*)*(?::=|=(?!=))|^\\s*${name}\\s+[^\\s(=]`, "m");
|
|
359
|
+
return texts === null || texts.some((text) => variable.test(javaCode(text)));
|
|
360
|
+
}
|
|
361
|
+
const goName = GO_ROW.exec(row.text);
|
|
362
|
+
if (goName !== null) {
|
|
363
|
+
// The package's other files: the directory's .go files, with its
|
|
364
|
+
// test files only for a test file.
|
|
365
|
+
const own = path.basename(file);
|
|
366
|
+
const test = own.endsWith("_test.go");
|
|
367
|
+
const texts = read(`go:${file}`, () => readdirSync(directory)
|
|
368
|
+
.filter((name) => name.endsWith(".go") && name !== own && (test || !name.endsWith("_test.go")))
|
|
369
|
+
.map((name) => path.join(directory, name)));
|
|
370
|
+
// A getter may be reached through the name by any chain of the
|
|
371
|
+
// package's functions and values, so the row stays when any of
|
|
372
|
+
// those files can read the environment and any names it.
|
|
373
|
+
// A file that imports a package of the project that can read the
|
|
374
|
+
// environment can read it too.
|
|
375
|
+
const name = new RegExp(`\\b${goName[1]}\\b`);
|
|
376
|
+
return (texts === null ||
|
|
377
|
+
(texts.some((text) => GO_ENV_SOURCE.test(text) || go.importsReach(text, directory)) &&
|
|
378
|
+
texts.some((text) => name.test(text))));
|
|
379
|
+
}
|
|
380
|
+
const csharp = CSHARP_ROW.exec(row.text);
|
|
381
|
+
if (csharp !== null) {
|
|
382
|
+
// Generated sources under obj/ are compiled too, so they are read.
|
|
383
|
+
const texts = read("csharp", () => sourceFiles(workspaceRoot, ".cs"));
|
|
384
|
+
return texts === null || texts.some((text) => csharpDeclares(text, csharp[1]));
|
|
385
|
+
}
|
|
386
|
+
return true;
|
|
387
|
+
});
|
|
388
|
+
};
|
|
389
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The SWI-Prolog evaluator behind the code proof kinds. Kibi runs it with the
|
|
3
|
+
* SWI-Prolog it resolves for its own engine (KIBI_SWIPL, the bundled runtime,
|
|
4
|
+
* then swipl on PATH). It loads the file a symbol names (a module, or a plain
|
|
5
|
+
* file into user) and reads a predicate named by its indicator: a domain is
|
|
6
|
+
* the distinct solutions of one argument (`arg`, or the only one), a value is
|
|
7
|
+
* the single number such a solution holds, a rule predicate is called once
|
|
8
|
+
* per row and decides it by success or failure, and a transition table lists
|
|
9
|
+
* every solution as an edge. The plan is the last command-line argument; the
|
|
10
|
+
* answer is the last line of output, in the JSON the JavaScript and Python
|
|
11
|
+
* evaluators print.
|
|
12
|
+
*/
|
|
13
|
+
export declare const PROLOG_EVALUATOR: string;
|
|
14
|
+
//# sourceMappingURL=prolog-evaluator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prolog-evaluator.d.ts","sourceRoot":"","sources":["../../../src/operations/proof/prolog-evaluator.ts"],"names":[],"mappings":"AAkBA;;;;;;;;;;;GAWG;AAEH,eAAO,MAAM,gBAAgB,QAwN5B,CAAC"}
|