Tutorials › Pharmacometric Workflows and Reproducible Modeling › Capturing Run Metadata in Diagnostic Reports

Automating Diagnostics and Reports · Tutorial 279 of 399

Capturing Run Metadata in Diagnostic Reports

Define a run-level metadata record, link it unambiguously to report artifacts, and check that the recorded provenance is complete and consistent.

Intermediate 11 min read

What You'll Learn

  • Distinguish run-level metadata from artifact-level identifiers and timestamps.
  • Specify stable model and dataset identifiers that support traceability.
  • Represent estimation status and analysis labels without concealing failed or incomplete runs.
  • Link each report artifact to exactly one metadata record using a run identifier.
  • Calculate metadata completeness and diagnose ambiguous or stale provenance.
  • Compare embedded metadata with filenames and sidecar manifests.

Why diagnostic outputs need run metadata

A diagnostic plot or table can be numerically correct and still be difficult to interpret later if its origin is unclear. A filename such as residuals-final.png does not establish which model, dataset, estimation attempt, or analysis scenario produced it. In a reproducible workflow, provenance is not a guess made from the surrounding folder; it is recorded and checked as part of producing the report.

The earlier material on the standard diagnostic report specification, mapping model outputs to report artifacts, canonical diagnostic data schemas, and normalizing residual and prediction outputs establishes what report artifacts contain and how their data are represented. This tutorial focuses on a separate question: what information must travel with an artifact so that a reviewer can identify the run behind it?

Definition: Run metadata is a set of recorded attributes that identifies the model execution and analysis context associated with a report. Artifact provenance is the traceable link from a particular output, such as a plot, table, or report file, to that run metadata. A run identifier is a unique key for one execution and its associated metadata record.

Specify the metadata before generating artifacts

A useful run record contains the required fields named in the focus of this tutorial, represented consistently rather than inferred after the fact. The model identifier should identify the model definition used; where a model can change while retaining a familiar name, include a model version or source digest as well. The dataset version should identify an immutable data snapshot, such as a controlled release identifier or a checksum-backed version. A mutable label such as “latest” is not sufficient to reproduce which data were analyzed.

Record the run date as an unambiguous timestamp, preferably in UTC and a machine-readable form such as 2026-10-14T09:32:00Z. This is the time the run began, not necessarily the time a report file was rendered. If the rendering time matters, store it separately as an artifact-generation timestamp. Keeping those events distinct prevents a report regenerated later from appearing to describe a new estimation run.

Estimation status should describe the estimation attempt, not the visual quality of the report. Use a defined vocabulary, for example converged, terminated_nonconverged, failed, not_run, or unknown. The workflow must specify what each value means and retain the actual status even when estimation fails. An output created from a failed or nonconverged run must not be relabelled as successful merely because a plot rendered.

Analysis labels identify intended context that is not already conveyed by the model and dataset identifiers. Examples include an analysis name, population, study, scenario, or occasion. Store labels as explicit fields or as a structured set of label-value pairs. Use controlled, consistent values where possible: “high_dose” and “High dose” should not accidentally become distinct groups if they mean the same scenario.

In practice, the run record also needs its unique run identifier. The identifier connects the metadata record to each output and prevents two executions with the same model and dataset from being mistaken for one another. It should be stable once assigned and should not be recycled for a later execution.

Key takeaway: At minimum, each artifact should be traceable to a unique run identifier and, through that identifier, to the model identifier, dataset version, run date, estimation status, and analysis labels. Store artifact type and generation time at the artifact level when they differ across outputs from the same run.

Link records without creating ambiguity

A clean design separates one run-level record from the many artifacts it may produce. The run table has one row per run identifier. The artifact table has one row per artifact and includes that identifier as a reference. This avoids repeating and potentially changing run-level fields independently in every file. It also supports a validation rule: every artifact’s run identifier must match exactly one run record.

$$ \text{Artifact}_i.\text{run\_id} \longrightarrow \text{RunMetadata}[\text{run\_id}] $$

