Skip to content

feat(pipeline): stamp artifact metadata on JSON outputs - #71

Merged
natashaannn merged 7 commits into
mainfrom
refactor/s2-artifact-metadata
May 14, 2026
Merged

feat(pipeline): stamp artifact metadata on JSON outputs#71
natashaannn merged 7 commits into
mainfrom
refactor/s2-artifact-metadata

Conversation

@natashaannn

@natashaannn natashaannn commented May 14, 2026

Copy link
Copy Markdown
Member

Summary

  • Added stampMetadata() helper in scripts/config/metadata.js that prepends schema_version and tool_versions to any JSON artifact, reading tool versions from .ragtech/project.json when present.
  • Wired 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-array diarization.json format and the new { turns: [...] } object format for backwards compatibility.

How to review

  • scripts/config/metadata.js — new helper; verify schema_version constant, buildToolVersions() reads from .ragtech/project.json with 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 in runAssignment() (lines 166–168); confirm the Array.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 test passes (288 tests across all Jest suites)
  • npm run test:e2e passes (3 smoke tests)

Manual verification completed prior to push:

  • node scripts/diarize/assign-speakers.js — reads legacy array diarization.json (backwards-compat path), assigns speakers, writes stamped transcript.raw.json; output confirmed schema_version: 1 and populated speaker name.

🤖 Generated with Claude Code

Issues

Closes #17

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.
@natashaannn
natashaannn merged commit 8a81d50 into main May 14, 2026
1 check passed
@natashaannn
natashaannn deleted the refactor/s2-artifact-metadata branch May 14, 2026 07:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add schema version and tool version metadata to JSON artifacts

1 participant