feat(pipeline): stamp artifact metadata on JSON outputs - #71
Merged
Conversation
Centralized helper that stamps schema_version and tool_versions onto any JSON artifact object before it is written to disk. Reads tool versions from .ragtech/project.json if present; falls back to node version only. Keeps stamping logic in one place so pipeline scripts import rather than duplicate the version-detection code. AC: centralize-if-possible
Covers ARTIFACT_SCHEMA_VERSION constant, buildToolVersions fallback when project.json is absent, stampMetadata field merging, original-field preservation, and array-wrapped artifact shape.
Each pipeline script that writes a JSON artifact now calls stampMetadata()
before fs.writeJson so every output carries schema_version and tool_versions.
Covered artifacts:
- transcript.raw.json (Transcriber.js, Diarizer.assignSpeakers, align-transcript.js)
- diarization.json (Diarizer.js — array wrapped in { turns, schema_version, tool_versions })
- transcript.json (edit-transcript.js)
diarization.json reader updated to accept both legacy array format and the
new object format so runs that have old artifacts on disk continue to work.
AC: functional-metadata, downstream-compat
Pre-push audit identified that the backwards-compat parsing added in
feat(pipeline): stamp artifact metadata on JSON outputs was untested.
Diarizer.runAssignment now accepts both the legacy bare array format
and the new { turns: [...] } object format — tests confirm both paths
assign speakers correctly and that the written transcript is stamped.
…ests W1/W2 from PR review: hardcoded schema_version string and weak toBeDefined() assertions replaced with imported ARTIFACT_SCHEMA_VERSION constant and exact node version check, so tests break if the constant or stamping logic drifts.
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.
Summary
stampMetadata()helper inscripts/config/metadata.jsthat prependsschema_versionandtool_versionsto any JSON artifact, reading tool versions from.ragtech/project.jsonwhen present.stampMetadata()into all four JSON-writing pipeline stages: transcribe, diarize, align, and edit-transcript — satisfying the reproducibility metadata requirement for downstream pipeline caching.Diarizer.runAssignment()now handles both the legacy bare-arraydiarization.jsonformat and the new{ turns: [...] }object format for backwards compatibility.How to review
scripts/config/metadata.js— new helper; verifyschema_versionconstant,buildToolVersions()reads from.ragtech/project.jsonwith graceful fallback, and spread order puts metadata first so artifact fields take precedence.scripts/diarize/Diarizer.js— two changes:stampMetadata({ turns })on write (line 127) and backwards-compat read inrunAssignment()(lines 166–168); confirm theArray.isArray(raw) ? raw : (raw.turns ?? [])guard is correct.scripts/config/metadata.test.js— unit tests; confirm edge cases covered (missing project.json, artifact fields overriding metadata keys, object-wrapped arrays).tests/integration/diarizer-runAssignment.test.ts— integration tests added by pre-push audit; confirm both legacy array format and new object format paths are tested.Test plan
npm testpasses (288 tests across all Jest suites)npm run test:e2epasses (3 smoke tests)Manual verification completed prior to push:
node scripts/diarize/assign-speakers.js— reads legacy arraydiarization.json(backwards-compat path), assigns speakers, writes stampedtranscript.raw.json; output confirmedschema_version: 1and populated speaker name.🤖 Generated with Claude Code
Issues
Closes #17