The arrow expresses a lookup, not a statistical relationship: the artifact’s run identifier selects its metadata record. If that identifier matches zero records, provenance is missing. If it matches more than one, provenance is ambiguous. A report consumer should be able to make the lookup without relying on file ordering, folder names, or assumptions about which run was “current.”

Worked Example: Attaching One Run Record to Several Outputs

Suppose a hypothetical diagnostic workflow produces a population plot and a residual summary table from one estimation run. The run record is: run_id R-041; model identifier PK_two_compartment, version 2.3; dataset version D-2026-04; run date 2026-10-14T09:32:00Z; estimation status converged; analysis labels population=adult and scenario=standard_dose.

The workflow emits two artifacts: A-101, a population diagnostic plot, and A-102, a residual summary table. Each artifact row stores its own artifact identifier and type, plus run_id R-041. The lookup for either row selects the same single run record:

$$ \text{metadata}(A\text{-}101) = \text{metadata}(A\text{-}102) = \text{RunMetadata}[\text{R-041}] $$

Thus both outputs inherit the same model, dataset, date, status, and analysis labels. If the plot is rendered at 10:05 UTC and the table at 10:06 UTC, those are artifact-generation times; they do not replace the run date of 09:32 UTC. This distinction lets a reviewer tell that the files were regenerated from the same estimation attempt.

Check completeness and uniqueness

A metadata record is complete only when every required field is present and valid under the workflow’s conventions. Presence alone is not enough: an empty string for dataset version is not an identifiable version, and a date that cannot be parsed is not a usable run timestamp. Define the required fields before running validation, then test each record and artifact reference against them.

A simple field-level completeness rate is the number of valid required metadata cells divided by the total number of required cells examined. This summary can help monitor a batch, but it does not replace record-level checks. One completely missing record may be hidden by many complete records, so report the affected artifact and field as well as any aggregate rate.

Worked Example: Quantifying Missing Metadata

A hypothetical report contains five artifacts. For each artifact, the workflow requires five metadata fields: model identifier, dataset version, run date, estimation status, and analysis label. There are \(5 \times 5=25\) required field cells. Inspection finds that 23 cells contain valid values; one artifact lacks its dataset version and another lacks its analysis label.

The field-level completeness rate is:

$$ \text{Completeness} = \frac{\text{valid required cells}}{\text{required cells}} = \frac{23}{25} = 0.92 $$

The batch is therefore 92% complete by this measure, but two artifacts still fail the required-field check. The correct action is to identify those artifacts and repair or explicitly mark their provenance as unavailable according to the workflow’s policy. Reporting only “92% complete” would conceal which outputs cannot be traced fully.

A further check is uniqueness: each run identifier must occur on exactly one run-level record. This condition justifies the metadata lookup. If a key is duplicated, the same artifact could join to multiple records, multiplying rows or assigning conflicting metadata. The issue is structural, not cosmetic; a report that happens to display one of the matching records is not reliably traceable.

Worked Example: Detecting a Duplicate Run Identifier

Consider two run records with run_id R-052. One says dataset version D-2026-05 and the other says D-2026-06. A diagnostic artifact A-208 refers to R-052. The lookup now has two matches:

$$ \left|\{r:r.\text{run\_id}=\text{R-052}\}\right|=2 $$

The required count is exactly 1, so the artifact cannot be assigned a dataset version from its run identifier alone. For example, joining A-208 to both records creates two joined rows, one for each dataset version; choosing either row arbitrarily would create unsupported provenance. The workflow should stop the report from being labelled as valid until the duplicate is resolved, for example by correcting a keying error or assigning distinct identifiers to the two executions. It must not silently select the most recent record unless that selection rule is explicitly part of a validated identifier design.

Why the one-to-one lookup condition matters

The metadata-linking rule follows directly from the structure of the records. Let \(a_i\) be an artifact with run identifier \(k_i\), and let \(R(k)\) be the set of run records whose identifier equals \(k\). For the artifact to have a single, unambiguous provenance record, the set selected by its key must contain exactly one record:

