## Phase 74: Themis Music Shield — AI Music Copyright Protection & Originality Verification System

**Purpose:** Build the most comprehensive AI music copyright protection system
in the industry — a multi-engine originality verification and legal risk
mitigation platform that gates every piece of AI-generated music before
publication. Covers melodic, harmonic, rhythmic, spectral, lyric, vocal, and
structural similarity detection with legal risk scoring, human review pipelines,
automatic remediation, model governance, and reference database management. This
is not optional — it is a legal and moral necessity at the scale Oshun operates.

**Scope:** 17 new libraries under `libs/themis/` (TypeScript + Rust WASM hybrid
for performance-critical DSP). Integrates with existing `@nous/audio`
fingerprinting, `@nous/core` similarity search, `@euterpe/theory` music
primitives, `@calliope/voice` anti-similarity, and `@isis/audio-generation`.
Reference proposal: `docs/domains/themis-music-shield-proposal.md`.

**Key Design Principles:**

- **Zero false negatives** — A missed infringement at scale is catastrophic.
  Every engine errs on the side of caution; false positives are handled by human
  review, false negatives are unacceptable.
- **Multi-element compound detection** — Single-element similarity is often
  coincidental; compound similarity across melody + lyrics + harmony targeting
  the same reference work is the true signal.
- **Legally grounded thresholds** — Every threshold is calibrated against actual
  case law outcomes, not arbitrary numbers.
- **Audit everything** — Every generation, every scan, every decision is logged
  with full provenance for legal defense.
- **Prevention > detection** — Model governance and prompt screening prevent
  infringement before it happens; detection engines catch what slips through.

---

### 74.1 Shield Core & Pipeline Orchestration (`@themis/music-shield`)

The central orchestration library that coordinates all scan engines, manages the
scan pipeline, and renders final decisions.

#### 74.1.1 Project Scaffolding & Core Types

- [x] **74.1.1.1** Create `libs/themis/music-shield/` project scaffolding
      (project.json with Nx targets for build/test/lint; package.json as
      `@themis/music-shield`; tsconfig.json extending base; vitest.config.ts;
      src/index.ts barrel export)
- [x] **74.1.1.2** Define core scan request/response types
      (MusicShieldScanRequest with audio data as Float32Array | Uint8Array | URL
      string, optional lyrics text, optional metadata object with
      genre/tempo/key/generationPrompt/ modelId/modelVersion/artistId,
      scanConfig with engines array, jurisdiction array, riskThreshold,
      maxLatencyMs; MusicShieldScanResult with overallRisk as RiskLevel enum,
      overallScore 0-1, confidence 0-1, elementScores object with
      melody/lyrics/vocal/harmony/spectral/structure/rhythm each as
      ElementScore, matches array of SimilarityMatch, provenance as
      ProvenanceRecord, recommendations array, scanDurationMs)
- [x] **74.1.1.3** Define RiskLevel enum and ElementScore types (RiskLevel:
      'pass' | 'advisory' | 'flag' | 'high_risk' | 'reject' with numeric
      thresholds — pass < 0.20, advisory 0.20-0.35, flag 0.35-0.55, high_risk
      0.55-0.80, reject > 0.80; ElementScore with score 0-1, confidence 0-1,
      matchedWorks array, topMatchScore, topMatchWorkId, engine name string,
      scanDurationMs, warnings array)
- [x] **74.1.1.4** Define SimilarityMatch type (referenceWorkId, referenceTitle,
      referenceArtist, copyrightHolder, isrc/iswc codes, matchedElements array
      each with elementType/score/confidence/timeSegments, compoundScore with
      non-linear escalation, legalRiskAssessment natural language string,
      jurisdiction-specific risk map, timeSegments array with queryStartMs/
      queryEndMs/referenceStartMs/referenceEndMs/matchType)
- [x] **74.1.1.5** Define ScanEngine interface (name string, version string,
      scan method accepting audio + config returning ElementScore, healthCheck
      method, getCapabilities returning supported element types, estimateLatency
      for a given audio duration)
- [x] **74.1.1.6** Define ShieldConfiguration type (enabledEngines array with
      per-engine config, globalThresholds per RiskLevel, jurisdictions array,
      maxScanLatencyMs, parallelEngineLimit, retryPolicy with maxRetries and
      backoffMs, cacheTtlMs for recent scan results, auditLevel 'minimal' |
      'standard' | 'verbose')

#### 74.1.2 Scan Pipeline Orchestration

- [x] **74.1.2.1** Implement MusicShieldPipeline class (constructor takes
      ShieldConfiguration and array of ScanEngine instances; scan method
      orchestrates the full pipeline — audio preprocessing → parallel engine
      dispatch → result aggregation → risk scoring → decision → provenance
      logging; supports abort via AbortSignal; emits progress events via
      EventEmitter for each engine completion)
- [x] **74.1.2.2** Implement audio preprocessing stage (validate input audio —
      check format/sample rate/duration/channel count; normalize to mono 44.1kHz
      Float32Array; compute audio duration and reject if < 5s or > 30min with
      appropriate errors; extract basic audio features — RMS energy, peak level,
      silence detection; cache preprocessed audio for reuse across engines)
- [x] **74.1.2.3** Implement parallel engine dispatch (launch all enabled
      engines concurrently with Promise.allSettled; respect parallelEngineLimit
      using a semaphore/pool; per-engine timeout from estimateLatency + buffer;
      collect results as engines complete, feeding early results to risk scoring
      for fast-path rejection — if any single engine returns reject-level score,
      short-circuit remaining engines)
- [x] **74.1.2.4** Implement result aggregation (collect all ElementScore
      results; merge multiple matches for the same reference work across engines
      into unified SimilarityMatch objects with compound scoring; sort matches
      by compoundScore descending; attach per-engine diagnostics and warnings)
- [x] **74.1.2.5** Implement fast-path scan mode (melody + audio fingerprint
      only, target < 5s latency; used for interactive/real-time feedback during
      composition; returns partial MusicShieldScanResult with only melody and
      fingerprint element scores populated; clearly marked as partial scan in
      result metadata)
- [x] **74.1.2.6** Implement batch scan mode (accept array of scan requests;
      process with configurable concurrency limit; return array of results with
      per-item status; support for priority ordering — higher-priority items
      scanned first; emit batch progress events with completed/total counts)
- [x] **74.1.2.7** Implement scan result caching (LRU cache keyed by audio
      content hash — SHA-256 of normalized audio; configurable TTL; cache hit
      returns previous result immediately; cache invalidation when reference
      database is updated; cache bypass flag in scan request for force-rescan)

#### 74.1.3 Decision Engine

- [x] **74.1.3.1** Implement DecisionEngine class (takes element scores and
      matched works; computes final RiskLevel and overallScore; applies compound
      similarity escalation — when multiple elements match the SAME reference
      work, apply non-linear multiplier: 2 elements × 1.5, 3 elements × 2.0, 4+
      elements × 3.0; applies element weights — melody 0.35, lyrics 0.25, vocal
      0.15, harmony 0.08, spectral 0.07, structure 0.05, rhythm 0.05;
      confidence-weighted scoring — low-confidence scores contribute less)
- [x] **74.1.3.2** Implement threshold comparison (compare overall score against
      configured thresholds for each RiskLevel; support per-genre threshold
      overrides — pop/hip-hop may have higher baseline similarity than
      experimental genres; support per-jurisdiction threshold overrides — more
      conservative thresholds for litigation-heavy jurisdictions like US)
