Package ai.chatur.cortex.core.branch
Class BranchMergeService
java.lang.Object
ai.chatur.cortex.core.branch.BranchMergeService
Resolves a branch pending review by merging its staged assertions into the default graph or
discarding them.
-
Constructor Summary
ConstructorsConstructorDescriptionBranchMergeService(org.apache.jena.query.Dataset assertions, BranchRepository branchRepository, ProvenanceRecorder provenanceRecorder) Creates the service. -
Method Summary
Modifier and TypeMethodDescriptionorg.apache.jena.rdf.model.ModelMerges the assertions staged on the given branch into the default graph, closing theprovenance activityof the ingestion and recording the reification of every merged statement, linked to the activity, in theprovenance graph, and deletes the branch.voidRejects the given branch, discarding its staged assertions, if it exists.
-
Constructor Details
-
BranchMergeService
public BranchMergeService(org.apache.jena.query.Dataset assertions, BranchRepository branchRepository, ProvenanceRecorder provenanceRecorder) Creates the service.- Parameters:
assertions- the dataset holding the approved assertions and the staged branchesbranchRepository- guards every operation against an unknown branchprovenanceRecorder- builds the provenance recorded when a branch is approved
-
-
Method Details
-
approve
Merges the assertions staged on the given branch into the default graph, closing theprovenance activityof the ingestion and recording the reification of every merged statement, linked to the activity, in theprovenance graph, and deletes the branch.The novelty diff, the merge, and the branch deletion all happen inside one write transaction on the assertions dataset: TDB2 serializes writers, so two branches can never be approved concurrently, and a failure partway through aborts the whole transaction rather than leaving the data merged while the branch is still pending (which used to risk a second, duplicate
prov:Activityon a retried approval). Staged triples that were approved through another branch in the meantime are skipped, so a statement is never merged or reified twice — this is now guaranteed by that same serialization, rather than a best-effort race with the other branch's approval.- Parameters:
branch- the branch name- Returns:
- the newly approved assertions — empty if every staged triple was approved through
another branch in the meantime — or
nullif the branch does not exist
-
reject
Rejects the given branch, discarding its staged assertions, if it exists.- Parameters:
branch- the branch name
-