$$ |R(k_i)|=1 $$

If \(|R(k_i)|=0\), no metadata can be retrieved. If \(|R(k_i)|>1\), more than one candidate exists. Only when the cardinality is 1 does the lookup return a unique record, so every run-level field has one defined value for that artifact. This is why both reference integrity (no unmatched artifacts) and uniqueness (no duplicated run records) are necessary; checking only that a run identifier is nonempty does not establish provenance.

1
Create the run record.
Assign a unique run identifier and record the model, immutable dataset version, UTC run date, estimation status, and analysis labels before report files are distributed.
2
Register each artifact.
Record an artifact identifier and type, its run identifier, and any artifact-specific generation time or file location.
3
Validate the link and fields.
Check required values, parseable dates, allowed status values, unique run identifiers, and exactly one matching run record per artifact.
4
Preserve the recorded state.
Keep the metadata with the output in a durable form and retain failed or nonconverged status rather than rewriting history after report generation.

Diagnostics, alternatives, and limitations

Useful workflow diagnostics include counts of artifacts with missing run identifiers, identifiers with no match or multiple matches, missing required fields, unparseable timestamps, and values outside the status vocabulary. Also compare the run-level fields across artifacts linked to the same run: they should resolve to the same record. These checks catch common problems such as metadata copied from a previous run, a changed dataset label paired with a stale checksum, and an output file written before its run record was registered.

Filenames and plot captions can make metadata visible to a human, but they are poor substitutes for a structured run record. Filenames are often shortened, manually edited, or duplicated; captions may omit fields or become detached from the underlying data. A sidecar manifest can provide structured metadata when the artifact format cannot embed it. The strongest practical approach is often to retain a machine-readable manifest keyed by artifact and run identifiers, while displaying a concise provenance summary in the report itself.

Embedding all fields in every artifact can make files self-describing, but repeated copies can drift when one copy is updated and others are not. A central manifest reduces duplication but depends on preserving the manifest and maintaining stable references to it. Either approach requires validation and durable storage. A checksum can help verify that a file has not changed, but by itself it does not establish which model or dataset produced that file. Similarly, a label such as “converged” records the workflow’s status classification; it does not prove that the model is scientifically adequate.

Metadata also cannot recover information that was never captured. If the dataset version points to a mutable location, or if analysis labels are vague, the record may be internally complete but practically insufficient. Define identifiers and allowed values in advance, preserve the referenced model and dataset versions, and treat unknown information as unknown rather than filling it by inference.

Common mistake

A common mistake is to use the report creation date as the run date and to infer the dataset version from the current input folder. The reasoning is that the report was generated from those inputs, so the surrounding context must still identify them. The correction is to record the run timestamp and immutable dataset version when the run occurs, then link later-generated artifacts to that run record. A report regenerated next week can then retain the original estimation provenance while recording its own generation time.

Check Your Understanding

Answer each question, then compare your reasoning with the solutions.

  1. A plot is generated from a run that began at 08:00 UTC, but the plot is rendered at 08:12 UTC. Which time is the run date, and what should 08:12 represent?
  2. Three required metadata fields are present and valid, but the dataset version is an empty string. Is the record complete? Why?
  3. An artifact’s run identifier matches no run record. What does this imply, and what should validation do?
  4. Why is a duplicated run identifier a problem even if both records have the same model identifier?
  5. A run has status terminated_nonconverged, but a diagnostic plot was produced successfully. What status should the artifact’s run metadata show?

Solutions. (1) The run date is 08:00 UTC; 08:12 is the artifact-generation time. (2) No. The dataset version is required, and an empty string does not identify an immutable data snapshot. (3) Provenance cannot be resolved; validation should flag the unmatched artifact and prevent it from being presented as fully traceable. (4) The identifier no longer selects exactly one record, so a lookup may be ambiguous even if one field agrees; the other metadata may conflict. (5) It should retain terminated_nonconverged. Successful rendering does not change the estimation outcome.

Clinical Biostats