kibi-core 0.22.4 → 0.22.5
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/package.json +1 -1
- package/src/kb.pl +32 -19
package/package.json
CHANGED
package/src/kb.pl
CHANGED
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
kb_commit_upsert/5,
|
|
17
17
|
kb_commit_upsert_batch/2,
|
|
18
18
|
kb_preview_upsert_contradiction/3,
|
|
19
|
+
kb_preview_upsert_contradiction/4,
|
|
19
20
|
kb_log_entity_upsert/3,
|
|
20
21
|
kb_retract_entity/1,
|
|
21
22
|
kb_retract_entity/3,
|
|
@@ -1069,9 +1070,7 @@ kb_commit_upsert(Type, Props, Relationships, SkipContradiction, ChangeKind) :-
|
|
|
1069
1070
|
catch(
|
|
1070
1071
|
rdf_transaction((
|
|
1071
1072
|
kb_stage(rdf_mutation),
|
|
1072
|
-
|
|
1073
|
-
kb_commit_relationships_no_audit(Relationships),
|
|
1074
|
-
kb_maybe_check_req_contradiction(Type, Id, SkipContradiction),
|
|
1073
|
+
kb_stage_upsert_mutation(Type, Id, Props, Relationships, SkipContradiction),
|
|
1075
1074
|
kb_stage(entity_audit),
|
|
1076
1075
|
kb_log_entity_upsert(ChangeKind, Type, Props),
|
|
1077
1076
|
kb_stage(relationship_audit),
|
|
@@ -1101,9 +1100,7 @@ kb_commit_upsert(Type, Props, Relationships, SkipContradiction, ChangeKind) :-
|
|
|
1101
1100
|
upsert_change_kind(Id, ChangeKind),
|
|
1102
1101
|
rdf_transaction((
|
|
1103
1102
|
kb_stage(rdf_mutation),
|
|
1104
|
-
|
|
1105
|
-
kb_commit_relationships_no_audit(Relationships),
|
|
1106
|
-
kb_maybe_check_req_contradiction(Type, Id, SkipContradiction),
|
|
1103
|
+
kb_stage_upsert_mutation(Type, Id, Props, Relationships, SkipContradiction),
|
|
1107
1104
|
kb_stage(entity_audit),
|
|
1108
1105
|
kb_log_entity_upsert(ChangeKind, Type, Props),
|
|
1109
1106
|
kb_stage(relationship_audit),
|
|
@@ -1130,35 +1127,51 @@ kb_maybe_check_req_contradiction(req, Id, false) :-
|
|
|
1130
1127
|
check_req_contradiction(Id).
|
|
1131
1128
|
kb_maybe_check_req_contradiction(_, _, _).
|
|
1132
1129
|
|
|
1130
|
+
%% kb_stage_upsert_mutation(+Type, +Id, +Properties, +Relationships, +SkipContradiction)
|
|
1131
|
+
% implements REQ-kibi-operation-interface-parity
|
|
1132
|
+
% The RDF mutation and refusal rules of one upsert, shared by the commit, the
|
|
1133
|
+
% batch commit and the dry-run preview so all three refuse the same payloads:
|
|
1134
|
+
% a relationship whose source or target entity does not exist, an invalid
|
|
1135
|
+
% relationship direction, a symbol mixing executable_for with production
|
|
1136
|
+
% ownership/coverage edges, and (for a requirement) a contradiction.
|
|
1137
|
+
kb_stage_upsert_mutation(Type, Id, Props, Relationships, SkipContradiction) :-
|
|
1138
|
+
kb_assert_entity_no_audit(Type, Props),
|
|
1139
|
+
kb_commit_relationships_no_audit(Relationships),
|
|
1140
|
+
kb_maybe_check_req_contradiction(Type, Id, SkipContradiction).
|
|
1141
|
+
|
|
1133
1142
|
% Stage one upsert inside an already-open transaction. The caller saves once.
|
|
1134
1143
|
kb_stage_upsert(Type, Props, Relationships, SkipContradiction, ChangeKind) :-
|
|
1135
1144
|
memberchk(id=Id, Props),
|
|
1136
1145
|
memberchk(SkipContradiction, [true, false]),
|
|
1137
1146
|
upsert_change_kind(Id, ChangeKind),
|
|
1138
|
-
|
|
1139
|
-
kb_commit_relationships_no_audit(Relationships),
|
|
1140
|
-
kb_maybe_check_req_contradiction(Type, Id, SkipContradiction),
|
|
1147
|
+
kb_stage_upsert_mutation(Type, Id, Props, Relationships, SkipContradiction),
|
|
1141
1148
|
kb_log_entity_upsert(ChangeKind, Type, Props),
|
|
1142
1149
|
kb_commit_relationship_audits(Relationships).
|
|
1143
1150
|
|
|
1144
1151
|
%% kb_preview_upsert_contradiction(+Type, +Properties, +Relationships)
|
|
1152
|
+
%% kb_preview_upsert_contradiction(+Type, +Properties, +Relationships, +SkipContradiction)
|
|
1145
1153
|
% implements REQ-kibi-operation-interface-parity
|
|
1146
|
-
% Stage one upsert in a transaction that is always rolled back and run
|
|
1147
|
-
% commit-time
|
|
1148
|
-
% kb_upsert dry run refuses exactly what the commit would refuse
|
|
1149
|
-
%
|
|
1150
|
-
%
|
|
1151
|
-
%
|
|
1152
|
-
%
|
|
1154
|
+
% Stage one upsert in a transaction that is always rolled back and run every
|
|
1155
|
+
% commit-time refusal rule (kb_stage_upsert_mutation/5) against the staged
|
|
1156
|
+
% KB, so a kb_upsert dry run refuses exactly what the commit would refuse:
|
|
1157
|
+
% missing relationship endpoints, invalid directions, mixed symbol roles and,
|
|
1158
|
+
% unless skipped, requirement contradictions. Nothing is written and nothing
|
|
1159
|
+
% marks the branch dirty: the no-audit assertions only touch the RDF store,
|
|
1160
|
+
% which the transaction rolls back, and no audit entry, snapshot save or
|
|
1161
|
+
% journal flush follows. The entity index is not transactional, so the
|
|
1162
|
+
% staged id is re-indexed from the restored store.
|
|
1153
1163
|
kb_preview_upsert_contradiction(Type, Props, Relationships) :-
|
|
1164
|
+
kb_preview_upsert_contradiction(Type, Props, Relationships, false).
|
|
1165
|
+
|
|
1166
|
+
kb_preview_upsert_contradiction(Type, Props, Relationships, SkipContradiction) :-
|
|
1154
1167
|
memberchk(id=Id, Props),
|
|
1168
|
+
memberchk(SkipContradiction, [true, false]),
|
|
1155
1169
|
with_kb_mutex(
|
|
1156
1170
|
call_cleanup(
|
|
1157
1171
|
catch(
|
|
1158
1172
|
rdf_transaction((
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
kb_maybe_check_req_contradiction(Type, Id, false),
|
|
1173
|
+
kb_stage(rdf_mutation),
|
|
1174
|
+
kb_stage_upsert_mutation(Type, Id, Props, Relationships, SkipContradiction),
|
|
1162
1175
|
throw(kibi_preview_rolled_back)
|
|
1163
1176
|
)),
|
|
1164
1177
|
Caught,
|