book/chapters/patterns/code-to-data.qmd
Michael Hanke fc60dd95bf
Some checks failed
Lint / Lint with vale (push) Failing after 28s
Lint / Lint with codespell (push) Successful in 33s
Build and publish / Build site and deploy on success (push) Successful in 1m25s
rf: delete patterns that grew to clode to each other
2026-11-17 15:53:50 +01:00

67 lines
12 KiB
Text

# Pattern — code to data
::: {.callout-note}
Deployment pattern. Follows the fixed template. Coordinate axes are defined once in [Deployment patterns](patterns.qmd) and are not re-explained here.
:::
**Status:** `planned` — every component this shape composes is `available`; the assembly itself is not yet stood up anywhere in the project. TODO — confirm and drop this line once a site runs it.
A *code-to-data* site is one where the analysis goes to the data instead of the other way round. The person who needs the result cannot hold the material — a collection too heavy to copy, or subject data whose governance forbids disclosure — and the party who holds it is willing for the work to happen on it, under review, but not for it to leave. The shape makes that transaction ordinary, reviewable, and reproducible: a pipeline is submitted, approved as a pinned state, executed close to the content, and its products are handed back once someone has read them. Neither party gives up control. The holder never publishes content; the author never runs unreviewed code.
**Position on the coordinate system:** delegated authority — the holder approves each submission, and each approval binds only that state · proxied-from-the-holder resources · gateway over the holder's storage and compute · project or institutional standards · confined data — content addressed and identified, but never disclosed; results are the only egress · human reviewers and machine executors · many small submissions against few large holders
## Context and constraints
Two parties, one hard edge, and everything else follows from the edge.
- **Review must be possible without the data.** Nothing the reviewer reads may depend on content being present, and nothing at execution time may depend on the reviewer having seen it. The submission therefore travels as identity, not as bytes.
- **An approval has to pin inputs, code, and environment together.** A pipeline reviewed against a moving target is not reviewed at all: if the container can be rebuilt from a floating tag or the input dataset can advance, the approved object and the executed object are different objects.
- **Egress is the second half of the deal.** Whatever the run writes back is itself reviewed before the author may read it. Stated plainly, because it is the honest test of the whole posture: a code-to-data site that returns unreviewed artifacts is a data-sharing site with extra steps.
- **Development cannot wait on approvals.** Iterating a pipeline one sanctioned run at a time is unusable, so the holder publishes *surrogate* data — content that stands in for the real thing's structure, formats, and shape without carrying its facts.
## Capabilities composed
- **Submission as an ordinary dataset.** The pipeline, its environment recipes or image references, and its declared inputs form a [DataLad](../reference/roster/datalad.qmd) dataset with nested subdatasets, pushed to [forgejo-aneksajo](../reference/roster/forgejo-aneksajo.qmd). A submission is a repository that can be cloned, diffed, and discussed, not a form with attachments — which is why review rides on the forge's existing conversation surface (a pull request) instead of a bespoke portal.
- **Content-free review, by construction.** Annexed inputs arrive as [git-annex](../reference/roster/git-annex.qmd) pointers. A key states the exact identity of the content and says where copies live, without granting access to any of them. So the reviewed state is precise about *which bytes will be used* while holding none of them — the property the whole shape rests on, and the reason this platform hosts annex repositories with and without their data. See [the data substrate](../concepts/data-substrate.qmd).
- **A pinned, re-runnable environment.** DataLad's actionable provenance is what makes "the reviewed state" a fact rather than an intention: inputs are recorded as independently managed dataset versions, so what ran and what was approved are the same statement. Container images are treated as inputs in exactly that sense — they arrive with their own provenance, or are built on site from recipe files committed alongside.
- **Execution close to the content.** A registered [Forgejo runner](../reference/roster/forgejo-runner.qmd), placed on the holder's infrastructure and scoped to the group permitted to dispatch to it, is the one environment in which a local `git-annex get` can reach the holder's data remote. The orchestration decision — whether, when, and where a job runs — is the foundation's; the runner is the deployable that carries it out, and access to it is governed by the same single identity as access to the data. See [orchestration](../concepts/platform-foundation.qmd) and [workflow execution](../reference/roster/forgejo-runner.qmd). The grant "this code may touch this data" is expressed once, as runner scope plus content availability — never as a per-job exception.
- **Deposition of the products.** The run commits outputs, logs, and captured provenance back into the same substrate, as a dataset state the holder reads before the author is granted access. Returned artifacts are records with stable identifiers like any other output, landing where the rest of the site's records live — see [records & knowledge](../concepts/records-and-knowledge.qmd).
- **Deliberately omitted.** Neither [Dump Things](../reference/roster/dump-things.qmd) nor [shacl-vue](../reference/roster/shacl-vue.qmd) is required to stand this up, nor is [search](../reference/roster/search.qmd). A site that already runs them will find the returned artifacts among its records; a site that does not can still transact. The information model earns nothing special here — this is the substrate and the forge doing their ordinary jobs under an unusual constraint.
## Carrots that carry it
- **Holders agree more often.** Approving one fixed piece of code is a smaller, more recordable decision than releasing a dataset — and it is the sort of decision a review board can actually take, in writing, about something it can read.
- **Authors develop at full speed.** Surrogates let a pipeline be written, tested, and demonstrated to reviewers before any real content is touched, so the submission that reaches approval has already run.
- **One submission, several holders.** Because inputs are addressed by identity rather than by location, the same pipeline state can be pointed at a different holder's remote. The second site is a change of coordinate, not a rewrite — the reason the economics axis reads *many small submissions* here.
- **The audit trail is a by-product.** Every run carries its pinned code, environment, and inputs as git history: the holder's compliance record and the author's reproducibility record are the same object, maintained by nobody as a separate chore.
- **Nothing is copied twice.** Compute next to the data avoids the transfer, the second copy, and the re-copy every time the pipeline changes — which for heavy collections is the difference between a workflow and an expedition.
## Governance
TODO — resolve against a real holder. The decisions this shape forces a site to name:
- **Who approves, and at what granularity.** A named reviewer holding standing authority over the content, plus an author accountable for the code. Whether approval is one person or a two-stage technical-and-ethical process is a site choice, not a platform one.
- **What an approval binds.** The exact reviewed dataset state — the commit pinning inputs, environment, and code. A submission that drifts needs a fresh approval, and the drift is legible as a diff rather than a suspicion.
- **Who owns a returned artifact, and under what terms it may leave.** The products are information derived from material the author never held; that asymmetry has to be settled before the first run, not after the first dispute.
- **The egress rule as policy, not goodwill.** Default to returning only declared output paths, read by a human first. This must be in writing before anyone is granted runner access, because the runner is precisely the capability that could bypass it.
- **Onward reuse of approved parts.** A container built and approved once should become a reusable input rather than something to re-litigate per submission. That accumulation — approvals that stay valid — is what makes a holder's site worth submitting to twice.
## Overlay and federation points
- **The holder's infrastructure is overlaid, never displaced.** Their archive stays a git-annex remote under their own access control; the platform sees keys, and sees content only inside the one execution context the holder grants. This is the posture of [the overlay model](../concepts/overlay-model.qmd) applied to data rather than to compute.
- **Two placements of the same shape, differing only in coordinates.** *Holder-operated*: the forge, the reviewers, and the runner are one institution — delegated authority, gateway over its own storage; this is the variant that is stood up inside constraints by [deploy under hard constraints](../howto/administrators/deploy-under-constraints.qmd). *Author-operated front door*: submissions land on the analyst's site while the holder runs only a content remote and a runner — peer-negotiated. The mechanism is identical in both; nothing here is rewritten when the authority moves.
- **A holder with many studies is a hub.** One submission surface, several scoped runners routing to several collections — the shape narrows to a [node in a data hub](hub-node.qmd) from the author's side.
- **Returned artifacts federate for free.** An output is an ordinary dataset with a stable identifier, so it can be deposited, cited, and — where its own terms allow — shared onward without a second copy being made. This is the *return value* half of [capture once, reuse widely](../orientation/why.qmd), arriving from a direction that looks like the opposite case.
- **Machines are parties here.** The runner and the `git-annex` client are the consumers that actually read the submission and write the result; they are documented as consumers under [API & integration](../reference/api-integration.qmd), and they are not a persona.
## What is hard
- **The second review is the real workload.** Reading returned artifacts for disclosure risk is slower and far less pleasant than reading code, and it is where these workflows actually stall. If nobody is funded to do it, the pattern is decorative.
- **"The key exists but nobody will give it to me."** This is the signature failure of the shape, and it is genuinely hard to diagnose from the consumer side: an untrusted remote, an absent copy, and a correctly withheld one all look identical from where the author sits.
- **Two-phase latency.** Approval before the run and after it. Cycle times of days are typical, and they dominate the author's experience of the platform no matter how good the tooling is.
- **Environments are data.** Images are large, need provenance of their own or an on-site build, and choosing to build on site moves work into exactly the execution window one is trying to keep short.
- **Surrogate drift.** A stand-in that no longer matches the real input's structure yields a pipeline that passes review and fails on the run. Surrogates need a version and a stated tie to what they stand in for — otherwise they quietly rot.
- **Runner scope is a sharp tool.** A group-scoped runner that can reach restricted content is the most valuable and most dangerous object on the site. A mis-scoped runner turns the entire posture into an open share with a review step nobody needed.
- **Queueing, by arithmetic.** Many small submissions against a few large holders concentrates demand on one or two machines. The design has to degrade into "this run waits until tonight" without anybody treating that as a failure.
**Stand it up:** [Operate a code-to-data execution service](../howto/administrators/code-to-data-execution.qmd).