- [x] **74.1.3.3** Implement recommendation generation (for each risk level,
      generate actionable recommendations: pass → 'clear for publication';
      advisory → 'log and monitor, no action needed'; flag → 'requires human
      review before publication, see matched works'; high_risk → 'musicologist
      and legal review required, remediation recommended, specific elements to
      modify listed'; reject → 'blocked, auto-remediation triggered, specific
      infringing elements identified with timestamps')
- [x] **74.1.3.4** Implement decision override support (allow human reviewers to
      override automated decisions via API; override must include reviewer ID,
      rationale text, and expiry timestamp; overrides are logged in audit trail;
      support for permanent overrides — e.g., 'this similarity is coincidental
      and has been legally cleared' — and temporary overrides — e.g., 'approved
      for this release only')
- [x] **74.1.3.5** Write comprehensive tests for decision engine (test compound
      scoring — verify 2-element match against same work escalates correctly;
      test element weighting — verify melody match contributes 35% of score;
      test confidence weighting — verify low-confidence scores are dampened;
      test threshold classification — verify boundary cases for each RiskLevel;
      test per-genre overrides; test recommendation generation for each risk
      level; minimum 50 test cases covering all paths)

#### 74.1.4 Shield API Surface

- [x] **74.1.4.1** Implement MusicShield facade class (single entry point for
      consumers; constructor takes config or uses sensible defaults; scan method
      for single track; batchScan for multiple tracks; quickScan for fast-path
      melody+fingerprint; getEngineStatus returning health of all engines;
      getStats returning scan counts/latencies/risk distribution; destroy for
      cleanup)
- [x] **74.1.4.2** Implement event system for scan lifecycle (events:
      'scanStart', 'engineStart', 'engineComplete', 'engineError',
      'scanComplete', 'decisionMade', 'cacheHit'; each event includes timestamp,
      scanId, and relevant payload; support on/off/once event registration;
      useful for progress UI and monitoring)
- [x] **74.1.4.3** Write integration tests for full pipeline (end-to-end test:
      create MusicShield with mock engines → submit scan request → verify
      pipeline executes all engines → verify result aggregation → verify
      decision; test timeout handling — slow engine times out, scan continues;
      test engine failure — one engine throws, others still contribute; test
      cache — second scan of same audio returns cached result; test abort — scan
      cancelled mid-flight via AbortSignal; minimum 30 integration tests)

---

### 74.2 Melodic Similarity Engine (`@themis/melodic-analysis`)

The single most critical engine. Melody is the #1 litigation vector in music
copyright.

#### 74.2.1 Project Setup & Core Types

- [x] **74.2.1.1** Create `libs/themis/melodic-analysis/` project scaffolding
      (project.json, package.json as `@themis/melodic-analysis`, tsconfig.json,
      vitest.config.ts, src/index.ts)
- [x] **74.2.1.2** Define melodic analysis types (MelodicNote with pitch as MIDI
      number 0-127, onsetMs, durationMs, velocity 0-127, confidence 0-1;
      MelodicContour as array of MelodicNote; ParsonsCode as string of 'U'/'D'/
      'R' characters; IntervalSequence as array of signed integers in semitones;
      MelodicNGram with pitches array, intervals array, startIndex, endIndex,
      sectionType 'chorus'|'verse'|'bridge'|'other', hash string; MelodicMatch
      with queryRange, referenceRange, similarity 0-1, metric name, isCommon
      boolean)

#### 74.2.2 Pitch Extraction

- [x] **74.2.2.1** Implement monophonic pitch extraction using pYIN algorithm
      (frame-by-frame fundamental frequency estimation; 10ms hop size;
      confidence scoring per frame; voiced/unvoiced classification; median
      filtering for pitch smoothing; output as array of {frequencyHz,
      confidence, isVoiced} per frame; handle silence gaps; convert Hz to MIDI
      note numbers with cent deviation; configurable frequency range 50Hz-2000Hz
      for vocal, 80Hz-4000Hz for instruments)
- [x] **74.2.2.2** Implement polyphonic melody extraction (multi-f0 estimation
      using harmonic summation or learned salience representations; extract
      top-N salient pitch streams simultaneously where N is configurable 1-8;
      stream continuity tracking — connect frames into continuous note streams
      using pitch proximity and temporal continuity; stream ranking by salience
      — highest salience stream is the 'primary melody'; each stream output as
      independent MelodicContour)
- [x] **74.2.2.3** Implement MIDI-level quantization (convert continuous pitch
      contours to discrete note events; adaptive tempo grid estimation using
      onset detection → inter-onset intervals → tempo hypothesis; snap note
      onsets to nearest grid position with configurable quantization strength
      0-1; merge adjacent frames with same pitch into single note events;
      compute note velocity from RMS energy around onset; output as MelodicNote
      array with quantized timing)
- [x] **74.2.2.4** Implement source separation preprocessing (integrate with
      Demucs/HTDemucs for 4-stem separation — vocals, drums, bass, other;
      extract melody from isolated vocal stem for vocal melody analysis; extract
      melody from 'other' stem for instrumental lead detection; cache separated
      stems for reuse by spectral and rhythmic engines; graceful fallback to
      full-mix extraction if separation fails)
- [x] **74.2.2.5** Write pitch extraction tests (test monophonic extraction on
      synthesized sine waves at known frequencies — verify pitch accuracy within
      ±10 cents; test on synthesized melodies with known note sequences — verify
      correct note count and pitch; test voiced/unvoiced classification on
      speech+silence signal; test MIDI quantization on synthetically generated
      MIDI-to-audio; test polyphonic extraction on two simultaneous sine waves —
      verify both detected; minimum 40 tests)

#### 74.2.3 Melodic Contour Analysis

- [x] **74.2.3.1** Implement Parsons Code encoder (convert MelodicContour to
      ParsonsCode string; first note is '\*'; subsequent notes: 'U' if higher
      than previous, 'D' if lower, 'R' if same within ±1 semitone tolerance;
      configurable repeat tolerance in cents; encode at multiple granularities —
      note-level and beat-level; provide reverse decoder for display)
- [x] **74.2.3.2** Implement interval sequence encoder (convert MelodicContour
      to IntervalSequence — array of signed integers representing semitone
      intervals between consecutive notes; inherently transposition-invariant;
      support octave-reduced intervals — fold all intervals into -6 to +6 range
      for octave-invariant comparison; support weighted intervals — weight by
      note duration so longer notes contribute more)
- [x] **74.2.3.3** Implement relative pitch encoder (normalize melody to start
      at pitch 0; express all subsequent notes as cumulative semitone offsets;
      output as integer array; useful for key-invariant absolute pitch
      comparison; support octave normalization — fold into single octave 0-11)
- [x] **74.2.3.4** Implement contour complexity scorer (compute Shannon entropy
      of interval histogram; compute pitch range in semitones; compute direction
      change rate — how often does the melody change from ascending to
      descending; compute step/leap ratio — percentage of intervals ≤ 2
      semitones vs > 2; output composite complexity score 0-1 where 0 is
      trivially simple e.g. repeated notes, 1 is maximally complex; simple
      contours have higher false positive probability — annotate this)
- [x] **74.2.3.5** Implement segment-level contour comparison (segment melodies
      into phrases using silence gaps, breath marks, and melodic cadences;
      compare at three granularities — phrase-level 8-16 bars, motif-level 1-4
      bars, fragment-level 3-8 notes; at each level, compute contour similarity
      using interval sequence comparison; track which segments matched and their
      position within the song structure)
- [x] **74.2.3.6** Write contour analysis tests (test Parsons Code on known
      melodies — e.g., 'Twinkle Twinkle' should produce '\*RUURDDDRUURD...';
      test interval sequences — C-D-E should produce [+2, +2]; test
      transposition invariance — same melody in C and G should produce identical
      interval sequences; test complexity scoring — repeated notes = low
      complexity, chromatic runs = high complexity; minimum 35 tests)

#### 74.2.4 N-gram Matching Engine

- [x] **74.2.4.1** Implement pitch n-gram extractor (extract all contiguous
      subsequences of length n from a melody; support configurable n range
      typically 5-12; output as MelodicNGram objects with pitch array, interval
      array, position indices, and hash; hash computation: sort-stable hash of
      interval sequence for transposition-invariant matching; generate n-grams
      at all supported lengths simultaneously in a single pass)
- [x] **74.2.4.2** Implement interval n-gram hash table (in-memory hash map from
      interval n-gram hash → list of {referenceWorkId, position, sectionType};
      support bulk loading from reference database; O(1) lookup for match
      candidates; configurable maximum entries — default 100M; LRU eviction for
      memory management; serializable for persistence to disk)
- [x] **74.2.4.3** Implement weighted n-gram scoring (accept section labels from
      structural analysis or heuristic detection — chorus/verse/bridge/other;
      apply section-based weights: chorus/hook matches × 3.0, phrase boundary
      matches × 2.0, verse matches × 1.0, transition/fill matches × 0.5; compute
      final weighted match score as sum of weighted matches / total possible
      weighted matches; normalize to 0-1)
- [x] **74.2.4.4** Implement common melody filter (load and maintain a database
      of melodic fragments classified as unprotectable — do-re-mi scale runs,
      pentatonic scale patterns, standard blues licks I-III-IV-♭V-V, Alberti
      bass patterns, common cadential patterns V-I, standard arpeggio patterns;
      before scoring matches, remove any that consist entirely of common
      fragments; configurable filter — can be disabled for maximum sensitivity)
- [x] **74.2.4.5** Implement rhythmically-aware n-grams (extend MelodicNGram to
      include duration ratios — each note's duration relative to the shortest
      note in the n-gram; hash includes both interval and duration ratio;
      matching considers pitch match AND rhythm match independently, then
      combines — same pitches + same rhythm = 1.0, same pitches + different
      rhythm = 0.5, different pitches + same rhythm = 0.1)
- [x] **74.2.4.6** Write n-gram matching tests (test n-gram extraction produces
      correct count — melody of length L should produce L-n+1 n-grams of length
      n; test transposition invariance — same melody in two keys produces same
      interval hashes; test weighted scoring — chorus match scores 3x verse
      match; test common melody filtering — scale run matches filtered out; test
      rhythmic awareness — same pitches with different rhythm scores lower;
      minimum 45 tests)

#### 74.2.5 Similarity Metrics

- [x] **74.2.5.1** Implement Levenshtein edit distance for melodies (adapt
      string edit distance to interval sequences; operations: insert interval,
      delete interval, substitute interval; substitution cost proportional to
      interval difference — replacing +2 with +3 costs less than replacing +2
      with -5; normalize by max sequence length for 0-1 similarity score;
      optimized O(mn) dynamic programming with O(min(m,n)) space)
- [x] **74.2.5.2** Implement Dynamic Time Warping for melodies (DTW on pitch
      sequences; Sakoe-Chiba band constraint to limit warping — max 20% tempo
      deviation; distance function: absolute pitch difference in semitones with
      octave reduction option; return DTW distance normalized by path length;
      also return the warping path for alignment visualization; optimized
      implementation with early termination when distance exceeds threshold)
- [x] **74.2.5.3** Implement Longest Common Subsequence for melodies (LCS on
      interval sequences with tolerance — two intervals match if they differ by
      ≤ 1 semitone; return LCS length normalized by shorter sequence length;
      also return the actual subsequence for human inspection; backtrack to
      recover all maximal common subsequences, not just one)
- [x] **74.2.5.4** Implement Smith-Waterman local alignment (adapt from
      bioinformatics for melodic comparison; scoring matrix: match = +3,
      mismatch penalty proportional to interval distance, gap penalty = -2;
      return best local alignment with score, aligned segments from both
      melodies, and position ranges; handles case where a short melody fragment
      is embedded within a longer work; traceback for alignment visualization)
- [x] **74.2.5.5** Implement cosine similarity on pitch class histograms
      (compute 12-bin pitch class profile — count of each pitch class C through
      B; normalize to unit vector; cosine similarity between two profiles; fast
      pre-filter — dissimilar pitch class profiles indicate dissimilar melodies
      without needing sequence comparison; also implement weighted version where
      pitch classes are weighted by note duration)
- [x] **74.2.5.6** Implement Earth Mover's Distance on contour features (extract
      feature distribution — histogram of intervals, histogram of contour
      directions, histogram of phrase lengths; compute EMD between feature
      distributions of two melodies; captures global stylistic similarity beyond
      note-by-note comparison; useful for detecting 'same feel' even when no
      exact fragment matches exist)
- [x] **74.2.5.7** Implement composite melodic similarity scorer (combine all
      metrics into a single melodic similarity score; weights: n-gram match
      0.35, local alignment 0.25, DTW 0.20, LCS 0.10, contour 0.10; if any
      individual metric exceeds reject threshold independently, flag as
      high-confidence match; output MelodicElementScore with composite score,
      per-metric breakdown, matched segments with timestamps, and confidence
      interval)
- [x] **74.2.5.8** Write similarity metrics tests (test edit distance —
      identical melodies = 0 distance; test DTW — same melody at different
      tempos should match; test LCS — melody with inserted notes should still
      match core subsequence; test Smith-Waterman — embedded fragment should be
      found; test pitch class histogram — transposed melody same histogram; test
      composite scorer — verify weights applied correctly; test against known
      music plagiarism cases where ground truth is available; minimum 60 tests)

#### 74.2.6 Transposition & Tempo Invariance

- [x] **74.2.6.1** Implement all-key transposition comparison (for absolute
      pitch comparisons, generate 12 transpositions of query melody — shift all
      pitches by 0-11 semitones; compare each transposition against reference;
      return best matching transposition; for interval-based comparisons,
      transposition invariance is automatic — verify this in tests)
- [x] **74.2.6.2** Implement tempo normalization (detect tempo of input audio
      using onset-based tempo estimation; normalize all melodies to canonical
      120 BPM by scaling note durations proportionally; support swing
      normalization — convert swung rhythms to straight for comparison then flag
      the swing match separately; support compound meter normalization — 6/8 and
      3/4 are metrically equivalent)
- [x] **74.2.6.3** Implement mode-invariant comparison (detect mode — major,
      natural minor, harmonic minor, dorian, etc.; for each interval sequence,
      also generate the parallel mode variant — e.g., if melody is in minor,
      also generate the major-mode version by adjusting 3rd/6th/7th scale
      degrees; compare both versions against reference database)
- [x] **74.2.6.4** Implement augmentation/diminution detection (detect when a
      melody has been rhythmically doubled or halved; generate 2x and 0.5x
      duration variants of query melody; compare variants against reference;
      also detect proportional augmentation — e.g., all durations × 1.5)

---

### 74.3 Harmonic Similarity Engine (`@themis/harmonic-analysis`)

Chord progressions have weaker copyright protection but strengthen compound
infringement claims when combined with melodic similarity.

#### 74.3.1 Project Setup & Types

- [x] **74.3.1.1** Create `libs/themis/harmonic-analysis/` project scaffolding
      (project.json, package.json as `@themis/harmonic-analysis`, tsconfig.json,
      vitest.config.ts, src/index.ts)
- [x] **74.3.1.2** Define harmonic analysis types (ChordLabel with root 0-11,
      quality 'major'|'minor'|'dim'|'aug'|'sus2'|'sus4'|'dom7'|'maj7'|'min7'|
      'dim7'|'hdim7'|'aug7'|'minmaj7'|'add9'|'add11'|'power'|'other', bass 0-11
      for slash chords, extensions array; RomanNumeral with degree 1-7,
      accidental -1|0|1, quality string, inversion 0-3; ChordProgression as
      array of {chord: ChordLabel|RomanNumeral, beatPosition: number,
      durationBeats: number}; HarmonicMatch with queryRange, referenceRange,
      progression similarity 0-1, isCommonProgression boolean)

#### 74.3.2 Chord Extraction

- [x] **74.3.2.1** Implement audio-to-chroma feature extraction (compute
      Harmonic Pitch Class Profile — 12-bin chroma vector per frame using STFT
      with harmonic peak picking; beat-synchronous chroma — average chroma
      vectors within each beat to get one chroma per beat; normalize chroma
      vectors to unit length; configurable frequency range to exclude bass and
      high-frequency noise; use Tukey window for spectral leakage reduction)
- [x] **74.3.2.2** Implement chord recognition from chroma (template matching —
      compute cosine similarity between beat-synchronized chroma and chord
      templates for all major/minor/7th/dim/aug chords in all 12 keys = 120+
      templates; select best-matching template per beat; apply temporal
      smoothing — Viterbi decoding with transition probabilities favoring common
      progressions; output ChordProgression with beat-level resolution)
- [x] **74.3.2.3** Implement Roman numeral conversion (detect global key from
      chord distribution using Krumhansl-Schmuckler key-finding algorithm;
      convert absolute chord labels to Roman numerals relative to detected key;
      handle secondary dominants V/V, V/vi etc.; handle borrowed chords ♭VII,
      ♭III, ♭VI from parallel mode; handle modulations — detect key changes
      using sliding-window key estimation and segment the progression)
- [x] **74.3.2.4** Implement harmonic rhythm extraction (compute chord change
      rate — how many chord changes per bar; detect syncopated chord changes —
      chords changing on weak beats; extract harmonic rhythm pattern as binary
      onset grid analogous to rhythmic patterns; compare harmonic rhythm
      independently from chord identity)
- [x] **74.3.2.5** Write chord extraction tests (test chroma on synthesized
      chords — C major triad should have peaks at C, E, G bins; test chord
      recognition — sequence of synthesized chords correctly identified; test
      Roman numeral conversion — C-Am-F-G in key of C = I-vi-IV-V; test
      modulation detection — key change from C to G correctly detected; minimum
      35 tests)

#### 74.3.3 Harmonic Similarity Comparison

- [x] **74.3.3.1** Implement chord progression n-gram matching (extract n-grams
      of Roman numeral sequences for n = 4 through 8; hash by Roman numeral
      sequence for key-invariant matching; compare against reference database;
      score by n-gram overlap weighted by length — longer matching sequences
      score higher)
- [x] **74.3.3.2** Implement common progression filter (maintain exhaustive
      database of non-protectable progressions — I-V-vi-IV, I-IV-V-I, i-VII-
      VI-VII Andalusian, I-vi-IV-V 50s, vi-IV-I-V modern pop, 12-bar blues,
      ii-V-I jazz, I-IV-vi-V Pachelbel, I-iii-IV-V, I-V-vi-iii-IV-I-IV-V canon,
      plus all rotations/inversions of each; auto-classify any progression
      appearing in 50+ indexed works as non-protectable; filter these from match
      results before scoring)
- [x] **74.3.3.3** Implement harmonic function comparison (abstract chords to
      tonic/predominant/dominant function — I/vi = tonic, IV/ii = predominant,
      V/viio = dominant; compare progression at function level — two songs with
      T-PD-D-T are functionally identical even with different specific chords;
      function-level matches are weaker evidence than specific-chord matches;
      score accordingly)
- [x] **74.3.3.4** Implement voice leading comparison (extract pitch content of
      each chord as sorted pitch array; track how each voice moves between
      consecutive chords; compare voice leading patterns — identical chord
      progressions with identical voice leading are more similar than same
      progressions with different voicings; compute voice leading distance as
      sum of absolute pitch movements across all voices)
- [x] **74.3.3.5** Implement modulation pattern comparison (extract sequence of
      keys and modulation types — e.g., C major → A minor (relative minor) → D
      major (up whole step); compare modulation sequences; unusual modulation
      patterns are more distinctive and protectable than common ones like truck
      driver modulation up a half-step)
- [x] **74.3.3.6** Implement composite harmonic similarity scorer (combine
      n-gram match score, voice leading similarity, modulation pattern
      similarity; apply common progression filtering — heavily discount matches
      that consist only of common progressions; output HarmonicElementScore with
      composite score, per-metric breakdown, isCommon boolean flag, matched
      progression segments)
- [x] **74.3.3.7** Write harmonic comparison tests (test I-V-vi-IV match against
      itself = 1.0; test common progression filter removes I-V-vi-IV from
      results; test key invariance — same progression in C and E♭ match; test
      voice leading — same chords different voicings score lower; test
      modulation detection — key change sequence correctly matched; minimum 40
      tests)

#### 74.3.4 Harmonic Protectability Scoring

- [x] **74.3.4.1** Implement uniqueness scoring (query each chord progression
      against reference database; count how many existing works use the same or
      very similar progression; uniqueness = 1 - (match_count / total_works)
      capped to [0, 1]; progressions used by < 10 works are 'highly unique';
      10-50 works is 'moderately unique'; 50+ is 'common')
- [x] **74.3.4.2** Implement complexity weighting (score harmonic complexity
      based on: variety of chord types used, presence of extended/altered
      chords, frequency of non-diatonic chords, modulation count, average chord
      duration — faster harmonic rhythm = more complex; complex harmony is more
      protectable; output complexity score 0-1)
- [x] **74.3.4.3** Implement context-dependent protectability (a common
      progression with a unique bass line, specific voicing, or distinctive
      harmonic rhythm may be protectable in context; when harmonic match is
      found against a common progression, check if additional contextual
      elements — bass line, rhythm, voicing — also match; if so, elevate the
      protectability score despite the common progression)

---

### 74.4 Rhythmic Similarity Engine (`@themis/rhythmic-analysis`)

Rhythmic patterns have weak copyright protection but iconic drum breaks and
distinctive grooves can be protectable, especially when sampled.

#### 74.4.1 Project Setup & Types

- [x] **74.4.1.1** Create `libs/themis/rhythmic-analysis/` project scaffolding
      (project.json, package.json as `@themis/rhythmic-analysis`, tsconfig.json,
      vitest.config.ts, src/index.ts)
- [x] **74.4.1.2** Define rhythmic analysis types (BeatGrid with tempo BPM,
      timeSignatureNumerator, timeSignatureDenominator, downbeatPositionsMs
      array, beatPositionsMs array; DrumPattern as 2D binary grid — rows for
      kick/snare/hihat/other, columns for 16th-note positions; GrooveTemplate as
      array of micro-timing deviations from grid in ms; RhythmicMatch with
      queryRange, referenceRange, similarity 0-1, matchType
      'pattern'|'groove'|'break')

#### 74.4.2 Beat & Rhythm Extraction

- [x] **74.4.2.1** Implement beat/downbeat tracking (onset detection using
      spectral flux with adaptive threshold; inter-onset interval histogram for
      tempo estimation; dynamic programming or agent-based beat tracking to find
      optimal beat grid; downbeat detection using spectral accent patterns —
      bass energy peaks typically align with downbeats; output BeatGrid with
      ms-accurate beat and downbeat positions; handle tempo changes gracefully —
      segmented tempo estimation)
- [x] **74.4.2.2** Implement drum pattern transcription (separate drums from mix
      using source separation or bandpass filtering; classify drum onsets into
      kick 60-150Hz, snare 150-400Hz, hihat 5kHz+; quantize detected onsets to
      nearest 16th-note grid position; output DrumPattern as binary grid;
      support 32nd-note resolution for complex patterns; confidence score per
      onset)
- [x] **74.4.2.3** Implement rhythmic motif extraction (identify repeated
      patterns in drum grid using autocorrelation — find the shortest repeating
      unit 1-4 bars; extract as canonical rhythmic motif; handle variations — a
      motif that repeats with minor fill variations is still the same core
      motif; output set of distinct motifs with repetition count and positions)
- [x] **74.4.2.4** Implement groove analysis (compute micro-timing deviations
      from quantized grid for each drum onset; average across repetitions of the
      same motif to get stable groove template; characterize swing ratio — ratio
      of long to short 8th notes, 1.0 = straight, ~1.67 = triplet swing; detect
      shuffle, half-time shuffle, push/pull patterns; output GrooveTemplate with
      per-position timing offsets in ms)
- [x] **74.4.2.5** Implement polyrhythm detection (analyze onset patterns across
      multiple metric interpretations — 3/4 vs 4/4, 6/8 vs 3/4; detect
      cross-rhythms — e.g., 3-against-4 hemiola; detect additive rhythms — e.g.,
      3+3+2 pattern common in Afro-Cuban music; output detected polyrhythmic
      relationships with confidence)

#### 74.4.3 Rhythmic Comparison

- [x] **74.4.3.1** Implement onset pattern matching (compare DrumPatterns using
      Hamming distance on binary grids; weight by drum type — kick+snare pattern
      match is more significant than hihat pattern match; normalize by pattern
      length; support partial pattern matching — a 1-bar query matching bars 3-4
      of a 4-bar reference)
- [x] **74.4.3.2** Implement groove template similarity (compare GrooveTemplates
      using Pearson correlation coefficient; two tracks with the same drum
      machine preset and swing setting will have correlation > 0.9; threshold
      for 'same groove' = 0.85 correlation; also compare using MAE of timing
      deviations — average absolute difference in ms)
- [x] **74.4.3.3** Implement drum break database and matching (curate database
      of 200+ iconic/protected drum breaks — Amen break from 'Amen Brother' by
      The Winstons, Funky Drummer by James Brown, Impeach the President by The
      Honey Drippers, Think break by Lyn Collins, Apache by Incredible Bongo
      Band, When the Levee Breaks by Led Zeppelin, Skull Snaps, Hot Pants, etc.;
      for each break store onset pattern + groove template + spectral
      fingerprint; match generated drum patterns against database; detect close
      derivatives — tempo-changed, pitch-shifted, or pattern-truncated versions)
- [x] **74.4.3.4** Implement tempo-invariant rhythm comparison (normalize all
      patterns to canonical tempo 120 BPM by resampling grid; compare normalized
      patterns; also compare at common tempo multiples — double time, half time
      — to catch tempo-shifted patterns)
- [x] **74.4.3.5** Implement composite rhythmic similarity scorer (combine onset
      pattern match, groove similarity, drum break match, polyrhythm match;
      apply weak default weighting — rhythm has lowest overall copyright weight;
      but elevate significantly when a specific protected drum break is matched;
      output RhythmicElementScore)
- [x] **74.4.3.6** Write rhythmic analysis tests (test beat tracking on click
      track — exact beat positions detected; test drum transcription on
      synthesized kick/snare patterns; test groove analysis — straight vs swung
      patterns distinguished; test drum break matching — Amen break correctly
      identified when time-stretched; test tempo invariance — same pattern at
      100 and 140 BPM matches; minimum 40 tests)

---

### 74.5 Spectral & Timbral Similarity Engine (`@themis/spectral-analysis`)

Detects direct sampling, production style reproduction, and sound-alike issues.

#### 74.5.1 Project Setup & Types

- [x] **74.5.1.1** Create `libs/themis/spectral-analysis/` project scaffolding
      (project.json, package.json as `@themis/spectral-analysis`, tsconfig.json,
      vitest.config.ts, src/index.ts)
- [x] **74.5.1.2** Define spectral analysis types (SpectralFeatures with mfccs
      as 2D array frames×coefficients, chromaHPCP as 2D array frames×12,
      spectralCentroid/bandwidth/rolloff/flux as 1D arrays; TimbralFingerprint
      with eqCurve, dynamicRangeLUFS, stereoWidth, reverbCharacteristics,
      bassWeight; SampleMatch with queryRange, referenceRange, similarity 0-1,
      matchType 'direct_sample'|'sample_library'|'micro_sample', sourceId)

#### 74.5.2 Spectral Feature Extraction

- [x] **74.5.2.1** Implement MFCC extraction (STFT with 2048-sample window,
      512-sample hop at 44.1kHz; mel filterbank with 128 bands 20Hz-20kHz;
      log-mel spectrogram; DCT to extract 13-40 MFCCs per frame; include delta
      and delta-delta MFCCs for temporal dynamics; output as
      SpectralFeatures.mfccs 2D array)
- [x] **74.5.2.2** Implement chroma/HPCP extraction (harmonic peak picking on
      STFT magnitude spectrum; assign peaks to pitch classes using log2
      frequency mapping; 12-bin chroma vector per frame; beat-synchronous
      averaging for chord-level chroma; Harmonic Pitch Class Profile variant
      with harmonic weighting — fundamental × 1.0, 2nd harmonic × 0.5, 3rd ×
      0.33; output as SpectralFeatures.chromaHPCP)
- [x] **74.5.2.3** Implement low-level spectral descriptors (spectral centroid —
      amplitude-weighted average frequency per frame; spectral bandwidth —
      spread around centroid; spectral rolloff — frequency below which 85% of
      energy lies; spectral flux — frame-to-frame spectral change; output all as
      per-frame arrays in SpectralFeatures; compute summary statistics — mean,
      std, skewness, kurtosis for each descriptor)
- [x] **74.5.2.4** Implement Tonnetz representation (project chroma features
      onto the Tonnetz — a 6-dimensional representation capturing perfect fifth,
      minor third, and major third relationships; each frame produces a 6D
      vector; useful for topology-aware harmonic comparison — harmonically close
      keys are close in Tonnetz space even when pitch class profiles differ)
- [x] **74.5.2.5** Implement neural audio embeddings (load pre-trained VGGish or
      PANNs model via ONNX Runtime; extract fixed-length embedding vectors per
      audio segment — typically 128D or 512D per ~1s segment; these embeddings
      capture high-level perceptual similarity; support batched inference for
      throughput; cache embeddings for reuse; fallback to MFCC-based features if
      model loading fails)
- [x] **74.5.2.6** Write spectral extraction tests (test MFCCs on synthesized
      signals — pure tone should have concentrated energy in few coefficients;
      test chroma on synthesized chords — C major should peak at C, E, G bins;
      test spectral centroid — high-frequency signal has higher centroid than
      low-frequency; test neural embeddings — same audio produces same embedding
      within numerical tolerance; minimum 30 tests)

#### 74.5.3 Timbral Fingerprinting

- [x] **74.5.3.1** Implement production style fingerprinting (extract: average
      spectral shape across full track as proxy for EQ curve; dynamic range —
      difference between 95th and 5th percentile RMS dB; stereo width —
      correlation between L/R channels; reverb estimation — RT60 from energy
      decay rate in pauses; bass weight — energy ratio below 200Hz vs total;
      loudness in LUFS; output as TimbralFingerprint)
- [x] **74.5.3.2** Implement instrument timbre identification (use neural audio
      embeddings per segment to classify predominant instruments — piano,
      guitar, synth, strings, brass, etc.; track which instruments appear in
      which song sections; output instrumentation timeline as array of
      {instrument, startMs, endMs, confidence})
- [x] **74.5.3.3** Implement mastering characteristic comparison (extract LUFS
      integrated loudness, LUFS short-term range, true peak dBTP, dynamic range
      dB, spectral tilt, crest factor; compare two tracks' mastering profiles
      using normalized Euclidean distance; similar mastering is not infringing
      but indicates same production pipeline)

#### 74.5.4 Sample Detection

- [x] **74.5.4.1** Implement direct sample detection (segment-level audio
      fingerprint matching at high resolution — 1s windows with 0.25s hop;
      compare against reference audio fingerprint database; detect matches
      with > 0.95 fingerprint similarity as potential direct samples; verify
      matches using cross-correlation on raw audio waveforms; account for gain
      changes, slight EQ differences, and encoding artifacts; output matched
      segments with timestamps in both tracks)
- [x] **74.5.4.2** Implement sample library identification (maintain fingerprint
      database of popular sample libraries — Splice top 10K samples, Native
      Instruments Komplete, Loopmasters, Output, Cymatics; when a segment
      matches a sample library entry, flag as 'sample library match' rather than
      'copyrighted work match' — sample library content is pre-cleared for use;
      this reduces false positives from sample-based production)
- [x] **74.5.4.3** Implement micro-sample detection (detect very short samples <
      1 second — drum hits, vocal chops, sound effects, stabs; use
      high-resolution fingerprinting with 100ms windows; compare against
      database of iconic one-shots — 808 kicks, Amen snare, TR-909 claps;
      differentiate between 'commonly used stock sounds' and 'copyrighted
      one-shots from specific recordings')
- [x] **74.5.4.4** Implement composite spectral similarity scorer (combine MFCC
      cosine similarity, chroma similarity, neural embedding similarity, sample
      detection results; weight: neural embeddings 0.40, MFCC 0.25, chroma 0.20,
      sample detection 0.15; output SpectralElementScore)
- [x] **74.5.4.5** Write sample detection tests (test direct sample detection —
      embed a 5s clip from reference into a generated track, verify detected
      with correct timestamps; test time-stretched sample detection; test sample
      library identification — known Splice sample correctly labeled; test
      micro-sample detection — isolated drum hit matched; minimum 30 tests)

---

### 74.6 Lyric Similarity Engine (`@themis/lyric-analysis`)

Lyrics have strong copyright protection as literary works. Even partial
reproduction can constitute infringement.

#### 74.6.1 Project Setup & Types

- [x] **74.6.1.1** Create `libs/themis/lyric-analysis/` project scaffolding
      (project.json, package.json as `@themis/lyric-analysis`, tsconfig.json,
      vitest.config.ts, src/index.ts)
- [x] **74.6.1.2** Define lyric analysis types (LyricLine with text, startMs,
      endMs, sectionType, language; LyricDocument as array of LyricLine with
      metadata — title, fullText, language, wordCount; LyricNGram with words
      array, hash, position, sectionType; PhoneticRepresentation with ipa
      string, soundex string, metaphone string; LyricMatch with queryLines,
      referenceLines, textSimilarity 0-1, semanticSimilarity 0-1,
      phoneticSimilarity 0-1, referenceWorkId, isCommonPhrase boolean)

#### 74.6.2 Text-Level Analysis

- [x] **74.6.2.1** Implement word n-gram extraction and matching (tokenize
      lyrics into words — lowercase, strip punctuation, normalize contractions;
      extract n-grams for n = 3 through 8; hash each n-gram; compare against
      reference lyric database via hash lookup; for each match, record matched
      n-gram text, position in query, reference work ID, section type; score:
      weighted sum of matched n-grams / total n-grams, weighted by length —
      longer matches score exponentially higher)
- [x] **74.6.2.2** Implement semantic similarity analysis (encode each lyric
      line as a sentence embedding using all-MiniLM-L6-v2 or BGE-small via ONNX
      Runtime; for each query line, find top-K most similar lines in reference
      database using cosine similarity; threshold for 'semantically similar' =
      0.85 cosine; aggregate line-level scores into song-level semantic
      similarity; differentiate between 'same idea, different words' and
      'completely different meaning')
- [x] **74.6.2.3** Implement phonetic similarity detection (convert each lyric
      line to IPA using a pronunciation dictionary — CMU Pronouncing Dictionary
      for English, extend for other languages; also generate Soundex and Double
      Metaphone codes; compare phonetic representations — two lines that sound
      the same when sung may use different spellings; Levenshtein distance on
      IPA sequences normalized by length; flag matches where phonetic
      similarity > 0.80 even when text similarity < 0.50)
- [x] **74.6.2.4** Implement rhyme scheme extraction and comparison (identify
      line-ending rhymes using phonetic matching on final syllables; encode as
      ABAB, AABB, etc.; compare rhyme schemes between query and reference; also
      extract internal rhymes — rhyming words within a line; identical rhyme
      scheme + similar content = elevated risk; rhyme scheme alone is not
      protectable)
- [x] **74.6.2.5** Implement meter and scansion matching (analyze syllable
      stress patterns using a pronunciation dictionary — stressed/unstressed
      syllable sequences; classify meter — iambic, trochaic, anapestic,
      dactylic, etc.; compare meter patterns between query and reference;
      identical meter + rhyme + similar content = compound evidence; meter alone
      is not protectable)
- [x] **74.6.2.6** Write text analysis tests (test n-gram extraction — correct
      count and content; test semantic similarity — paraphrased line scores
      high, unrelated line scores low; test phonetic similarity — 'night' and
      'knight' score 1.0 phonetically; test rhyme scheme — AABB correctly
      detected; test meter — iambic pentameter correctly identified; minimum 40
      tests)

#### 74.6.3 Filtering & Thresholds

- [x] **74.6.3.1** Implement common phrase database (curate database of 10,000+
      lyric phrases classified as non-protectable — generic love expressions,
      common idioms, genre clichés, seasonal phrases, exclamatory phrases;
      organize by category for analysis; for each matched n-gram, check against
      common phrase database; if match is a common phrase, exclude from scoring;
      auto-expand database: any phrase appearing in 100+ indexed songs is
      auto-classified as common)
- [x] **74.6.3.2** Implement hook/chorus weighting (when section labels are
      available, weight matches by section — chorus/hook matches × 3.0, verse
      matches × 1.0, bridge matches × 1.5, intro/outro × 0.5; if section labels
      not available, use heuristic — repeated lyric blocks are likely choruses,
      apply elevated weighting to repeated blocks)
- [x] **74.6.3.3** Implement multi-language support (detect lyric language using
      character set analysis and n-gram language models; support English,
      Spanish, French, German, Japanese, Korean, Portuguese, Italian, Chinese,
      Arabic, Hindi at minimum; for non-English lyrics, perform comparison in
      original language AND generate English translation for cross-language
      matching; detect when lyrics translate or transliterate copyrighted lyrics
      from another language)
- [x] **74.6.3.4** Implement title phrase detection (maintain database of
      distinctive song titles from commercially released music — 'Bohemian
      Rhapsody', 'Smells Like Teen Spirit', 'Purple Rain', etc.; when generated
      lyrics contain a distinctive title phrase, flag for elevated scrutiny;
      generic titles — 'Love', 'Baby', 'Tonight' — are not distinctive and are
      not flagged)

#### 74.6.4 Lyric-Melody Joint Analysis

- [x] **74.6.4.1** Implement combined lyric-melody matching (when both lyrics
      AND melody are available, perform joint analysis; for each matched lyric
      segment, check if the corresponding melodic segment also matches the same
      reference work; joint match — same words sung to same tune — is the
      strongest possible evidence; compound score: lyric_score × melody_score ×
      joint_multiplier where joint_multiplier = 5.0 for simultaneous match)
- [x] **74.6.4.2** Implement syllable-pitch alignment analysis (align syllables
      to pitches using note onset/lyric timing; compare syllable-pitch pairings
      between query and reference; even with different words, if syllable stress
      patterns align with the same melodic contour the same way, this is a
      compound signal; output aligned score)
- [x] **74.6.4.3** Implement composite lyric similarity scorer (combine text
      n-gram score, semantic similarity, phonetic similarity, joint lyric-melody
      score; apply common phrase filtering; apply section weighting; output
      LyricElementScore with composite and per-metric breakdown)
- [x] **74.6.4.4** Write lyric engine integration tests (test full pipeline
      end-to-end — submit lyrics → text + semantic + phonetic analysis →
      filtering → scoring; test common phrase filtering removes 'I love you';
      test multi-language — Spanish lyrics matched against Spanish reference;
      test joint lyric-melody — simultaneous match scores much higher than
      either alone; minimum 35 tests)

---

### 74.7 Vocal Similarity Engine (`@themis/vocal-analysis`)

Voice similarity is increasingly litigious with the NO FAKES Act and
international voice right legislation.

#### 74.7.1 Project Setup & Types

- [x] **74.7.1.1** Create `libs/themis/vocal-analysis/` project scaffolding
      (project.json, package.json as `@themis/vocal-analysis`, tsconfig.json,
      vitest.config.ts, src/index.ts)
- [x] **74.7.1.2** Define vocal analysis types (SpeakerEmbedding as Float32Array
      typically 192D or 512D; VoicePrint with speakerEmbedding, formants F1-F5,
      vibratoRate/depth, breathiness 0-1, roughness 0-1, speakingRate,
      pitchRange; VocalMatch with queryVoicePrint, referenceVoicePrint,
      cosineSimilarity 0-1, formantDistance, overallSimilarity 0-1,
      referenceArtistId, consentStatus 'consented'|'not_consented'|'unknown')

#### 74.7.2 Speaker Embedding Extraction

- [x] **74.7.2.1** Implement speaker embedding extraction (load pre-trained
      ECAPA-TDNN or TitaNet model via ONNX Runtime; extract d-vector/x-vector
      speaker embeddings from vocal audio; input preprocessing — 16kHz
      resampling, VAD to extract speech-only segments, normalization;
      segment-level extraction — embeddings per 3-5 second vocal segments;
      utterance-level aggregation — average segment embeddings with length
      weighting for global voice print; output SpeakerEmbedding; handle singing
      voice — may need fine-tuned model for sung vs spoken)
- [x] **74.7.2.2** Implement voice print construction (aggregate speaker
      embeddings across multiple vocal segments; extract formant frequencies
      F1-F5 using LPC analysis on vocal segments; measure vibrato —
      autocorrelate pitch contour of sustained notes, extract rate in Hz and
      depth in semitones; measure breathiness — harmonic-to-noise ratio; measure
      roughness — jitter and shimmer; compute pitch range from f0 statistics;
      output complete VoicePrint)
- [x] **74.7.2.3** Implement voice database management (store protected voice
      prints in PostgreSQL with pgvector for embedding similarity search; CRUD
      operations for voice prints — add, update, remove; bulk import from audio
      files; attach metadata — artist name, label, known consent status,
      jurisdiction; version voice prints — re-extract when model is updated;
      support for multiple embeddings per artist from different recordings for
      robustness)

#### 74.7.3 Vocal Similarity Comparison

- [x] **74.7.3.1** Implement speaker embedding comparison (cosine similarity
      between query and reference embeddings; threshold calibration — 0.75
      cosine = 'similar', 0.85 = 'highly similar', 0.95 = 'near identical';
      compare against all protected voices in database using pgvector
      approximate nearest neighbor search; return top-K matches with similarity
      scores; handle singing vs speaking voice discrepancy — same person may
      have different embeddings for singing vs speaking)
- [x] **74.7.3.2** Implement formant analysis comparison (compare F1-F5 formant
      frequencies between query and reference; compute formant distance as
      weighted Euclidean — F1 and F2 have highest discriminative power;
      normalize by typical formant ranges; formant comparison is complementary
      to embedding comparison and less sensitive to recording conditions)
- [x] **74.7.3.3** Implement singing technique fingerprinting (detect signature
      vocal techniques from audio: melismatic runs — rapid pitch fluctuations
      spanning > 3 semitones in < 0.5s; vocal fry — low-frequency irregularity
      at phrase endings; belting — sustained high-energy vocalizations above
      passaggio; falsetto/head voice transitions — abrupt register change;
      vibrato characteristics — fast vibrato rate > 6Hz vs slow < 4Hz, deep > 1
      semitone vs shallow; compare technique profiles between query and
      reference artists)
- [x] **74.7.3.4** Implement phrasing and timing analysis (extract phrase
      durations, breath positions, rhythmic relationship to beat — anticipated
      vs behind the beat; compute average phrase length, breath frequency,
      anticipation/delay statistics; compare phrasing profiles; distinctive
      phrasing is a secondary identification feature)

#### 74.7.4 Anti-Impersonation System

- [x] **74.7.4.1** Implement real-time voice comparison during synthesis
      (streaming interface: accept audio chunks as they are generated; extract
      embedding from accumulated audio every N seconds; compare against
      protected voice database incrementally; emit early warning if similarity
      to any protected voice exceeds 0.70; allows generation pipeline to abort
      or modify in real-time before full track completion)
- [x] **74.7.4.2** Implement distinctiveness scoring (compare generated voice
      against entire voice database — not just protected voices; compute minimum
      distance to any known voice; higher minimum distance = more distinctive =
      lower risk; score 0-1 where 0 = identical to a known voice, 1 = maximally
      unique; recommend minimum distinctiveness of 0.30 before publication)
- [x] **74.7.4.3** Implement voice modification suggestions (when generated
      voice is too similar to a protected voice, analyze which features
      contribute most to the similarity — formant proximity, vibrato match,
      breathiness match; generate specific modification recommendations: 'shift
      F2 formant up 100Hz', 'reduce vibrato depth by 0.3 semitones', 'increase
      breathiness by 15%'; each recommendation includes expected similarity
      reduction)
- [x] **74.7.4.4** Implement consent verification integration (query consent
      database for matched artist: 'has Artist X consented to voice
      replication?'; consent statuses: 'consented' → bypass flag for this
      artist, 'not_consented' → enforce flag, 'unknown' → enforce flag with
      advisory to seek consent; consent can be scoped — consented for specific
      projects/uses only; log all consent checks in audit trail)
- [x] **74.7.4.5** Implement composite vocal similarity scorer (combine speaker
      embedding similarity, formant distance, technique fingerprint match,
      phrasing similarity; output VocalElementScore; if any protected voice
      match exceeds 0.85 cosine, automatically escalate to REJECT regardless of
      composite score)
- [x] **74.7.4.6** Write vocal analysis tests (test speaker embedding extraction
      — same speaker different segments should have cosine > 0.90; different
      speakers should have cosine < 0.50; test formant extraction on synthesized
      vowels; test real-time comparison — similarity alert fires when threshold
      crossed; test distinctiveness scoring — unique voice scores high; test
      consent bypass — consented artist not flagged; minimum 40 tests)

---

### 74.8 Structural Similarity Engine (`@themis/structural-analysis`)

Song structure similarity strengthens compound claims when combined with other
matching elements.

#### 74.8.1 Project Setup & Implementation

- [x] **74.8.1.1** Create `libs/themis/structural-analysis/` project scaffolding
      (project.json, package.json as `@themis/structural-analysis`,
      tsconfig.json, vitest.config.ts, src/index.ts)
- [x] **74.8.1.2** Define structural analysis types (SongSection with type
      'intro'|'verse'|'pre_chorus'|'chorus'|'bridge'|'instrumental'|'outro'|
      'other', startMs, endMs, durationMs, energy 0-1; SongStructure as array of
      SongSection with totalDurationMs and sectionSequence string; EnergyContour
      as array of {timeMs, energy 0-1} at 100ms resolution;
      ArrangementFingerprint with instrumentationTimeline, texturalDensityCurve,
      productionEvents)
- [x] **74.8.1.3** Implement section segmentation (compute feature matrix —
      concatenate MFCCs, chroma, spectral centroid per frame; compute
      self-similarity matrix using cosine distance; detect section boundaries
      using novelty function — peak picking on the diagonal of the self-
      similarity matrix; classify sections by repetition analysis — repeated
      sections labeled as chorus, first occurrence as verse; use structural
      analysis from musicology — intro typically lower energy, chorus higher
      energy; output SongStructure)
- [x] **74.8.1.4** Implement section comparison (compare section sequences using
      string edit distance on section type sequences; compare section duration
      ratios — vector of relative durations; combine sequence similarity and
      duration ratio similarity; common structures like ABABCB are non-
      protectable — filter these)
- [x] **74.8.1.5** Implement energy contour comparison (extract loudness curve
      at 100ms resolution using LUFS or RMS; smooth with 1s window; normalize to
      0-1 range; compare energy contours using cross-correlation — find best
      alignment; similar energy contours indicate similar dynamic shape —
      build-ups, drops, quiet sections in same places)
- [x] **74.8.1.6** Implement arrangement analysis (extract instrumentation
      timeline using instrument classification per segment; compute textural
      density — number of simultaneous active instruments over time; detect
      production events — risers, drops, filter sweeps, breakdowns, drum fills
      using spectral analysis; compare arrangement fingerprints between tracks)
- [x] **74.8.1.7** Implement composite structural similarity scorer (combine
      section sequence similarity, duration ratio similarity, energy contour
      correlation, arrangement fingerprint similarity; low default weight —
      structure alone is rarely protectable; but significantly elevate weight
      when structural match co-occurs with melodic or harmonic match to same
      reference work)
- [x] **74.8.1.8** Write structural analysis tests (test section segmentation —
      song with clear verse/chorus structure correctly segmented; test energy
      contour — loud chorus has higher energy than quiet verse; test arrangement
      — track with only piano should differ from full band; test common
      structure filtering — ABABCB not flagged; minimum 25 tests)

---

### 74.9 Audio Fingerprint Engine (`@themis/audio-fingerprint`)

Extends existing `@nous/audio` fingerprinting with copyright-specific matching.
Fastest pre-filter in the pipeline.

#### 74.9.1 Project Setup & Implementation

- [x] **74.9.1.1** Create `libs/themis/audio-fingerprint/` project scaffolding
      (project.json, package.json as `@themis/audio-fingerprint`, tsconfig.json,
      vitest.config.ts, src/index.ts)
- [x] **74.9.1.2** Define audio fingerprint types extending @nous/audio
      (CopyrightFingerprintResult extending AudioFingerprintMatchResult with
      additional fields: isrcCode, iswcCode, copyrightHolder, isDirectCopy
      boolean, matchedSegments array with timestamps; NeuralFingerprint with
      embeddingVector Float32Array, modelVersion, extractionParams;
      ContentIdResult with platform, claimType, claimant, referenceId)
- [x] **74.9.1.3** Implement neural audio fingerprinting (load pre-trained
      neural fingerprint model via ONNX — e.g., Neural Audio Fingerprint or
      COLA; extract fixed-length fingerprint vectors per ~1s segment;
      fingerprints are invariant to common transformations — MP3 encoding,
      volume changes, slight EQ; compare via cosine similarity in vector
      database; more robust than landmark fingerprinting for detecting
      transformations that defeat spectral peaks)
- [x] **74.9.1.4** Implement robust perceptual hashing (generate compact
      perceptual hash per audio segment — 128 or 256 bit hash; invariant to:
      lossy encoding up to 128kbps MP3, volume normalization, mild EQ +/- 3dB,
      sample rate conversion, mono/stereo conversion; hash comparison via
      Hamming distance — threshold 15% mismatch for 'same recording'; store
      hashes in Redis for sub-millisecond lookup)
- [x] **74.9.1.5** Implement segment-level matching (divide query audio into 10s
      windows with 2.5s hop; fingerprint each segment independently; match each
      segment against reference database; detect when a short segment of
      generated audio matches a copyrighted work even though the rest is
      original; output matched segments with precise timestamps in both query
      and reference)
- [x] **74.9.1.6** Implement speed/pitch-shifted matching (generate additional
      query fingerprints at common time-stretch ratios — 0.8x, 0.9x, 1.1x, 1.2x
      — and pitch-shift intervals — ±1, ±2 semitones; compare all variants
      against reference; catches AI model failure mode of reproducing training
      data at altered speed/pitch)
- [x] **74.9.1.7** Implement stem-level fingerprinting (after source separation,
      fingerprint each stem independently — vocals, drums, bass, other; match
      each stem against reference database; catches cases where a generated
      track has original melody but copies a drum pattern from a copyrighted
      recording; output per-stem match results)
- [x] **74.9.1.8** Implement Content ID proxy integration (YouTube Content ID:
      upload audio via YouTube Data API as unlisted video, poll for Content ID
      claims, retrieve claim details, delete video; wrapper class with
      configurable API credentials; timeout and retry logic; parse Content ID
      claim response into structured ContentIdResult; rate limiting to stay
      within API quotas; this is optional/external — shield functions without
      it)
- [x] **74.9.1.9** Implement ISRC/ISWC resolution (when a fingerprint match
      identifies a reference track by internal ID, resolve to standard
      identifiers: ISRC for recording, ISWC for musical work; query MusicBrainz
      API for ISRC→metadata mapping; query CISAC/SUISA for ISWC; cache
      resolutions; attach identifiers to SimilarityMatch)
- [x] **74.9.1.10** Implement composite fingerprint scorer (combine landmark
      match score from @nous/audio, chroma match score, neural fingerprint
      cosine similarity, perceptual hash match, segment-level matches; if any
      algorithm detects a direct copy with > 0.95 match, auto-classify as
      REJECT; output FingerprintElementScore)
- [x] **74.9.1.11** Write fingerprint engine tests (test neural fingerprint
      invariance — same audio through MP3 encoding and back should match; test
      segment matching — embedded 15s clip detected; test speed/pitch shift —
      10% tempo change still detected; test stem matching — copied drum pattern
      caught; test perceptual hashing — Hamming distance near zero for same
      recording; minimum 35 tests)

---

### 74.10 Reference Database System (`@themis/reference-db`)

The reference database is the foundation. The system is only as good as its
coverage.

#### 74.10.1 Project Setup & Schema

- [x] **74.10.1.1** Create `libs/themis/reference-db/` project scaffolding
      (project.json, package.json as `@themis/reference-db`, tsconfig.json,
      vitest.config.ts, src/index.ts)
- [x] **74.10.1.2** Define database schema (ReferenceWork table: id UUID PK,
      title, artist, album, releaseDate, isrc, iswc, copyrightHolder, publisher,
      label, genres array, publicDomain boolean, publicDomainJurisdictions
      array, protectabilityAnnotations JSONB, indexedAt timestamp, updatedAt
      timestamp; MelodyIndex table: id, referenceWorkId FK, contourType
      'parsons'|'interval'| 'absolute', encodedContour text, sectionType,
      ngramHashes text array, startMs, endMs; HarmonicIndex: id, referenceWorkId
      FK, romanNumerals text array, ngramHashes text array; LyricIndex: id,
      referenceWorkId FK, fullText, lineEmbeddings vector array, ngramHashes
      text array, language; VoicePrintIndex: id, artistId, embedding
      vector(512), formants JSONB, consentStatus; AudioFingerprintIndex: id,
      referenceWorkId FK, landmarkHash text, chromaHash text, neuralEmbedding
      vector(256), perceptualHash bytea; RhythmIndex: id, referenceWorkId FK,
      drumPattern bytea, grooveTemplate float array)
- [x] **74.10.1.3** Implement Drizzle ORM schema and migrations (define all
      tables using drizzle-orm TypeScript schema; pgvector extension for
      embedding columns; GIN indexes on array columns for n-gram hash lookup;
      HNSW indexes on vector columns for ANN search; composite indexes on
      referenceWorkId + sectionType for filtered queries; migration system for
      schema evolution)

#### 74.10.2 Data Ingestion Pipeline

- [x] **74.10.2.1** Implement MusicBrainz ingestion adapter (connect to
      MusicBrainz API; query recordings by various criteria — artist, release,
      date range; extract metadata: title, artist, ISRC, release date, genres;
      resolve to AcoustID fingerprints where available; rate limiting per
      MusicBrainz API terms — 1 request/second; batch import with progress
      tracking; handle pagination for large result sets; target: index metadata
      for 20M+ recordings)
- [x] **74.10.2.2** Implement AcoustID fingerprint ingestion (for recordings
      with AcoustID entries, download pre-computed chromaprint fingerprints;
      store in AudioFingerprintIndex; batch processing with configurable
      concurrency; deduplication — skip already-indexed recordings)
- [x] **74.10.2.3** Implement MIDI melody ingestion (download and process Lakh
      MIDI Dataset — 176,000+ MIDI files; extract melody tracks from MIDI —
      highest-pitched monophonic track or track labeled 'melody'; convert to
      MelodicContour; compute Parsons codes, interval sequences, n-gram hashes;
      store in MelodyIndex; also process other MIDI databases; batch processing
      with error handling — skip corrupt files)
- [x] **74.10.2.4** Implement lyric ingestion pipeline (integrate with licensed
      lyric APIs — Musixmatch, Genius; for each indexed recording, fetch lyrics
      where available; compute sentence embeddings for each line; extract word
      n-gram hashes; detect language; store in LyricIndex; respect API rate
      limits and licensing terms; fallback to public domain lyric sources for
      pre-copyright works)
- [x] **74.10.2.5** Implement audio feature ingestion (for recordings where
      audio access is available — licensed catalogs, public domain recordings;
      extract all features: melody contours, chord progressions, drum patterns,
      spectral features, audio fingerprints, voice prints; store in all relevant
      index tables; batch processing with distributed workers via BullMQ;
      target: process 1000 recordings per hour per worker)
- [x] **74.10.2.6** Implement public domain collection ingestion (process IMSLP
      classical scores — extract melody from MusicXML/MEI; process Musopen
      recordings — full audio feature extraction; process traditional folk music
      archives; tag all entries as publicDomain with applicable jurisdictions;
      these enable automatic clearance when generated music matches public
      domain works only)
- [x] **74.10.2.7** Implement real-time release monitoring (monitor Spotify new
      release radar via API — poll daily; monitor Billboard chart entries via
      scraping or API; monitor TikTok trending sounds via social listening; when
      new high-profile release detected, priority-queue it for feature
      extraction; target SLA: chart-topping releases indexed within 24 hours,
      all new releases within 48 hours)

#### 74.10.3 Database Maintenance

- [x] **74.10.3.1** Implement deduplication system (detect duplicate reference
      works — same song appearing as single, album track, compilation track,
      remaster; match by ISRC first, then audio fingerprint similarity, then
      metadata fuzzy matching; merge duplicates into canonical entry while
      preserving all ISRC variants; periodic dedup scan on new ingestions)
- [x] **74.10.3.2** Implement metadata enrichment pipeline (for each reference
      work, enrich with: songwriter credits from MusicBrainz, publisher info,
      copyright holder from ISRC registry, known licensing terms, genre
      classification; keep enriched data fresh — periodic re-enrichment every 30
      days; resolve songwriter → publisher → label chain for copyright holder
      identification)
- [x] **74.10.3.3** Implement protectability annotation (for each indexed work,
      compute per-element protectability scores: melody uniqueness score from
      n-gram rarity, harmonic commonality score, lyric originality score;
      annotate reference works so that matches against low-protectability
      elements are scored lower; periodic re-computation as database grows)
- [x] **74.10.3.4** Implement jurisdiction mapping (for each reference work,
      determine copyright status per jurisdiction — a work may be public domain
      in one country but protected in another; track based on: publication date,
      author death date, rule of the shorter term, US copyright term rules
      pre/post-1978; store per-jurisdiction status in protectabilityAnnotations
      JSONB)
- [x] **74.10.3.5** Write reference database tests (test ingestion — MusicBrainz
      adapter correctly parses API response; test deduplication — same song
      different ISRCs merged; test metadata enrichment — songwriter credits
      attached; test protectability annotation — common progression gets low
      score; test jurisdiction mapping — pre-1928 work marked public domain in
      US; minimum 40 tests)

---

### 74.11 Legal Risk Scoring Engine (`@themis/risk-scoring`)

Synthesizes all similarity signals into legally grounded risk assessments.

#### 74.11.1 Project Setup & Core Implementation

- [x] **74.11.1.1** Create `libs/themis/risk-scoring/` project scaffolding
      (project.json, package.json as `@themis/risk-scoring`, tsconfig.json,
      vitest.config.ts, src/index.ts)
- [x] **74.11.1.2** Define risk scoring types (RiskAssessment with overallRisk
      RiskLevel, overallScore 0-1, confidence 0-1, elementScores map,
      compoundMatches array, jurisdictionAssessments map, recommendations array;
      CompoundMatch with referenceWorkId, matchedElements array each with
      type/score/confidence, compoundMultiplier, aggregateScore;
      JurisdictionAssessment with jurisdictionCode, testApplied string,
      riskLevel, explanation string)
- [x] **74.11.1.3** Implement composite scorer (accept element scores from all
      engines; apply configurable element weights — default: melody 0.35, lyrics
      0.25, vocal 0.15, harmony 0.08, spectral 0.07, structure 0.05, rhythm
      0.05; compute weighted sum; apply confidence weighting — low- confidence
      scores contribute proportionally less; normalize to 0-1; support per-genre
      weight overrides — e.g., hip-hop elevates rhythm weight to 0.12 and
      reduces melody to 0.28)
- [x] **74.11.1.4** Implement compound similarity detection (group all matches
      by reference work ID; for each reference work with matches across multiple
      elements, compute compound score with non-linear escalation: 2 matching
      elements × 1.5, 3 elements × 2.0, 4+ elements × 3.0; compound matches are
      the strongest infringement evidence — melody + lyrics to the same song is
      far more damning than melody to song A + lyrics to song B)
- [x] **74.11.1.5** Implement confidence interval calculation (for each element
      score, compute confidence interval using: engine-reported confidence,
      match count — more matches = higher confidence, match consistency —
      multiple metrics agreeing = higher confidence; report final score as point
      estimate ± interval; risk classification uses the upper bound of the
      confidence interval for conservative assessment)

#### 74.11.2 Legal Precedent Database

- [x] **74.11.2.1** Implement case law database schema and data (define
      CopyrightCase type: caseName, year, court, jurisdiction, outcome
      'infringement'|'no_infringement'|'settled'|'reversed', damages number,
      keyElement, thresholdApplied string, similarityDescription string;
      populate with 50+ landmark music copyright cases — Bright Tunes v
      Harrisongs 1976, Three Boys v Bolton 2000, Williams v Gaye 2015, Gray v
      Perry 2019, Griffin v Sheeran 2023, Structured Asset Sales v Sheeran 2023,
      Skidmore v Led Zeppelin 2020, etc.; include non-US cases where available)
- [x] **74.11.2.2** Implement threshold calibration from case law (analyze case
      law outcomes to determine empirical thresholds — at what similarity level
      have courts found infringement?; set flag threshold below the lowest
      infringement-finding similarity level for safety margin; output calibrated
      thresholds per element and per jurisdiction; periodic re-calibration as
      new cases are decided)
- [x] **74.11.2.3** Implement legal precedent citation (when a flagged match is
      similar to a decided case, cite the relevant case in the risk assessment —
      'This melodic similarity is comparable to the level found infringing in
      Williams v. Gaye (2015)'; or 'This harmonic similarity is comparable to
      the level found non-infringing in Griffin v. Sheeran (2023)'; include case
      outcome and damages for context)

#### 74.11.3 Jurisdiction-Aware Assessment

- [x] **74.11.3.1** Implement US copyright analysis (apply the Arnstein test
      framework: probative similarity → access → substantial similarity; also
      apply the Ninth Circuit extrinsic/intrinsic test; for AI-generated music,
      access is presumed — AI models trained on massive datasets almost
      certainly had access to popular works; therefore focus on substantial
      similarity analysis; output US-specific risk assessment)
- [x] **74.11.3.2** Implement EU copyright analysis (apply EU originality
      standard — 'author's own intellectual creation'; apply copyright directive
      text and data mining exceptions — Article 3 for research, Article 4 for
      commercial with opt-out; check if reference work's rights holder has opted
      out of TDM; output EU-specific risk assessment)
- [x] **74.11.3.3** Implement UK CDPA analysis (apply the 'substantial part'
      test — qualitative not just quantitative; in UK law, even a small part can
      be substantial if it's the most distinctive part; output UK-specific risk
      assessment)
- [x] **74.11.3.4** Implement multi-jurisdiction risk aggregation (when a work
      will be distributed globally, assess risk under all configured
      jurisdictions; report the highest risk across all jurisdictions as the
      overall risk — must be safe in the strictest jurisdiction; generate
      per-jurisdiction breakdown for legal team review)
- [x] **74.11.3.5** Implement moral rights assessment (in jurisdictions with
      moral rights — EU, UK, Japan, most non-US countries; assess whether
      generated content could constitute a 'distortion' or 'mutilation' of an
      existing work; flag when generated content closely parodies or transforms
      a specific work in a way that could damage the original author's
      reputation)
- [x] **74.11.3.6** Write risk scoring tests (test composite scoring — verify
      weights applied correctly; test compound detection — 2-element match to
      same work escalates; test confidence intervals — low confidence reduces
      contribution; test case law citation — relevant case cited for similar
      matches; test jurisdiction — US vs EU may give different risk levels for
      same match; minimum 45 tests)

---

### 74.12 Provenance & Audit Trail System (`@themis/provenance`)

Complete documentation of every generated work's origins for legal defense.

#### 74.12.1 Project Setup & Implementation

- [x] **74.12.1.1** Create `libs/themis/provenance/` project scaffolding
      (project.json, package.json as `@themis/provenance`, tsconfig.json,
      vitest.config.ts, src/index.ts)
- [x] **74.12.1.2** Define provenance types (GenerationRecord with generationId,
      timestamp, prompt, modelId, modelVersion, checkpoint, temperature, topK,
      topP, guidanceScale, seed, operatorId 'automated'|userId, stages array of
      GenerationStage; ScanRecord with scanId, generationId, timestamp,
      scanConfig, elementScores, matches, riskLevel, decision, scanDurationMs;
      DecisionRecord with decisionId, scanId, decisionType
      'auto_pass'|'auto_reject'|'human_approve'|'human_reject'|'human_override',
      reviewerId, rationale, conditions, expiresAt; ProvenanceChain linking
      generation → scan → decision → publication)
- [x] **74.12.1.3** Implement generation provenance recorder (capture full
      generation parameters at the moment of music creation; support multi-stage
      recording — melody generation → arrangement → production → mastering each
      recorded separately; immutable append-only storage in PostgreSQL;
      content-addressed — generation records are hashed and hash is stored for
      tamper detection; integration hooks for Calliope, Euterpe, Isis generation
      pipelines)
- [x] **74.12.1.4** Implement scan result recorder (after every shield scan,
      store complete scan results including all element scores, matched
      reference works, risk assessment, decision; link to generation record via
      generationId; store full diagnostics for debugging and auditing; support
      scan result retrieval by generationId, scanId, or time range)
- [x] **74.12.1.5** Implement decision audit trail (record every decision —
      automated and human; human decisions include reviewer identity and
      rationale; override decisions include original decision, override
      decision, and justification; support querying decision history for a
      specific work; generate audit report for legal team — complete chain from
      generation parameters to publication decision)
- [x] **74.12.1.6** Implement training data provenance (store training data
      manifests per model — datasets used, license types, opt-out compliance;
      link generation records to model manifests; if a dataset is later found to
      be problematic, query all generations that used models trained on that
      dataset; support opt-out registry — list of artists who have opted out of
      AI training, verified against model manifests)
- [x] **74.12.1.7** Implement provenance export (generate human-readable
      provenance report for a specific work — PDF or Markdown; include:
      generation parameters, model and training data provenance, scan results
      with matched works and risk scores, decision chain with rationale;
      suitable for legal discovery or regulatory audit; also export
      machine-readable JSON for integration)
- [x] **74.12.1.8** Write provenance tests (test generation recording — all
      params captured; test scan recording — results stored and retrievable;
      test decision trail — override properly logged with justification; test
      provenance chain — full chain from generation to publication
      reconstructable; test tamper detection — modified record detected via hash
      mismatch; minimum 30 tests)

---

### 74.13 Human Review Pipeline (`@themis/review-pipeline`)

Human experts handle the nuanced cases between clear pass and clear reject.

#### 74.13.1 Project Setup & Implementation

- [x] **74.13.1.1** Create `libs/themis/review-pipeline/` project scaffolding
      (project.json, package.json as `@themis/review-pipeline`, tsconfig.json,
      vitest.config.ts, src/index.ts)
- [x] **74.13.1.2** Define review pipeline types (ReviewItem with reviewId,
      scanId, generationId, priority 1-5, riskLevel, matchedWorks array, status
      'pending'|'assigned'|'in_review'|'decided'|'escalated', assignedTo,
      createdAt, dueAt, decidedAt; ReviewDecision with reviewId, decision
      'approve'|'reject'|'modify'|'escalate', rationale text, conditions array,
      reviewerExpertise string; ReviewerProfile with reviewerId, name, expertise
      array of 'musicologist'|'lyricist'|'legal'|'genre_specialist',
      genreExpertise array, activeReviews count, averageReviewTimeMs)
- [x] **74.13.1.3** Implement priority review queue (BullMQ-backed priority
      queue; priority calculation: base from risk level — high_risk = P1, flag =
      P3; modifiers: artist tier — higher profile = higher priority; publication
      deadline — closer deadline = higher priority; similarity confidence —
      higher confidence = higher priority; support requeue after timeout; FIFO
      within same priority level)
- [x] **74.13.1.4** Implement reviewer assignment (match review items to
      qualified reviewers based on expertise: melodic/harmonic disputes →
      musicologists, lyric disputes → lyricists, high-risk → legal reviewers,
      genre-specific → genre specialists; load balancing — assign to reviewer
      with fewest active reviews; respect reviewer capacity limits; round-robin
      within qualification tier; escalation if no qualified reviewer available
      within SLA)
- [x] **74.13.1.5** Implement review decision recording (record decisions with
      mandatory rationale text — minimum 20 characters; support conditional
      approvals — 'approved if melody in bars 33-36 is modified'; support
      escalation — reviewer unsure, escalates to senior musicologist or external
      expert panel; all decisions immutably logged in provenance system)
- [x] **74.13.1.6** Implement comparison tools API (server-side endpoints for
      review UI: get side-by-side audio segments for A/B comparison; get
      similarity heatmap data — per-second similarity to each matched work; get
      element isolation — request solo melody/harmony/rhythm for both tracks
      using source separation; get legal context — matched work's copyright
      holder, known litigation history, relevant case law)
- [x] **74.13.1.7** Implement SLA monitoring and escalation (track time from
      flag to decision; alert at 75% of SLA — 3 hours for 4-hour SLA;
      auto-escalate if SLA breached — reassign to next available reviewer at
      higher priority; track SLA compliance metrics; report on reviewer
      performance)
- [x] **74.13.1.8** Write review pipeline tests (test priority calculation —
      high_risk items queue before flag items; test reviewer assignment —
      musicologist assigned for melodic dispute; test decision recording —
      rationale stored, linked to provenance; test SLA escalation — item
      reassigned after timeout; test conditional approval — conditions attached
      to decision; minimum 30 tests)

---

### 74.14 Remediation Pipeline (`@themis/remediation`)

Automatically fix flagged content to preserve creative intent while eliminating
similarity.

#### 74.14.1 Project Setup & Implementation

- [x] **74.14.1.1** Create `libs/themis/remediation/` project scaffolding
      (project.json, package.json as `@themis/remediation`, tsconfig.json,
      vitest.config.ts, src/index.ts)
- [x] **74.14.1.2** Define remediation types (RemediationRequest with scanResult
      MusicShieldScanResult, flaggedElements array each with elementType/
      matchedWorkId/timeSegments, preserveIntent object with mood/energy/
      genre/tempo/key; RemediationResult with success boolean, modifiedAudio
      Float32Array, modifiedLyrics string or null, modifications array of
      {elementType, description, beforeSegment, afterSegment}, rescanResult
      MusicShieldScanResult confirming remediation cleared the flag;
      RemediationStrategy 'melody_variation'|'harmonic_reharmonization'|
      'lyric_reformulation'|'vocal_modification'|'rhythmic_variation'|
      'constrained_regeneration')
- [x] **74.14.1.3** Implement melody variation engine (accept flagged melodic
      segment with timestamps; analyze which notes contribute most to the match
      — n-gram overlap analysis; apply targeted modifications: pitch
      substitution — replace matching notes with neighbor tones ±1-2 semitones
      preserving contour direction; rhythmic variation — alter note durations
      while preserving pitch contour; intervallic expansion/ compression —
      stretch or shrink intervals by 1 semitone; ornamental variation — add
      grace notes, passing tones, turns; verify modified melody no longer
      matches reference by re-running melodic similarity; iterate up to 3 times
      with increasing modification intensity)
- [x] **74.14.1.4** Implement harmonic reharmonization (accept flagged chord
      progression with timestamps; suggest alternative harmonizations that
      preserve harmonic function: substitute IV with ii, V with viio, I with vi
      deceptive cadence; maintain voice leading smoothness; generate 3-5
      alternative reharmonizations ranked by similarity reduction and musical
      quality; verify each alternative clears the flag by re-running harmonic
      similarity)
- [x] **74.14.1.5** Implement lyric reformulation (accept flagged lyric lines
      with reference; preserve semantic meaning, meter, and rhyme scheme while
      changing specific words; use synonym substitution first — least
      disruptive; if insufficient, rephrase entire line preserving meaning and
      rhyme; verify phonetic dissimilarity — new lines must not sound like the
      reference when sung; re-run lyric similarity to confirm clearance)
- [x] **74.14.1.6** Implement vocal modification (accept flagged voice
      similarity match; apply targeted modifications to increase
      distinctiveness: formant shifting — shift F1/F2 by recommended amounts;
      vibrato adjustment — change rate/depth to diverge from reference artist;
      breathiness adjustment; ensure modifications preserve voice quality and
      naturalness; verify by re-running vocal similarity)
- [x] **74.14.1.7** Implement constrained regeneration (when targeted
      modification is insufficient, regenerate the flagged section entirely;
      pass negative constraints to generation model — 'do not produce melody
      similar to [reference]'; run shield scan as real-time constraint during
      generation — reject candidate outputs that still match; iterate up to 5
      times with tightening constraints; preserve creative intent — mood,
      energy, genre, tempo, key from original)
- [x] **74.14.1.8** Implement prompt risk assessment (before generation begins,
      analyze the prompt for copyright risk: references to specific artists →
      HIGH risk, references to specific songs → REJECT, genre/mood descriptions
      → NORMAL, specific musical parameters → LOW; auto-inject negative
      constraints for high-risk prompts — 'do not reproduce any existing
      copyrighted melodies'; log assessment in provenance)
- [x] **74.14.1.9** Implement remediation orchestrator (accept
      RemediationRequest; determine optimal strategy based on flagged elements —
      melodic flag → melody variation, lyric flag → reformulation, etc.; execute
      strategy; re-scan remediated audio through full shield pipeline; if still
      flagged, escalate strategy — targeted modification → constrained
      regeneration → human review; track remediation success rate; output
      RemediationResult with complete before/after documentation)
- [x] **74.14.1.10** Write remediation tests (test melody variation — modified
      melody no longer matches reference while preserving contour; test
      reharmonization — alternative chords are functionally equivalent; test
      lyric reformulation — meaning preserved, text similarity reduced; test
      vocal modification — distinctiveness increased; test constrained
      regeneration — iterative loop converges; test prompt risk — artist
      reference detected as high risk; minimum 40 tests)

---

### 74.15 Model Safety & Training Data Governance (`@themis/model-governance`)

Prevention is better than detection. Ensure models are safe before deployment.

#### 74.15.1 Project Setup & Implementation

- [x] **74.15.1.1** Create `libs/themis/model-governance/` project scaffolding
      (project.json, package.json as `@themis/model-governance`, tsconfig.json,
      vitest.config.ts, src/index.ts)
- [x] **74.15.1.2** Define model governance types (TrainingDataManifest with
      modelId, modelVersion, datasets array each with name/license/
      coversGenerativeUse boolean/optOutMechanism/recordCount/sourceUrl,
      totalRecords, deduplicationApplied boolean, differentialPrivacy with
      epsilon/delta or null, trainingDate; MemorizationTestResult with modelId,
      testType 'membership_inference'|'verbatim_reproduction'| 'canary',
      samplesTested, memorizationRate 0-1, flaggedSamples array; RedTeamResult
      with modelId, promptsTested, infringementDetected count,
      topVulnerabilities array each with prompt/matchedWork/similarity)
- [x] **74.15.1.3** Implement training data license verification (accept
      TrainingDataManifest; verify each dataset's license covers generative
      commercial use — CC-BY/CC0 = yes, research-only = no, custom = flag for
      manual review; check opt-out compliance against opt-out registry; output
      verification report with per-dataset status and overall compliance score;
      flag models trained on non-compliant data)
- [x] **74.15.1.4** Implement memorization detection via membership inference
      (given a model and a set of known training examples, test whether the
      model has memorized them; technique: generate continuations from first N
      seconds of training examples, compare to actual training data using audio
      fingerprinting; compute memorization rate — fraction of tested examples
      where continuation matches original with > 0.80 similarity; flag models
      with memorization rate > 5%)
- [x] **74.15.1.5** Implement verbatim reproduction testing (feed the model
      prompts designed to elicit copyrighted content — 'continue this melody'
      with first 4 bars of famous songs; test against top-100 most popular songs
      across decades; measure reproduction rate — fraction where output matches
      reference > 0.70 similarity; identify specific works the model is prone to
      reproducing)
- [x] **74.15.1.6** Implement canary testing (before training, insert known
      unique 'canary' sequences — synthetic melodies/rhythms/lyrics not present
      in any real music; after training, test if model reproduces canaries; high
      canary reproduction rate indicates high memorization risk; low canary
      reproduction suggests good generalization)
- [x] **74.15.1.7** Implement model red-teaming framework (systematic
      adversarial testing before deployment; prompt categories: artist-specific
      — 'make it sound like [artist]'; song-specific — 'a song about [specific
      topic of famous song]'; style-specific — '[producer]'s signature beat';
      test against representative sample of Billboard Hot 100, Grammy winners,
      most-streamed tracks; output RedTeamResult with vulnerability ranking;
      models failing red-team must be retrained or filtered)
- [x] **74.15.1.8** Implement opt-out registry (database of artists/rights
      holders who have opted out of AI training; CRUD operations with
      verification — opt-out requests must include proof of rights; query
      interface for model training pipelines to exclude opted-out works;
      periodic reconciliation — verify models in production were trained
      respecting current opt-out list)
- [x] **74.15.1.9** Write model governance tests (test license verification —
      research-only dataset flagged; test memorization detection — model that
      memorizes known examples is flagged; test canary testing — inserted canary
      detected in model output; test red-teaming — artist-specific prompt that
      triggers reproduction is caught; test opt-out registry — opted-out
      artist's work excluded from training manifest; minimum 35 tests)

---

### 74.16 Platform Integration API (`@themis/shield-api`)

REST API and integration layer for all consuming services.

#### 74.16.1 Project Setup & Implementation

- [x] **74.16.1.1** Create `libs/themis/shield-api/` project scaffolding
      (project.json, package.json as `@themis/shield-api`, tsconfig.json,
      vitest.config.ts, src/index.ts)
- [x] **74.16.1.2** Define API types and OpenAPI specification (document all
      endpoints: POST /scan — full scan, POST /scan/quick — fast-path scan, POST
      /scan/batch — batch scan, GET /scan/:id — retrieve scan result, POST
      /remediate — trigger remediation, GET /reference/:id — lookup reference
      work, POST /review/:id/decide — submit review decision, GET
      /provenance/:generationId — get provenance chain, GET /health — service
      health, GET /stats — scan statistics; generate OpenAPI 3.1 spec; generate
      TypeScript client from spec)
- [x] **74.16.1.3** Implement HTTP API server (Hono or Fastify framework;
      implement all endpoints defined in OpenAPI spec; request validation using
      Zod schemas derived from core types; multipart upload support for audio
      files; streaming response support for large batch results; authentication
      via API key or JWT; rate limiting per client; request/response logging for
      audit)
- [x] **74.16.1.4** Implement webhook notification system (allow clients to
      register webhook URLs for async scan results; when a scan completes, POST
      the result to registered webhook URL; support retry with exponential
      backoff on webhook delivery failure; webhook payload includes scan result,
      risk level, and action required; HMAC signature on webhook payloads for
      verification)
- [x] **74.16.1.5** Implement real-time scanning mode via WebSocket (WebSocket
      endpoint for streaming audio during generation; client sends audio chunks
      as they are generated; server runs continuous fast-path scan; server
      pushes similarity alerts in real-time; enables generation pipelines to get
      instant feedback without waiting for full track completion; graceful
      degradation — if server is overloaded, fall back to post-generation scan)
- [x] **74.16.1.6** Implement Calliope integration adapter (integrate shield
      into AI artist music publication pipeline; every track generated by a
      Calliope AI artist passes through shield before publication; configure
      per-artist scan settings based on genre, influences, and vocal identity;
      automatic retry on transient failures; block publication until scan
      completes with PASS or human APPROVE)
- [x] **74.16.1.7** Implement Euterpe integration adapter (hook into DAW/studio
      engine export pipeline; scan triggered on every audio export from Euterpe
      studio that involves AI-generated or AI-assisted content; lightweight
      integration — call shield API, block export until result received, display
      result in studio UI)
- [x] **74.16.1.8** Implement Isis integration adapter (hook into generative
      factory music production pipeline; scan every generated track as part of
      quality gate; batch mode for high-volume factory runs; configure
      factory-specific thresholds — may be more conservative than individual
      artist thresholds)
- [x] **74.16.1.9** Implement TypeScript SDK client (auto-generated from OpenAPI
      spec or hand-crafted for better DX; methods: scan, quickScan, batchScan,
      getResult, remediate, submitReview; connection pooling and retry logic
      built in; type-safe — all request/response types from core library;
      publish as `@themis/shield-client`)
- [x] **74.16.1.10** Write API integration tests (test full HTTP scan
      request/response cycle; test webhook delivery — mock server receives
      callback; test WebSocket real-time mode — streaming audio receives alerts;
      test authentication — unauthorized requests rejected; test rate limiting —
      excess requests throttled; test batch mode — multiple tracks scanned and
      results returned; minimum 35 tests)

---

### 74.17 Monitoring, Analytics & Continuous Improvement (`@themis/shield-analytics`)

The system must learn and improve continuously based on real-world performance.

#### 74.17.1 Project Setup & Implementation

- [x] **74.17.1.1** Create `libs/themis/shield-analytics/` project scaffolding
      (project.json, package.json as `@themis/shield-analytics`, tsconfig.json,
      vitest.config.ts, src/index.ts)
- [x] **74.17.1.2** Define analytics types (ScanMetrics with totalScans,
      scansByRiskLevel map, averageLatencyMs, p95LatencyMs, p99LatencyMs,
      cacheHitRate, engineLatencies map; FalsePositiveRecord with scanId,
      overrideDecision, originalRiskLevel, engine, reason; FalseNegativeRecord
      with generationId, thirdPartyClaimSource, claimType, matchedWork,
      missedByEngines array; ThresholdTuningRecommendation with engine,
      currentThreshold, recommendedThreshold, rationale, expectedFPRateChange,
      expectedFNRateChange)
- [x] **74.17.1.3** Implement false positive tracker (when a human reviewer
      overrides a FLAG or REJECT decision to APPROVE, record as false positive;
      track FP rate per engine, per genre, per reference work; identify engines
      or reference works with high FP rates; feed into threshold tuning;
      dashboard-friendly aggregations by day/week/month)
- [x] **74.17.1.4** Implement false negative tracker (when a published work
      receives a third-party copyright claim — Content ID, DMCA, legal — that
      the shield did not catch, record as false negative; this is the CRITICAL
      metric — every false negative is a potential lawsuit; root cause analysis:
      which engines should have caught it? what was the similarity score at scan
      time? was the reference work in the database? feed into reference database
      gaps and threshold tuning)
- [x] **74.17.1.5** Implement threshold tuning engine (analyze accumulated FP
      and FN data; use ROC curve analysis to find optimal threshold per engine —
      maximize true positive rate while minimizing FP rate; generate
      ThresholdTuningRecommendations; human approval required before applying
      new thresholds — never auto-adjust; provide impact prediction — 'lowering
      melody threshold from 0.55 to 0.50 would have caught 3 FNs but generated
      15 additional FPs this month')
- [x] **74.17.1.6** Implement analytics dashboard data provider (expose
      aggregated metrics via API for dashboard consumption: scan volume over
      time, risk level distribution, average/P95/P99 latencies per engine, most
      frequently matched reference works, match distribution by element type,
      genre risk heatmap — risk levels by genre, model risk tracking — flag
      rates per generation model; Prometheus metrics export for Grafana
      integration)
- [x] **74.17.1.7** Implement legal landscape monitor (track new music copyright
      cases via news API or curated feed; when a new decision is published,
      analyze its implications for threshold calibration; alert legal team when
      a case is decided that may affect Oshun's risk posture; track legislative
      changes — new AI music laws, voice right legislation, international
      regulations)
- [x] **74.17.1.8** Implement feedback loop to model training (aggregate
      patterns from human reviews — 'Model X consistently generates melodies
      similar to 2010s pop hooks'; generate model-specific reports for training
      team; identify which training data subsets correlate with high flag rates;
      recommend training data curation adjustments)
- [x] **74.17.1.9** Implement post-publication monitoring (monitor published
      works for third-party claims after publication — poll Content ID, track
      DMCA notices, monitor litigation filings; correlate claims with shield
      scan results; if a claim arrives for a work that scanned as PASS, record
      as false negative and trigger investigation; if a claim arrives for a work
      that scanned as FLAG/APPROVED, review the human decision that approved it)
- [x] **74.17.1.10** Write analytics tests (test FP tracking — override recorded
      and aggregated correctly; test FN tracking — third-party claim linked to
      scan result; test threshold tuning — recommendation generated with
      expected impact; test dashboard metrics — correct aggregation by time
      period; test post-publication monitor — claim correlated with original
      scan; minimum 30 tests)

---

### 74.18 Cross-Engine Integration & End-to-End Testing

Verify the complete system works as an integrated whole.

#### 74.18.1 Integration Testing

- [x] **74.18.1.1** Implement end-to-end integration test suite (create test
      fixtures: 10 synthesized 'reference tracks' with known melodies, chord
      progressions, lyrics, and vocal characteristics; index all fixtures in
      reference database; generate 20 'query tracks' with varying degrees of
      similarity — 5 direct copies, 5 with transposed melodies, 5 with modified
      lyrics but same melody, 5 completely original; run full shield scan on all
      query tracks; verify: direct copies → REJECT, transposed melodies → FLAG
      or HIGH_RISK, modified lyrics → FLAG, original tracks → PASS)
- [x] **74.18.1.2** Implement compound similarity integration tests (create test
      cases where individual elements score below threshold but compound
      similarity against the same work should escalate: melody 40% + lyrics 35%
      → individually below flag, but compound to same work should flag; verify
      compound detection correctly escalates these cases; create test cases
      where elements match different works — melody matches Song A, lyrics match
      Song B — verify compound does NOT escalate since they target different
      works)
- [x] **74.18.1.3** Implement remediation integration tests (create test tracks
      that are flagged for specific elements; run remediation pipeline; verify
      remediated track passes shield scan; verify creative intent preserved —
      same genre, similar mood, same tempo/key; verify specific infringing
      elements were modified while rest remains unchanged; test iterative
      remediation — first attempt still flagged, second attempt clears)
- [x] **74.18.1.4** Implement provenance chain integration tests (simulate full
      lifecycle: generate music → scan → flag → human review → approve with
      conditions → publish; verify complete provenance chain is reconstructable
      — every step logged with timestamps, actors, and rationale; verify tamper
      detection — modify a provenance record, verify hash check fails)
- [x] **74.18.1.5** Implement performance benchmarks (benchmark full scan
      pipeline on 3-minute track — target < 30 seconds; benchmark quick scan —
      target < 5 seconds; benchmark individual engines — identify bottlenecks;
      benchmark batch mode — throughput at 100 concurrent scans; measure memory
      usage under load; generate performance regression test baseline)

#### 74.18.2 Known Plagiarism Case Validation

- [x] **74.18.2.1** Implement validation against known plagiarism cases (obtain
      or synthesize audio approximating famous plagiarism cases: 'My Sweet Lord'
      vs 'He's So Fine', 'Blurred Lines' vs 'Got to Give It Up', 'Ice Ice Baby'
      vs 'Under Pressure'; run shield on the infringing works against the
      originals; verify the shield correctly identifies the similarity and
      classifies at FLAG or higher; document which engines detect the similarity
      and at what score)
- [x] **74.18.2.2** Implement validation against known non-infringement cases
      (synthesize audio approximating cases where courts found no infringement:
      'Thinking Out Loud' vs 'Let's Get It On', 'Dark Horse' vs 'Joyful Noise'
      on appeal; run shield; verify the shield does NOT classify as REJECT —
      these should be PASS or ADVISORY at most; if they flag, the thresholds may
      be too aggressive — document for calibration)
- [x] **74.18.2.3** Implement ongoing validation corpus (maintain a growing test
      corpus of known infringement/non-infringement pairs; run the full corpus
      as a regression test on every shield update; track classification accuracy
      — true positive rate for known infringements, true negative rate for known
      non-infringements; alert if any update degrades accuracy)

---

### 74.19 Documentation & Deployment

#### 74.19.1 Documentation

- [x] **74.19.1.1** Write developer guide for shield integration (how to
      integrate the shield into a new music generation pipeline; step-by-step:
      install @themis/shield-client, configure scan parameters, call scan API,
      handle results — PASS/FLAG/REJECT branching; code examples for TypeScript;
      document all configuration options; troubleshooting guide)
- [x] **74.19.1.2** Write reference database administration guide (how to add
      new reference works, manage ingestion pipelines, monitor database health,
      run deduplication, update protectability annotations; database backup and
      recovery procedures; scaling guide for growing reference database)
- [x] **74.19.1.3** Write human reviewer guide (how to use the review queue,
      interpret similarity scores, use A/B comparison tools, make and document
      decisions, escalate uncertain cases; training materials for new reviewers;
      genre-specific review guidelines)
- [x] **74.19.1.4** Write legal team guide (how to interpret risk assessments,
      understand jurisdiction-specific reports, use the provenance system for
      legal discovery, access audit trails, review case law citations in risk
      reports)

#### 74.19.2 Deployment & Operations

- [x] **74.19.2.1** Create Docker Compose configuration for shield services
      (shield API server, reference database PostgreSQL with pgvector, Redis for
      caching and perceptual hashes, BullMQ workers for async scans, Qdrant for
      vector similarity search; health checks for all services; development and
      production profiles)
- [x] **74.19.2.2** Create Kubernetes deployment manifests (Helm chart or
      Kustomize manifests for production deployment; horizontal pod autoscaler
      for scan workers based on queue depth; persistent volume claims for
      reference database; network policies; secrets management for API keys and
      database credentials)
- [x] **74.19.2.3** Implement database seeding pipeline (script to bootstrap
      reference database with initial data: MusicBrainz top-10K recordings, Lakh
      MIDI Dataset melodies, public domain collections, common phrase database,
      iconic drum break database, case law database; idempotent — safe to
      re-run; progress reporting; estimated initial seed time: 4-8 hours)
- [x] **74.19.2.4** Implement health check and monitoring setup (Prometheus
      metrics endpoint on shield API; Grafana dashboard template with: scan
      volume, latency percentiles, risk distribution, queue depth, cache hit
      rate, engine health, FP/FN rates; alerting rules: scan latency > 60s,
      engine health check failure, FN detected, queue depth > 1000)

---

### Phase 74 Summary — Themis Music Shield

| Section                                              | Number | Tasks   |
| ---------------------------------------------------- | ------ | ------- |
| 74.1 Shield Core & Pipeline Orchestration            | 74.1   | 18      |
| 74.2 Melodic Similarity Engine                       | 74.2   | 30      |
| 74.3 Harmonic Similarity Engine                      | 74.3   | 17      |
| 74.4 Rhythmic Similarity Engine                      | 74.4   | 12      |
| 74.5 Spectral & Timbral Similarity Engine            | 74.5   | 14      |
| 74.6 Lyric Similarity Engine                         | 74.6   | 14      |
| 74.7 Vocal Similarity Engine                         | 74.7   | 14      |
| 74.8 Structural Similarity Engine                    | 74.8   | 8       |
| 74.9 Audio Fingerprint Engine                        | 74.9   | 11      |
| 74.10 Reference Database System                      | 74.10  | 12      |
| 74.11 Legal Risk Scoring Engine                      | 74.11  | 11      |
| 74.12 Provenance & Audit Trail System                | 74.12  | 8       |
| 74.13 Human Review Pipeline                          | 74.13  | 8       |
| 74.14 Remediation Pipeline                           | 74.14  | 10      |
| 74.15 Model Safety & Training Data Governance        | 74.15  | 9       |
| 74.16 Platform Integration API                       | 74.16  | 10      |
| 74.17 Monitoring, Analytics & Continuous Improvement | 74.17  | 10      |
| 74.18 Cross-Engine Integration & End-to-End Testing  | 74.18  | 8       |
| 74.19 Documentation & Deployment                     | 74.19  | 8       |
| **TOTAL Phase 74**                                   |        | **232** |

---

**Phase 74 establishes the Themis Music Shield — the most comprehensive AI music
copyright protection system in the industry. 232 tasks across 19 sections
covering: core pipeline orchestration with multi-engine parallel scanning and
compound similarity detection; melodic similarity with pitch extraction, contour
analysis, n-gram matching, DTW, Smith-Waterman alignment, and transposition/
tempo invariance; harmonic similarity with chord extraction, common progression
filtering, and protectability scoring; rhythmic similarity with beat tracking,
drum pattern transcription, groove analysis, and iconic break detection;
spectral similarity with MFCC/chroma/neural embeddings, timbral fingerprinting,
and direct sample detection; lyric similarity with text/semantic/phonetic
matching, common phrase filtering, and joint lyric-melody analysis; vocal
similarity with speaker embeddings, anti-impersonation, and consent
verification; structural similarity with section segmentation and arrangement
analysis; audio fingerprinting with neural fingerprints, Content ID integration,
and segment- level matching; reference database with
MusicBrainz/AcoustID/MIDI/lyric ingestion, deduplication, and jurisdiction
mapping; legal risk scoring with case law database, jurisdiction-aware
assessment, and compound detection; provenance and audit trails for legal
defense; human review pipeline with priority queue, expert assignment, and SLA
monitoring; automatic remediation with melody variation, reharmonization, lyric
reformulation, and constrained regeneration; model governance with training data
audit, memorization detection, canary testing, and adversarial red-teaming;
platform integration API with REST, WebSocket, and adapters for
Calliope/Euterpe/Isis; monitoring and analytics with false positive/negative
tracking, threshold tuning, and legal landscape monitoring; cross-engine
integration testing with known plagiarism case validation; and deployment
infrastructure. Every generated note must be defensible.**

---
