feat(pipeline)!: transaction-aware Writer and the Executor→Reader rename#559
Open
ddeboer wants to merge 3 commits into
Open
feat(pipeline)!: transaction-aware Writer and the Executor→Reader rename#559ddeboer wants to merge 3 commits into
ddeboer wants to merge 3 commits into
Conversation
The pipeline input unit is now named for the read side of the familiar Reader/Writer I/O pair: a Reader produces quads for a dataset from outside the pipeline, whether that is a SPARQL endpoint, a dump, or a non-RDF facade. Only the input renames; Writer keeps its name. BREAKING CHANGE: ‘Executor’ is now ‘Reader’ and its ‘execute()’ method is ‘read()’. Renamed accordingly: SparqlConstructExecutor → SparqlConstructReader, SparqlConstructExecutorOptions → SparqlConstructReaderOptions, ExecuteOptions → ReadOptions, ExecutorContext → ReaderContext, AttachedExecutor → AttachedReader (its ‘executor’ property → ‘reader’), StageExecutors → StageReaders, and StageOptions.executors → StageOptions.readers. @lde/pipeline-void re-exports the renamed types.
A Writer is now a factory of per-run transactions: Pipeline.run opens one run (openRun(context) → RunWriter), writes every dataset through it, and ends it with exactly one commit() or abort(error) – the home of run-level lifecycle such as alias swaps, deletion sweeps and cross-pod locks. The pipeline never branches on the writer’s update mode. Stages write through the narrower DatasetWriter, so a stage can never commit or abort the run. RunContext carries runId, startedAt, selectedSources() (complete by commit time, including datasets skipped as unchanged) and the provenance store. Lifecycle-free destinations wrap a per-dataset write with the new perDatasetWriter() helper. FileWriter and SparqlUpdateWriter keep per-run state (open files, cleared graphs) in the run, so re-running a pipeline on the same writer instance replaces output instead of appending – previously a latent bug. FileWriter.commit finalizes files still open; abort discards temp output. Chained (sub-stage) scratch FileWriters are now flushed before their output is resolved. ShaclValidator opens one long-lived run per report writer. See docs/decisions/0006. BREAKING CHANGE: Writer’s per-dataset write/flush/reset moved to the RunWriter returned by the new openRun(context); custom writers implement openRun or wrap their per-dataset write with perDatasetWriter(). Generic payload: Writer<Item = Quad>. Stage.run now takes a DatasetWriter.
Review cleanups on the transactional Writer: - Fan-out commits run concurrently (mirroring abort): destinations are independent, so their alias swaps and sweeps – the slowest part of a run – no longer queue behind each other. Both share one settleBranches helper that rethrows the first failure after every branch had its chance. - A chained stage’s scratch run is now bracketed like any other run: committed on success, aborted on failure – so a failing chained stage no longer leaves a stale temp file behind. - RunWriter.commit documents the driver contract: every written dataset is flushed before commit, so commit-time unflushed writes only occur under direct use and should be finalized non-destructively. - perDatasetWriter forwards flush/reset with bind instead of manual wrapper closures.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First slice of #534 (search as a Configurable Pipeline instance): the
@lde/pipelinecore changes everything else builds on. Design captured in ADR 6.Rename
Executor→Reader(commit 1)The input unit is now named for the read side of the familiar Reader/Writer I/O pair (the Stack’s
source/sink):Executor→Reader,execute()→read(),SparqlConstructExecutor→SparqlConstructReader,ExecutorContext→ReaderContext,AttachedExecutor→AttachedReader,StageOptions.executors→readers. Mechanical;@lde/pipeline-voidre-exports the renamed types,@lde/pipeline-shacl-sampleradapts internally.Transaction-aware
Writer(commit 2)Writerbecomes a factory of per-run transactions, generic over its payload (Writer<Item = Quad>):Pipeline.rundrivesopenRun → write* → commit/abortuniformly and never branches on the writer’s update mode: an alias swap is a private step of a Blue/green writer’scommit(), a deletion sweep of an In-place writer’s.RunContextcarriesrunId,startedAt,selectedSources()(complete by commit time, including datasets skipped as unchanged – the input to a registry-membership sweep) and the provenance store.DatasetWriter, so a stage can never commit or abort the run.perDatasetWriter()– deliberately no secondTransactionalWriterinterface.Ridden-along fixes
FileWriters are now flushed before their output path is resolved – previously the chain resolved a final path that only materialized on a flush nobody issued.FileWriter.commitfinalizes files still open;abortdiscards temp output, never leaving a truncated final file.Breaking changes
Both commits are marked
!. Custom writers implementopenRun(or wrap withperDatasetWriter);Executorcall sites rename. The Dataset Knowledge Graph pipeline adapts on its next@lde/pipelineupgrade.Part of #534 (slice 1 of 4; next:
BlueGreenRebuild/InPlaceRebuildwriters in@lde/search-typesense).