Skip to content

Refactor/s2 project params - #70

Merged
natashaannn merged 8 commits into
mainfrom
refactor/s2-project-params
May 13, 2026
Merged

Refactor/s2 project params#70
natashaannn merged 8 commits into
mainfrom
refactor/s2-project-params

Conversation

@natashaannn

Copy link
Copy Markdown
Member

Summary

  • Typed PipelineParams — replaced the open-ended [key: string]: unknown index signature in scripts/config/project.ts with specific optional fields (timestamp_offset, diarization_seed, num_speakers, sync_window_seconds), matching the schema in docs/PRODUCTION_REFACTOR_PLAN.md. Downstream phases can now rely on typed, named fields from readProject().params.
  • Project-file-sourced paramsdiarize-audio.js reads num_speakers, and transcribe-audio.js / edit-transcript.js read timestamp_offset from .ragtech/project.json before falling back to CLI flags. Rerunning any of these scripts no longer requires repeating the flags.
  • CLI flags still work as overrides — existing usage with --num-speakers or --timestamp-offset is unchanged; the flag takes precedence over the project file.
  • Integration tests added — 6 tests verify the project-file-first resolution order, the absence-fallback, and CLI override behavior by spawning the actual entrypoints against a temp project file.

How to review

  • scripts/config/project.tsPipelineParams fields should match the spec in docs/PRODUCTION_REFACTOR_PLAN.md §Layer 1 exactly (field names, types, all optional).
  • scripts/diarize/diarize-audio.jsreadProjectParams() helper and updated resolveArgs(). Verify resolution order: cli.numSpeakers ?? projectParams.num_speakers ?? null.
  • scripts/transcribe/transcribe-audio.js — same pattern for timestamp_offset. Verify cli.timestampOffset ?? projectParams.timestamp_offset ?? 0.
  • scripts/edit-transcript.js — same pattern; also check three pre-existing dead-code removals (OUTRO_DURATION_SECS, actualEnd, baseStart) that were blocking the linter.
  • tests/integration/project-params-entrypoints.test.ts — 6 tests that spawn the real entrypoints in a temp dir. Confirm they exercise all three resolution paths.
  • tests/integration/project.test.ts — 3 new tests for the typed params roundtrip. Confirm roundtrip with partial params covers the optional-field case.

Test plan

  • npm test passes (15 suites, 272 tests)
  • tsc --noEmit clean

Manual verification completed:

  • npm run transcribe -- --audio <file> with params.timestamp_offset: 0.5 in project.json prints Offset: -0.5s without --timestamp-offset flag
  • npm run diarize -- --audio <file> with params.num_speakers: 3 prints Speakers: 3 (locked) without --num-speakers flag

🤖 Generated with Claude Code

Issues

Closes #16

natashaannn and others added 8 commits May 13, 2026 17:37
Replace the open-ended index signature with specific optional fields:
timestamp_offset, diarization_seed, num_speakers, sync_window_seconds.

These are the three params the refactor plan calls out as needing to live
in project.json rather than transient CLI flags. Downstream pipeline scripts
can now read readProject().params and get a typed, predictable shape.

AC: PipelineParams shape matches docs/PRODUCTION_REFACTOR_PLAN.md spec.
Update SAMPLE fixture to use the new typed fields (timestamp_offset,
diarization_seed, num_speakers, sync_window_seconds) replacing the old
open-ended seed key that no longer satisfies the typed interface.

Add two new integration tests:
- roundtrip preserves all deterministic pipeline params: verifies each field
  survives a write/read cycle with correct value and type
- roundtrip with partial params: verifies optional fields are preserved as
  undefined when omitted (partial project files must stay valid)

AC: read/write params roundtrip verified for all typed fields.
Add readProjectParams() helper that reads .ragtech/project.json and
returns the params object, returning {} on any error (file absent or
malformed). This keeps the script self-contained without importing TS.

Resolution order: --num-speakers CLI flag > project.params.num_speakers.
If neither is present, the script exits with a clear error message pointing
the user to the wizard or the flag.

This makes num_speakers reproducible: once the wizard writes it to the
project file, reruns don't need the flag explicitly.

AC: rerunning diarize uses persisted num_speakers from project file.
…llback

Add readProjectParams() helper (same pattern as diarize-audio.js) that
reads .ragtech/project.json, returning {} when the file is absent.

Resolution order: --timestamp-offset CLI flag > project.params.timestamp_offset > 0.
This removes CLI ownership of the value: once the wizard stores it in the
project file, reruns pick it up automatically without needing the flag.

AC: rerunning transcribe uses persisted timestamp_offset from project file.
…nscript

Add readProjectParams() helper that reads .ragtech/project.json, returning
{} when the file is absent or malformed. Resolve timestampOffset using the
same precedence as other entrypoints: CLI flag > project.params.timestamp_offset > 0.

The resolved value is stored in a local variable so all downstream checks
and log statements use the project-sourced value rather than the raw CLI object.

Also remove two dead variable assignments (actualEnd, baseStart) and an
unused constant (OUTRO_DURATION_SECS) that were pre-existing ESLint warnings
blocking the pre-commit hook.

AC: rerunning edit-transcript uses persisted timestamp_offset from project file.
…arams

Inventory: annotate Sprint 1 issue #3 as done on refactor/s2-project-params.

CLAUDE.md: update scripts/config/project.ts row to reflect the typed
PipelineParams interface added in this sprint (timestamp_offset,
diarization_seed, num_speakers, sync_window_seconds).
…rypoints

Pre-push audit identified that readProjectParams() in diarize-audio.js and
transcribe-audio.js was untested. These helpers are private to their entrypoints
so they're verified via observable stdout behavior: the scripts log speaker count
and timestamp offset before attempting diarization/transcription.

Tests cover three cases each:
- param read from project file (no CLI flag present)
- default behavior when project file is absent
- CLI flag takes precedence over project file value
W1: add Phase 3 migration comment to readProjectParams in all three .js
scripts pointing to scripts/config/project.ts as the canonical source.

W2: add 3 integration tests for edit-transcript.js covering project-file
timestamp_offset, absent-file fallback, and CLI override resolution paths.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@natashaannn
natashaannn merged commit 633b00a into main May 13, 2026
1 check passed
@natashaannn
natashaannn deleted the refactor/s2-project-params branch May 13, 2026 10:17
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.

Persist deterministic params in project file

1 participant