3.6 KiB
3.6 KiB
Built-In Modules
Purpose
Describes implemented built-in module behavior and boundaries in
internal/builtin.
Implemented module set
Input reader:
json-files
Preprocessing:
validate-rawnormalize-speakerstrim-text
Merger:
chronological-merge
Postprocessing:
detect-overlapsresolve-overlapsbackchannelfillerresolve-danglerscoalesceautocorrectassign-idsvalidate-output
Output writer:
json
Inputs, outputs, and side effects
json-files: reads JSON files fromcfg.InputFiles, parses supported segment/word fields, emits warnings for untimed words.validate-raw: validates raw source/timing invariants.normalize-speakers: converts raw transcripts to canonical segments, optionally resolving speakers fromcfg.SpeakersFile.trim-text: trims canonical segment text whitespace.chronological-merge: flattens canonical segments and applies deterministic sort (model.SegmentLess).detect-overlaps: annotates overlap groups.resolve-overlaps: rewrites overlap groups using timed words and thresholds.backchannel/filler: classify short utterances using duration thresholds.resolve-danglers: merges dangling derived fragments.coalesce: merges adjacent same-speaker segments within configured gap.autocorrect: applies YAML replacement rules when configured.assign-ids: assigns final sequential IDs.validate-output: validates selected public artifact shape.json: writes artifact JSON tocfg.OutputFile.
Filesystem side effects are limited to:
- reading configured input/YAML files
- writing configured output artifact
Config fields used
Primary module inputs from config.Config:
- file paths:
InputFiles,SpeakersFile,AutocorrectFile,OutputFile - schema/modules:
OutputSchema,OutputModules - overlap/coalesce thresholds:
OverlapWordRunGap,WordRunReorderWindow,CoalesceGap - category thresholds:
BackchannelMaxDuration,FillerMaxDuration
Ordering constraints
- Preprocessing must satisfy state contracts from
rawtocanonical. - Order-sensitive transforms should run before
assign-ids. validate-outputshould run after final ID assignment and output-shape mutations.- Default configuration includes a second
detect-overlapspass after transformations.
Boundaries
- Modules implement behavior; CLI/config parsing remains outside modules.
- Modules communicate through explicit model contracts and report events.
- Output modules operate on final artifacts and do not re-run transform logic.
Failure behavior
Representative failures:
- invalid input JSON shape or typed field errors (
json-files) - invalid YAML or unmatched speaker map entries
- unknown module names during registry resolution
- invalid ordering/state transitions in preprocessing chain
- validation failure in
validate-output - output write failure in
jsonwriter
Tests to inspect before changes
internal/builtin/preprocess_test.gointernal/builtin/postprocess_test.gointernal/overlap/resolve_test.gointernal/overlap/detect_test.gointernal/coalesce/coalesce_test.gointernal/danglers/danglers_test.gointernal/backchannel/backchannel_test.gointernal/filler/filler_test.gointernal/autocorrect/autocorrect_test.gointernal/cli/merge_test.go
Invariants
- Modules are selected by canonical name through the registry.
- Execution is sequential and deterministic for a fixed configuration.
assign-idsdefines final public segment IDs.validate-outputenforces public artifact contracts throughschema.