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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"relationships.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/relationships.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAE3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,eAAO,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"relationships.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/relationships.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0CAA0C,CAAC;AAE3E,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,eAAO,MAAM,kBAAkB,0RAmBrB,CAAC;AACX,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEnE,wBAAgB,0BAA0B,CACxC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,MAA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MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,aAAa,EAAE,SAAS,iBAAiB,EAAE,EAC3C,aAAa,EAAE,MAAM,EACrB,IAAI,GAAE,qBAAuD,GAC5D,OAAO,CAAC,IAAI,CAAC,CAyCf;AAED,wBAAgB,gCAAgC,CAC9C,QAAQ,EAAE,MAAM,EAChB,YAAY,EAAE,iBAAiB,GAC9B,MAAM,CAIR;AAuBD,wBAAsB,+BAA+B,CACnD,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,aAAa,EAAE,SAAS,iBAAiB,EAAE,GAC1C,OAAO,CAAC,IAAI,CAAC,CAuBf;AAED,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,UAAU,EAClB,aAAa,EAAE,SAAS,iBAAiB,EAAE,GAC1C,OAAO,CAAC,IAAI,CAAC,CA+Bf;AAED,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,SAAS,iBAAiB,EAAE,CAAC,CAevC"}
|
|
@@ -28,6 +28,11 @@ export type SagaRollbackFailure = Readonly<{
|
|
|
28
28
|
step: string;
|
|
29
29
|
error: unknown;
|
|
30
30
|
}>;
|
|
31
|
+
/** A mutation failed before commit and at least one compensation also failed. */
|
|
32
|
+
export declare class MutationRollbackFailureError extends AggregateError {
|
|
33
|
+
readonly rollbackFailures: readonly SagaRollbackFailure[];
|
|
34
|
+
constructor(errors: readonly unknown[], message: string, rollbackFailures: readonly SagaRollbackFailure[]);
|
|
35
|
+
}
|
|
31
36
|
export declare class MutationSaga {
|
|
32
37
|
private readonly steps;
|
|
33
38
|
private rollbackCompleted;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"saga.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/saga.ts"],"names":[],"mappings":"AAkBA;;;;;;;;;GASG;AAGH,MAAM,MAAM,Q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Q,GAAG,IAAI;IAIzB;;;;OAIG;IAEH,aAAa,IAAI,IAAI;IAKrB,IAAI,SAAS,IAAI,OAAO,CAEvB;IAED;;;;OAIG;IAEG,QAAQ,IAAI,OAAO,CAAC,SAAS,mBAAmB,EAAE,CAAC;CAkB1D"}
|
|
@@ -15,6 +15,16 @@
|
|
|
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
|
+
/** A mutation failed before commit and at least one compensation also failed. */
|
|
19
|
+
// implements REQ-014
|
|
20
|
+
export class MutationRollbackFailureError extends AggregateError {
|
|
21
|
+
rollbackFailures;
|
|
22
|
+
constructor(errors, message, rollbackFailures) {
|
|
23
|
+
super(errors, message);
|
|
24
|
+
this.rollbackFailures = rollbackFailures;
|
|
25
|
+
this.name = "MutationRollbackFailureError";
|
|
26
|
+
}
|
|
27
|
+
}
|
|
18
28
|
// implements REQ-014
|
|
19
29
|
export class MutationSaga {
|
|
20
30
|
steps = [];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/serialization.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/serialization.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAsDpD,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACxC,MAAM,CAMR;AAGD,wBAAgB,yBAAyB,CAAC,GAAG,EAAE,iBAAiB,GAAG,MAAM,CAOxE;AAGD,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAkBtD"}
|
|
@@ -27,6 +27,8 @@ function serializeValue(key, value) {
|
|
|
27
27
|
return `'${value.replaceAll("'", "''")}'`;
|
|
28
28
|
}
|
|
29
29
|
if (key === "rule_ir" ||
|
|
30
|
+
key === "argument_constants" ||
|
|
31
|
+
key === "argument_aliases" ||
|
|
30
32
|
key === "semantic_inventory" ||
|
|
31
33
|
key === "proof_contract" ||
|
|
32
34
|
key === "proof_bindings" ||
|
|
@@ -8,6 +8,12 @@ export type SourceWriteReceipt = Readonly<{
|
|
|
8
8
|
created: boolean;
|
|
9
9
|
}>;
|
|
10
10
|
export declare function writePendingSourceReceipt(workspaceRoot: string, relativePath: string, afterHash: string): void;
|
|
11
|
+
/**
|
|
12
|
+
* Retire the pending receipt of a source that a committed plan deleted. A
|
|
13
|
+
* receipt binds untracked input to exact bytes, so one left behind for a
|
|
14
|
+
* removed file makes every later sync fail on a missing pending source.
|
|
15
|
+
*/
|
|
16
|
+
export declare function retirePendingSourceReceipt(workspaceRoot: string, relativePath: string): void;
|
|
11
17
|
export declare function resolveContainedSourcePath(workspaceRoot: string, relative: string): string;
|
|
12
18
|
export declare function normalizeAuthoredSourcePath(workspaceRoot: string, source: string): string;
|
|
13
19
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"source-authoring.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/source-authoring.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAKjF,OAAO,KAAK,EAAqB,WAAW,EAAE,MAAM,YAAY,CAAC;AAEjE,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAC;IACzB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC,CAAC;AAmBH,wBAAgB,yBAAyB,CACvC,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,GAChB,IAAI,CAiBN;
|
|
1
|
+
{"version":3,"file":"source-authoring.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/source-authoring.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAKjF,OAAO,KAAK,EAAqB,WAAW,EAAE,MAAM,YAAY,CAAC;AAEjE,MAAM,MAAM,kBAAkB,GAAG,QAAQ,CAAC;IACxC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAC;IACzB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,OAAO,EAAE,OAAO,CAAC;CAClB,CAAC,CAAC;AAmBH,wBAAgB,yBAAyB,CACvC,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,EACpB,SAAS,EAAE,MAAM,GAChB,IAAI,CAiBN;AAED;;;;GAIG;AAEH,wBAAgB,0BAA0B,CACxC,aAAa,EAAE,MAAM,EACrB,YAAY,EAAE,MAAM,GACnB,IAAI,CAMN;AAgBD,wBAAgB,0BAA0B,CACxC,aAAa,EAAE,MAAM,EACrB,QAAQ,EAAE,MAAM,GACf,MAAM,CAwCR;AAED,wBAAgB,2BAA2B,CACzC,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,MAAM,GACb,MAAM,CAWR;AAsBD;;;;GAIG;AACH,wBAAgB,sBAAsB,CACpC,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,MAAM,GACX,MAAM,GAAG,SAAS,CAYpB;AAED,wBAAgB,yBAAyB,CACvC,aAAa,EAAE,MAAM,EACrB,IAAI,EAAE,MAAM,GACX,OAAO,CAET;AAwFD,uFAAuF;AAEvF,eAAO,MAAM,uBAAuB,uGAM1B,CAAC;AA8BX,wBAAgB,qB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,OAAO,CAAC;IACT,OAAO,EAAE,kBAAkB,CAAC;IAC5B,QAAQ,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC/B,GAAG,IAAI,CAAC,CAoHR;AAED,uEAAuE;AACvE,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,gBAAgB,EACzB,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAC3C,MAAM,CAOR"}
|
|
@@ -22,6 +22,26 @@ export function writePendingSourceReceipt(workspaceRoot, relativePath, afterHash
|
|
|
22
22
|
createdAt: new Date().toISOString(),
|
|
23
23
|
}, null, 2)}\n`, { mode: 0o600 });
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Retire the pending receipt of a source that a committed plan deleted. A
|
|
27
|
+
* receipt binds untracked input to exact bytes, so one left behind for a
|
|
28
|
+
* removed file makes every later sync fail on a missing pending source.
|
|
29
|
+
*/
|
|
30
|
+
// implements REQ-core-atomic-upsert-persistence, REQ-kibi-operation-interface-parity
|
|
31
|
+
export function retirePendingSourceReceipt(workspaceRoot, relativePath) {
|
|
32
|
+
try {
|
|
33
|
+
fs.unlinkSync(pendingReceiptPath(workspaceRoot, relativePath));
|
|
34
|
+
}
|
|
35
|
+
catch (error) {
|
|
36
|
+
if (error.code !== "ENOENT")
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Authored YAML round-trips keep long scalars on one line, matching sync and
|
|
42
|
+
* coordinate refresh output, so editing one entry never refolds the others.
|
|
43
|
+
*/
|
|
44
|
+
const AUTHORED_YAML_OPTIONS = { lineWidth: 0 };
|
|
25
45
|
function authoredPath(value) {
|
|
26
46
|
if (typeof value !== "string" || !value.trim())
|
|
27
47
|
return undefined;
|
|
@@ -245,6 +265,15 @@ function mergeManifestRelationships(existing, incoming, entityId) {
|
|
|
245
265
|
}
|
|
246
266
|
return [...merged.values()].sort((left, right) => `${left.type}\u0000${left.target}`.localeCompare(`${right.type}\u0000${right.target}`));
|
|
247
267
|
}
|
|
268
|
+
/** Indexes of every manifest entry whose `id` equals `id`, in file order. */
|
|
269
|
+
function symbolManifestIndexes(items, id) {
|
|
270
|
+
return items.flatMap((item, index) => item &&
|
|
271
|
+
typeof item === "object" &&
|
|
272
|
+
"get" in item &&
|
|
273
|
+
String(item.get("id")) === id
|
|
274
|
+
? [index]
|
|
275
|
+
: []);
|
|
276
|
+
}
|
|
248
277
|
function renderSymbolManifest(entity, relationships, existingContent) {
|
|
249
278
|
if (existingContent === undefined) {
|
|
250
279
|
const doc = parseDocument(stringify({
|
|
@@ -252,7 +281,7 @@ function renderSymbolManifest(entity, relationships, existingContent) {
|
|
|
252
281
|
symbolManifestRecord(entity, mergeManifestRelationships([], relationships, String(entity.id))),
|
|
253
282
|
],
|
|
254
283
|
}));
|
|
255
|
-
return doc.toString();
|
|
284
|
+
return doc.toString(AUTHORED_YAML_OPTIONS);
|
|
256
285
|
}
|
|
257
286
|
const doc = parseDocument(existingContent);
|
|
258
287
|
const symbols = doc.get("symbols", true);
|
|
@@ -261,31 +290,42 @@ function renderSymbolManifest(entity, relationships, existingContent) {
|
|
|
261
290
|
}
|
|
262
291
|
const items = symbols.items;
|
|
263
292
|
const id = String(entity.id);
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
const
|
|
293
|
+
// A rebase that unions both sides of the manifest can leave the same id
|
|
294
|
+
// twice with different ownership. Fold every copy into the first one so an
|
|
295
|
+
// upsert repairs the duplicate instead of updating one copy and leaving the
|
|
296
|
+
// other to shadow it.
|
|
297
|
+
const matches = symbolManifestIndexes(items, id);
|
|
298
|
+
const index = matches[0] ?? -1;
|
|
299
|
+
const existingRelationships = matches.flatMap((match) => manifestRelationships(items[match]));
|
|
270
300
|
let next = symbolManifestRecord(entity, mergeManifestRelationships(existingRelationships, relationships, id));
|
|
271
301
|
if (index >= 0) {
|
|
272
302
|
// Partial symbol payloads (for example a relationship-only upsert) must
|
|
273
303
|
// never erase authored provenance from the manifest. Preserve fields the
|
|
274
|
-
// payload omits, with incoming values winning on explicit conflicts
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
304
|
+
// payload omits, with incoming values winning on explicit conflicts; the
|
|
305
|
+
// first copy wins over later duplicates.
|
|
306
|
+
let preserved = {};
|
|
307
|
+
for (const match of [...matches].reverse()) {
|
|
308
|
+
const item = items[match];
|
|
309
|
+
const previous = typeof item?.toJSON === "function" ? item.toJSON() : null;
|
|
310
|
+
if (typeof previous === "object" &&
|
|
311
|
+
previous !== null &&
|
|
312
|
+
!Array.isArray(previous)) {
|
|
313
|
+
preserved = {
|
|
314
|
+
...preserved,
|
|
315
|
+
...symbolManifestRecord(previous, []),
|
|
316
|
+
};
|
|
317
|
+
}
|
|
282
318
|
}
|
|
319
|
+
next = { ...preserved, ...next };
|
|
283
320
|
doc.setIn(["symbols", index], next);
|
|
321
|
+
for (const duplicate of matches.slice(1).reverse()) {
|
|
322
|
+
doc.deleteIn(["symbols", duplicate]);
|
|
323
|
+
}
|
|
284
324
|
}
|
|
285
325
|
else {
|
|
286
326
|
doc.addIn(["symbols"], next);
|
|
287
327
|
}
|
|
288
|
-
return doc.toString();
|
|
328
|
+
return doc.toString(AUTHORED_YAML_OPTIONS);
|
|
289
329
|
}
|
|
290
330
|
export function renderSourceDeletion(sourcePathValue, entityId, entityType, existingContent) {
|
|
291
331
|
const extension = path.extname(sourcePathValue).toLowerCase();
|
|
@@ -306,16 +346,15 @@ export function renderSourceDeletion(sourcePathValue, entityId, entityType, exis
|
|
|
306
346
|
throw new OperationError("SOURCE_FORMAT_INVALID", "Symbol manifest must contain a symbols array");
|
|
307
347
|
}
|
|
308
348
|
const items = symbols.items;
|
|
309
|
-
const
|
|
310
|
-
|
|
311
|
-
return false;
|
|
312
|
-
return (String(item.get("id")) === entityId);
|
|
313
|
-
});
|
|
314
|
-
if (index < 0) {
|
|
349
|
+
const matches = symbolManifestIndexes(items, entityId);
|
|
350
|
+
if (matches.length === 0) {
|
|
315
351
|
throw new OperationError("SOURCE_ENTITY_MISMATCH", `Symbol manifest ${sourcePathValue} does not contain ${entityId}`);
|
|
316
352
|
}
|
|
317
|
-
|
|
318
|
-
|
|
353
|
+
// Delete every copy, last first so earlier indexes stay valid.
|
|
354
|
+
for (const match of [...matches].reverse()) {
|
|
355
|
+
doc.deleteIn(["symbols", match]);
|
|
356
|
+
}
|
|
357
|
+
return { mode: "write", body: doc.toString(AUTHORED_YAML_OPTIONS) };
|
|
319
358
|
}
|
|
320
359
|
throw new OperationError("SOURCE_FORMAT_UNSUPPORTED", `Unsupported authored source format: ${extension || "unknown"}`);
|
|
321
360
|
}
|
|
@@ -381,7 +420,7 @@ export function renderMarkdownRelationshipDeletion(sourcePathValue, existingCont
|
|
|
381
420
|
return { body: existingContent, removed: false };
|
|
382
421
|
const body = existingContent.slice(marker + "\n---".length);
|
|
383
422
|
return {
|
|
384
|
-
body: `---\n${frontmatter.toString()}---${body.startsWith("\n") ? "" : "\n"}${body}`,
|
|
423
|
+
body: `---\n${frontmatter.toString(AUTHORED_YAML_OPTIONS)}---${body.startsWith("\n") ? "" : "\n"}${body}`,
|
|
385
424
|
removed: true,
|
|
386
425
|
};
|
|
387
426
|
}
|
|
@@ -437,7 +476,7 @@ export function renderYamlRelationshipDeletion(sourcePathValue, existingContent,
|
|
|
437
476
|
}
|
|
438
477
|
}
|
|
439
478
|
return removed
|
|
440
|
-
? { body: doc.toString(), removed: true }
|
|
479
|
+
? { body: doc.toString(AUTHORED_YAML_OPTIONS), removed: true }
|
|
441
480
|
: { body: existingContent, removed: false };
|
|
442
481
|
}
|
|
443
482
|
function renderSourceDocument(input, entity, existingContent, relativePath) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"strict-fact.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/strict-fact.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"strict-fact.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/strict-fact.ts"],"names":[],"mappings":"AAWA,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAarD;AAGD,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACxC,MAAM,EAAE,CA+EV;AAED,wBAAgB,qBAAqB,CACnC,aAAa,EAAE,OAAO,EACtB,aAAa,EAAE,OAAO,GACrB,IAAI,CAUN;AAGD,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GACxC,IAAI,CAmDN"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { validateLogicIr } from "../../logic/ir.js";
|
|
2
|
+
import { predicateVocabularyErrors } from "../modeling/predicate-vocabulary.js";
|
|
2
3
|
const PROPERTY_VALUE_FIELDS = [
|
|
3
4
|
"value_string",
|
|
4
5
|
"value_int",
|
|
@@ -106,6 +107,10 @@ export function validateFactModelingShape(entity) {
|
|
|
106
107
|
if (hints.length > 0) {
|
|
107
108
|
throw new Error(`Entity validation failed: ${hints.join("; ")}`);
|
|
108
109
|
}
|
|
110
|
+
const vocabularyErrors = predicateVocabularyErrors(entity);
|
|
111
|
+
if (vocabularyErrors.length > 0) {
|
|
112
|
+
throw new Error(`Entity validation failed: ${vocabularyErrors.join("; ")}`);
|
|
113
|
+
}
|
|
109
114
|
if (entity.type === "fact" && entity.fact_kind === "rule") {
|
|
110
115
|
const validation = validateLogicIr(entity.rule_ir);
|
|
111
116
|
if (!validation.valid || !validation.semanticKey) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { SemanticAdvisorReceipt } from "../semantic-advisor/types.js";
|
|
2
|
+
import type { SagaRollbackFailure } from "./saga.js";
|
|
2
3
|
export type RelationshipInput = Readonly<Record<string, unknown>>;
|
|
3
4
|
export type UpsertInput = {
|
|
4
5
|
readonly type: string;
|
|
@@ -48,6 +49,20 @@ export type UpsertPayload = {
|
|
|
48
49
|
readonly checked_req_id: string;
|
|
49
50
|
readonly strict_readiness: string;
|
|
50
51
|
};
|
|
52
|
+
readonly deferredCommit?: DeferredUpsertCommit;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Internal lifecycle for source writes prepared ahead of a batched Prolog
|
|
56
|
+
* commit. Finalization crosses the compiled commit boundary and permanently
|
|
57
|
+
* disables source rollback for that mutation.
|
|
58
|
+
*/
|
|
59
|
+
export type DeferredUpsertCommit = {
|
|
60
|
+
readonly entity: Readonly<Record<string, unknown>>;
|
|
61
|
+
readonly relationships: readonly RelationshipInput[];
|
|
62
|
+
readonly skipContradictionCheck: boolean;
|
|
63
|
+
readonly state: "prepared" | "rolling_back" | "rolled_back" | "committed";
|
|
64
|
+
readonly finalize: () => void;
|
|
65
|
+
readonly rollback: () => Promise<readonly SagaRollbackFailure[]>;
|
|
51
66
|
};
|
|
52
67
|
export type ValidateUpsertPayload = {
|
|
53
68
|
readonly valid: boolean;
|
|
@@ -74,6 +89,8 @@ export type DeletePayload = {
|
|
|
74
89
|
readonly error_codes?: readonly Readonly<Record<string, unknown>>[];
|
|
75
90
|
readonly relationship_results?: readonly Record<string, unknown>[];
|
|
76
91
|
readonly sync_required?: boolean;
|
|
92
|
+
/** Declared effects this call did not perform, such as a plan-only result. */
|
|
93
|
+
readonly skippedEffects?: readonly string[];
|
|
77
94
|
readonly sourceWrites?: readonly {
|
|
78
95
|
readonly path: string;
|
|
79
96
|
readonly mode?: "write" | "delete";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../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YAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;YACtB,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,QAAQ,CAAC;YAClC,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;YACnC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;YAClC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;SACxB,EAAE,CAAC;QACJ,QAAQ,CAAC,oBAAoB,EAAE,OAAO,CAAC;KACxC,CAAC;CACH,CAAC"}
|
|
@@ -18,6 +18,12 @@ export type UpsertExecutionOptions = Readonly<{
|
|
|
18
18
|
* entries. Everything else keeps the append-only invariant fail-closed.
|
|
19
19
|
*/
|
|
20
20
|
readonly allowReceiptsPrune?: boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Prepare source and validation, then return the commit payload without
|
|
23
|
+
* talking to Prolog. Proof ingest batches those payloads into one
|
|
24
|
+
* transaction.
|
|
25
|
+
*/
|
|
26
|
+
readonly deferCompiledCommit?: boolean;
|
|
21
27
|
}>;
|
|
22
28
|
export declare function executeUpsert(input: UpsertInput, context: OperationContext, options?: UpsertExecutionOptions): Promise<OperationResult<UpsertPayload>>;
|
|
23
29
|
//# sourceMappingURL=upsert.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"upsert.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/upsert.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;
|
|
1
|
+
{"version":3,"file":"upsert.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/upsert.ts"],"names":[],"mappings":"AAeA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AACjF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAoCxE,OAAO,KAAK,EAAE,iBAAiB,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAuGhF,wBAAsB,+BAA+B,CACnD,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,IAAI,CAAC,CAaf;AAED,wBAAsB,sBAAsB,CAC1C,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,EACzC,aAAa,EAAE,SAAS,iBAAiB,EAAE,EAC3C,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,SAAS,iBAAiB,EAAE,CAAC,CAuBvC;AAmCD,MAAM,MAAM,sBAAsB,GAAG,QAAQ,CAAC;IAC5C;;;;;;OAMG;IAEH,QAAQ,CAAC,sBAAsB,CAAC,EAAE,MAAM,CAAC;IACzC;;;;OAIG;IACH,QAAQ,CAAC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IACtC;;;;OAIG;IACH,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC;CACxC,CAAC,CAAC;AAEH,wBAAsB,aAAa,CACjC,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,gBAAgB,EACzB,OAAO,GAAE,sBAA2B,GACnC,OAAO,CAAC,eAAe,CAAC,aAAa,CAAC,CAAC,CAshBzC"}
|
|
@@ -9,11 +9,13 @@ import { loadEntities } from "../../public/operations/discovery-entities.js";
|
|
|
9
9
|
import { appendOnlyProofReceiptHistoryErrors } from "../../public/proof-receipt.js";
|
|
10
10
|
import { appendRelationship, computeShardPath, } from "../../relationships/shards.js";
|
|
11
11
|
import { resolveBranchAttachment } from "../../utils/branch-resolver.js";
|
|
12
|
+
import { entityIdStyleWarnings } from "../../utils/entity-id-style.js";
|
|
12
13
|
import { analyzeSemanticAdvisorInput } from "../semantic-advisor/analyze-prose.js";
|
|
13
14
|
import { assertLogicalGroundingClaimKeys, assertSemanticInventoryBoundary, } from "../semantic-advisor/ingestion-boundary.js";
|
|
14
15
|
import { buildUpsertCommitGoal, formatUpsertError } from "./contradictions.js";
|
|
16
|
+
import { assertPredicateArgumentVocabulary } from "./predicate-vocabulary-guard.js";
|
|
15
17
|
import { existingRelationships, validateLiveRelationshipTargets, validateRelationshipSources, validateStrictLanePairing, validateSupersedesSourceHistory, } from "./relationships.js";
|
|
16
|
-
import { MutationSaga } from "./saga.js";
|
|
18
|
+
import { MutationRollbackFailureError, MutationSaga } from "./saga.js";
|
|
17
19
|
import { writePendingSourceReceipt, writeSourceForUpsert, } from "./source-authoring.js";
|
|
18
20
|
import { acquireSymbolCompilerLock, releaseSymbolCompilerLock, } from "./symbol-compiler-lock.js";
|
|
19
21
|
import { validateSymbolGranularity } from "./symbol-granularity.js";
|
|
@@ -220,6 +222,7 @@ export async function executeUpsert(input, context, options = {}) {
|
|
|
220
222
|
semanticAdvisor = semantic.receipt;
|
|
221
223
|
assertSemanticInventoryBoundary({ ...input, relationships }, relationships, semantic.receipt);
|
|
222
224
|
await assertLogicalGroundingClaimKeys(prolog, { ...input, relationships }, relationships);
|
|
225
|
+
await assertPredicateArgumentVocabulary(prolog, validated.entity);
|
|
223
226
|
if (context.fs !== undefined && context.sourceFirst !== false) {
|
|
224
227
|
const existingRows = await loadEntities(prolog, {
|
|
225
228
|
id: input.id,
|
|
@@ -329,6 +332,57 @@ export async function executeUpsert(input, context, options = {}) {
|
|
|
329
332
|
source: sourceWrite.receipt.path,
|
|
330
333
|
};
|
|
331
334
|
}
|
|
335
|
+
if (options.deferCompiledCommit === true) {
|
|
336
|
+
let deferredState = "prepared";
|
|
337
|
+
let rollbackPromise;
|
|
338
|
+
const deferredCommit = {
|
|
339
|
+
entity: commitEntity ?? validated.entity,
|
|
340
|
+
relationships: validated.relationships,
|
|
341
|
+
skipContradictionCheck: input._skipContradictionCheck === true,
|
|
342
|
+
get state() {
|
|
343
|
+
return deferredState;
|
|
344
|
+
},
|
|
345
|
+
finalize: () => {
|
|
346
|
+
if (deferredState !== "prepared") {
|
|
347
|
+
throw new Error(`Cannot finalize deferred upsert ${input.id} from state ${deferredState}`);
|
|
348
|
+
}
|
|
349
|
+
saga.markCommitted();
|
|
350
|
+
deferredState = "committed";
|
|
351
|
+
},
|
|
352
|
+
rollback: () => {
|
|
353
|
+
if (deferredState === "committed") {
|
|
354
|
+
return Promise.reject(new Error(`Cannot roll back deferred upsert ${input.id} after its compiled commit`));
|
|
355
|
+
}
|
|
356
|
+
if (deferredState === "rolled_back")
|
|
357
|
+
return Promise.resolve([]);
|
|
358
|
+
if (rollbackPromise !== undefined)
|
|
359
|
+
return rollbackPromise;
|
|
360
|
+
deferredState = "rolling_back";
|
|
361
|
+
rollbackPromise = saga.rollback().then((failures) => {
|
|
362
|
+
deferredState = "rolled_back";
|
|
363
|
+
return failures;
|
|
364
|
+
});
|
|
365
|
+
return rollbackPromise;
|
|
366
|
+
},
|
|
367
|
+
};
|
|
368
|
+
return {
|
|
369
|
+
content: [
|
|
370
|
+
{
|
|
371
|
+
type: "text",
|
|
372
|
+
text: `Prepared ${input.id} for a batched proof commit.`,
|
|
373
|
+
},
|
|
374
|
+
],
|
|
375
|
+
structuredContent: {
|
|
376
|
+
created: 0,
|
|
377
|
+
updated: 0,
|
|
378
|
+
relationships_created: validated.relationships.length,
|
|
379
|
+
warnings: semantic.warnings,
|
|
380
|
+
semanticAdvisor: semantic.receipt,
|
|
381
|
+
deferredCommit,
|
|
382
|
+
...(sourceWrite ? { sourceWrites: [sourceWrite.receipt] } : {}),
|
|
383
|
+
},
|
|
384
|
+
};
|
|
385
|
+
}
|
|
332
386
|
const transaction = buildUpsertCommitGoal({
|
|
333
387
|
entity: commitEntity ?? validated.entity,
|
|
334
388
|
relationships: validated.relationships,
|
|
@@ -349,6 +403,15 @@ export async function executeUpsert(input, context, options = {}) {
|
|
|
349
403
|
}
|
|
350
404
|
const coverage = await scenarioCoverageWarnings(prolog, validated.relationships, input.type, input.id);
|
|
351
405
|
const created = changeKind === "created" ? 1 : 0;
|
|
406
|
+
const idStyleWarnings = created === 1
|
|
407
|
+
? entityIdStyleWarnings({
|
|
408
|
+
id: input.id,
|
|
409
|
+
sourcePath: sourceWrite?.receipt.path ??
|
|
410
|
+
(typeof validated.entity.source === "string"
|
|
411
|
+
? validated.entity.source
|
|
412
|
+
: undefined),
|
|
413
|
+
})
|
|
414
|
+
: [];
|
|
352
415
|
const shardWarnings = [];
|
|
353
416
|
const relationshipSourceWrites = [];
|
|
354
417
|
for (const [shardPath, before] of relationshipShardBefore) {
|
|
@@ -382,7 +445,12 @@ export async function executeUpsert(input, context, options = {}) {
|
|
|
382
445
|
created,
|
|
383
446
|
updated: changeKind === "updated" ? 1 : 0,
|
|
384
447
|
relationships_created: validated.relationships.length,
|
|
385
|
-
warnings: [
|
|
448
|
+
warnings: [
|
|
449
|
+
...semantic.warnings,
|
|
450
|
+
...coverage,
|
|
451
|
+
...idStyleWarnings,
|
|
452
|
+
...shardWarnings,
|
|
453
|
+
],
|
|
386
454
|
semanticAdvisor: semantic.receipt,
|
|
387
455
|
...(shardWarnings.length > 0
|
|
388
456
|
? {
|
|
@@ -480,7 +548,7 @@ export async function executeUpsert(input, context, options = {}) {
|
|
|
480
548
|
}
|
|
481
549
|
const coordinateFailure = rollbackFailures.find((failure) => failure.step === "symbol-coordinates");
|
|
482
550
|
if (coordinateFailure !== undefined) {
|
|
483
|
-
const failure = new
|
|
551
|
+
const failure = new MutationRollbackFailureError([error, coordinateFailure.error], `Upsert failed and coordinate artifact rollback failed for ${input.id}`, rollbackFailures);
|
|
484
552
|
operationFailure = { error: failure };
|
|
485
553
|
throw failure;
|
|
486
554
|
}
|
|
@@ -489,7 +557,7 @@ export async function executeUpsert(input, context, options = {}) {
|
|
|
489
557
|
const rollbackMessage = sourceFailure.error instanceof Error
|
|
490
558
|
? sourceFailure.error.message
|
|
491
559
|
: String(sourceFailure.error);
|
|
492
|
-
const failure = new
|
|
560
|
+
const failure = new MutationRollbackFailureError([error, sourceFailure.error], `Upsert failed and authored source rollback failed for ${input.id}: ${rollbackMessage}`, rollbackFailures);
|
|
493
561
|
operationFailure = { error: failure };
|
|
494
562
|
throw failure;
|
|
495
563
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validate-upsert.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/validate-upsert.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validate-upsert.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/validate-upsert.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,gBAAgB,EAEjB,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kCAAkC,CAAC;AAcxE,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAerE,wBAAsB,qBAAqB,CACzC,KAAK,EAAE,WAAW,EAClB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,eAAe,CAAC,qBAAqB,CAAC,CAAC,CAoGjD"}
|
|
@@ -1,9 +1,18 @@
|
|
|
1
|
+
// implements REQ-kibi-operation-interface-parity
|
|
2
|
+
import { escapeAtom } from "../../prolog/codec.js";
|
|
3
|
+
import { entityIdStyleWarnings } from "../../utils/entity-id-style.js";
|
|
1
4
|
import { analyzeSemanticAdvisorInput } from "../semantic-advisor/analyze-prose.js";
|
|
2
5
|
import { assertLogicalGroundingClaimKeys, assertSemanticInventoryBoundary, validateSemanticInventoryBoundary, } from "../semantic-advisor/ingestion-boundary.js";
|
|
6
|
+
import { assertPredicateArgumentVocabulary } from "./predicate-vocabulary-guard.js";
|
|
3
7
|
import { validateLiveRelationshipTargets, validateRelationshipSources, } from "./relationships.js";
|
|
4
8
|
import { validateSymbolGranularity } from "./symbol-granularity.js";
|
|
5
9
|
import { effectiveRelationships, validateAppendOnlyProofReceipts, } from "./upsert.js";
|
|
6
10
|
import { validateUpsertInput } from "./validation.js";
|
|
11
|
+
// implements REQ-kibi-entity-id-style
|
|
12
|
+
async function entityExists(prolog, id) {
|
|
13
|
+
const result = await prolog.query(`once(kb_entity('${escapeAtom(id)}', _Type, _Props))`);
|
|
14
|
+
return result.success;
|
|
15
|
+
}
|
|
7
16
|
export async function executeValidateUpsert(input, context) {
|
|
8
17
|
try {
|
|
9
18
|
const validated = validateUpsertInput(input, context.clock());
|
|
@@ -26,11 +35,25 @@ export async function executeValidateUpsert(input, context) {
|
|
|
26
35
|
assertSemanticInventoryBoundary({ ...input, relationships }, relationships, semantic.receipt);
|
|
27
36
|
if (context.prolog !== undefined) {
|
|
28
37
|
await assertLogicalGroundingClaimKeys(context.prolog, { ...input, relationships }, relationships);
|
|
38
|
+
await assertPredicateArgumentVocabulary(context.prolog, validated.entity);
|
|
29
39
|
}
|
|
40
|
+
// Style warnings apply only to entities this upsert would create, so the
|
|
41
|
+
// existence read happens only when the ID actually has a style issue.
|
|
42
|
+
const candidateIdStyleWarnings = entityIdStyleWarnings({
|
|
43
|
+
id: input.id,
|
|
44
|
+
sourcePath: typeof validated.entity.source === "string"
|
|
45
|
+
? validated.entity.source
|
|
46
|
+
: undefined,
|
|
47
|
+
});
|
|
48
|
+
const idStyleWarnings = candidateIdStyleWarnings.length > 0 &&
|
|
49
|
+
context.prolog &&
|
|
50
|
+
!(await entityExists(context.prolog, input.id))
|
|
51
|
+
? candidateIdStyleWarnings
|
|
52
|
+
: [];
|
|
30
53
|
const payload = {
|
|
31
54
|
valid: true,
|
|
32
55
|
errors: [],
|
|
33
|
-
warnings: semantic.warnings,
|
|
56
|
+
warnings: [...semantic.warnings, ...idStyleWarnings],
|
|
34
57
|
semanticAdvisor: semantic.receipt,
|
|
35
58
|
normalizedPreview: validated.entity,
|
|
36
59
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/validation.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,0BAA0B,EAC3B,MAAM,oCAAoC,CAAC;AAO5C,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/operations/mutation/validation.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,0BAA0B,EAC3B,MAAM,oCAAoC,CAAC;AAO5C,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AA6F/D,wBAAgB,mBAAmB,CACjC,KAAK,EAAE,WAAW,EAClB,GAAG,EAAE,IAAI,GACR,eAAe,CA4DjB;AAED,OAAO,EAAE,0BAA0B,EAAE,CAAC"}
|
|
@@ -11,7 +11,19 @@ const schema = entitySchema;
|
|
|
11
11
|
const properties = schema.properties !== null && typeof schema.properties === "object"
|
|
12
12
|
? schema.properties
|
|
13
13
|
: {};
|
|
14
|
-
|
|
14
|
+
// Compiled on first mutation: every CLI command imports this module, and
|
|
15
|
+
// most never validate an upsert.
|
|
16
|
+
let entityValidator;
|
|
17
|
+
let relationshipValidator;
|
|
18
|
+
function entitySchemaValidator() {
|
|
19
|
+
entityValidator ??= ajv.compile(upsertEntitySchema);
|
|
20
|
+
return entityValidator;
|
|
21
|
+
}
|
|
22
|
+
function relationshipSchemaValidator() {
|
|
23
|
+
relationshipValidator ??= ajv.compile(relationshipSchema);
|
|
24
|
+
return relationshipValidator;
|
|
25
|
+
}
|
|
26
|
+
const upsertEntitySchema = {
|
|
15
27
|
...schema,
|
|
16
28
|
properties: {
|
|
17
29
|
...properties,
|
|
@@ -27,8 +39,7 @@ const validateEntity = ajv.compile({
|
|
|
27
39
|
},
|
|
28
40
|
symbol_role: { type: "string", enum: [...SYMBOL_ROLES] },
|
|
29
41
|
},
|
|
30
|
-
}
|
|
31
|
-
const validateRelationship = ajv.compile(relationshipSchema);
|
|
42
|
+
};
|
|
32
43
|
const ALIASES = new Map([
|
|
33
44
|
["subjectKey", "subject_key"],
|
|
34
45
|
["propertyKey", "property_key"],
|
|
@@ -83,6 +94,7 @@ export function validateUpsertInput(input, now) {
|
|
|
83
94
|
entity.created_at ??= now.toISOString();
|
|
84
95
|
entity.updated_at ??= now.toISOString();
|
|
85
96
|
entity.source ??= "mcp://kibi/upsert";
|
|
97
|
+
const validateEntity = entitySchemaValidator();
|
|
86
98
|
if (!validateEntity(entity)) {
|
|
87
99
|
throw new Error(`Entity validation failed: ${formatEntityErrors(entity, validateEntity.errors ?? [])}`);
|
|
88
100
|
}
|
|
@@ -105,6 +117,7 @@ export function validateUpsertInput(input, now) {
|
|
|
105
117
|
}
|
|
106
118
|
}
|
|
107
119
|
const relationships = input.relationships ?? [];
|
|
120
|
+
const validateRelationship = relationshipSchemaValidator();
|
|
108
121
|
relationships.forEach((relationship, index) => {
|
|
109
122
|
if (!validateRelationship(relationship)) {
|
|
110
123
|
const details = (validateRelationship.errors ?? [])
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apply-plan.d.ts","sourceRoot":"","sources":["../../../src/operations/planning/apply-plan.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"apply-plan.d.ts","sourceRoot":"","sources":["../../../src/operations/planning/apply-plan.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AAGjF,OAAO,EACL,KAAK,eAAe,EAIrB,MAAM,uBAAuB,CAAC;AAwB/B,OAAO,KAAK,EACV,aAAa,EACb,eAAe,EAGhB,MAAM,uBAAuB,CAAC;AAE/B,YAAY,EACV,aAAa,EACb,eAAe,EACf,kBAAkB,GACnB,MAAM,uBAAuB,CAAC;AAG/B,eAAO,MAAM,yBAAyB,EAAG,2BAAoC,CAAC;AAmI9E,wBAAgB,iCAAiC,CAC/C,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAChB,IAAI,CAMN;AAED,wBAAgB,mCAAmC,CACjD,SAAS,EAAE,SAAS;IAAE,EAAE,EAAE,MAAM,CAAC;IAAC,SAAS,CAAC,EAAE,SAAS,MAAM,EAAE,CAAA;CAAE,EAAE,EACnE,OAAO,EAAE,WAAW,CAAC,MAAM,CAAC,GAC3B,IAAI,CAaN;AAED,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,SAAS,eAAe,EAAE,EACnC,SAAS,cAAoB,GAC5B,eAAe,EAAE,CA2CnB;AAy+CD,wBAAsB,gBAAgB,CACpC,IAAI,EAAE,aAAa,EACnB,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC;IACT,OAAO,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/C,iBAAiB,EAAE,eAAe,CAAC;CACpC,CAAC,CA2BD"}
|