Skip to content

feat(memos): named-transcript matches and the speaker-matches columns - #1550

Merged
hrustalq merged 2 commits into
devfrom
feat/1416-speaker-matches
Dec 3, 2026
Merged

hrustalq merged 2 commits into
devfrom
feat/1416-speaker-matches

Conversation

@hrustalq

@hrustalq hrustalq commented Dec 3, 2026

Copy link
Copy Markdown
Owner

Closes #1416
Refs #1402
Refs #1400

What this does

Phase 1's fourth session lands the two exact rungs of the evidence ladder (docs/features/89 § Evidence ladder) as
SpeakerMatch rows, and the columns they live in.

  • memos.speaker_matches and notes.speaker_matches — JSONB, NOT NULL DEFAULT '[]', beside participants. []
    is "no machine answer", never null, so there is one empty state and not two.
  • SpeakerMatch in @knowledge/contracts: { label, userId, confidence, margin, model, evidence, decidedAt },
    evidence: 'track' | 'metadata' | 'voice'. confidence/margin/model are null for both exact rungs because
    those rungs are exact; voice is phase 3's.
  • One pure function owns both rungs. A label the track manifest produced is track; any other named label is
    metadata; a manifest label wins over a metadata reading of the same label. A row needs an exact folded full
    name
    matching exactly one candidate — a stored participant whose userId is still a member, or a member's
    displayName. Two members sharing a name, a name nobody has, a first-name-only label, a numbered voice and a
    guest's name all produce no row: a suggestion at most, never a match, no user created.
  • memberNames in speakers.ts is the one workspace-member map (userId -> displayName, the same two reads and
    the same 2000-row cap loadSpeakers already used); the memo read, a Plaud import, a roster write and the tracks
    worker now share it instead of copying the query.

Why not resolveSpeakers yet

memos.speakers is the uploader's own statement and stays untouched. The rows are stored evidence for phase 3,
which will add matches as one more input to the pure resolveSpeakers and implement the precedence
(confirmed > remembered > metadata > auto > suggested, § Matches). Nothing on the wire changes in this task: no
MemoDetailResponse field, no DTO, no route. A future Zoom VTT adapter calls the same pure function from its own
import path.

The three write points

These are the three moments the exact evidence exists; there is no read-time write and no background job.

writer what it writes why
importPlaud the rows in the same create as the transcript Plaud's transcript is the named transcript phase 1 has; at import there is no roster, so the member map is the only candidate source. The existing early return stays: an already imported memo is not recomputed.
saveParticipants participants and speakerMatches in one update, re-running the rung the roster is the rung's other input and normally arrives after the transcript. The write replaces the rows it owns (track, metadata) and keeps voice rows — phase 3's, which this write did not decide. A second PUT replaces, never duplicates, and a malformed stored array reads [] instead of a stale partial answer.
memos.processor's tracks branch speakerMatches in the same update that stores the transcript the worker already holds the manifest and trackLabel; one track is one speaker, so those labels are track rows by construction. The single-file branch writes nothing — its labels are numbered voices.

No other writer: matchSpeaker, retry, confirm, triage and the sweeper are untouched.

Decisions and divergences

  • The field is evidence, not source. feat(memos): call participants 1.4 — named transcript mapping #1416's body says source: 'metadata'; the doc's SpeakerMatch (§
    Matches) has evidence: 'track' | 'metadata' | 'voice', and phase 3 reads that array. The doc wins; this is the
    issue's wording, named here as a divergence.
  • Both columns land, only the memo rows are written. The doc's § Operations assigns both memos.speaker_matches
    and notes.speaker_matches to 1.4. Phase 1 has no note writer (notes' participants carry no userId, and its
    named-transcript source is a later adapter), so the notes column has no writer until phase 3's voice rung. One
    additive migration now beats a second later one; no note writer was added to justify it, and apps/api/src/notes
    is untouched.
  • Files beyond the issue's four: the schema and its migration (the doc assigns the columns here), the contract
    type, speakers.ts's memberNames extraction, the processor's writer (the doc's Operations row assigns the
    track rows here too), CHANGELOG.md, and apps/api/test/plaud-import.spec.ts — whose fake needed the member
    reads importPlaud now performs, plus one assertion that the import writes the rows.
  • The issue's dto/memos.dto.ts needs no change. Nothing on the wire changes: no route accepts a transcript
    today beyond Plaud's own, and matches are internal until phase 3. A future Zoom VTT adapter calls the same pure
    function from its own import path; no field is invented now.
  • [] is the empty state, never null — like memos.participants; a null would be a second spelling of "no
    machine answer".
  • A match implies membership at write time. userId comes from a stored participant 1.2 already resolved, or
    from the member map itself; the read filters again when phase 3 lands. A guest is never a match and never a user.
  • No i18n key, env var, feature flag or model call. Every rule is a stored row; nothing refuses a request, and
    nothing asks a model to decide a match.
  • Generated outputs were regenerated once from the final tree (make api-client); nothing changed — the
    contract type is not on any route, so openapi.json, contract-schemas.json, schema.d.ts and the docs
    reference are byte-identical. No generated file is in this diff.

Per-criterion

#1416

criterion how it is met spec
An exact single name maps; an ambiguous one does not. speakerMatches: candidates are exact folded full names, deduped by userId; a row only when exactly one; two members sharing a display name yield none, and a first-name-only label yields none (that stays byName's suggestion). speakerMatches (#1416) › maps an exact single member name…, › stays silent when two members share the display name, › never matches a first name
A guest is named from the transcript but never becomes a user. A participant with no userId contributes no candidate; a member is a candidate only through the member map; no user is created anywhere. speakerMatches (#1416) › never turns a guest into a user, › matches a participant the roster resolved, and only while that person is a member
memos.speakers is untouched; the metadata match is a separate row/field. Rows go to speaker_matches; no writer touches speakers, and resolveSpeakers/MemoSpeaker are unchanged. MemosService speaker matches (#1416) › re-runs the exact rung… and › importPlaud writes… assert the write payload has no speakers; › replaces its own rows…
make verify passes. make verify exited 0: 350 test files / 5411 tests, lint, typecheck and dependency-cruiser green. —

#1402's named-transcript row

criterion how it is met spec
A named transcript maps an exact single name; two members with the same name produce no match. the pure rung plus the three writers above; track rows exist for the manifest path, so a named track is never re-read as a metadata guess. the two #1416 describes and MemosProcessor tracks › writes the manifest's exact rows…

Verification

ALTER TABLE "memos" ADD COLUMN     "speaker_matches" JSONB NOT NULL DEFAULT '[]';
ALTER TABLE "notes" ADD COLUMN     "speaker_matches" JSONB NOT NULL DEFAULT '[]';

Proven on a throwaway database created and owned by this task (speaker_matches_probe, dropped afterwards), with
prisma migrate deploy replaying every migration:

 table_name |   column_name   | data_type | is_nullable | column_default
------------+-----------------+-----------+-------------+----------------
 memos      | speaker_matches | jsonb     | NO          | '[]'::jsonb
 notes      | speaker_matches | jsonb     | NO          | '[]'::jsonb

make verify → 350 test files passed, 5411 tests passed. make db-generate regenerated the Prisma client;
make api-client regenerated the client from the final tree and changed nothing (no wire surface).

Review

Independent review before opening this PR (spec + work, fresh context), sliced by area: the mapper/parser, the three
writers, the schema + migration + contract, the pure-rung cases, the service-write cases, the Plaud spec +
changelog, and the fixture/processor cases.

  • Fixed: the roster-recompute case could not tell stored-transcript labels from the PUT's own names — the fixture
    used one label that was both. A member named only in the transcript now has to produce a row, and the second-PUT
    case asserts the first write too (b8a711a8); the delta review confirmed both blocks close.
  • Rejected: "the address branch of the harness filters by memberIds, so the membership read is unused" —
    production filters membership inside the same user.findMany query (memberships: { some: { workspaceId } },
    storedParticipants), and the harness models that predicate with the same memberIds array that builds
    workspaceMember.findMany, so the two cannot disagree. The member map itself is load-bearing: the amended case's
    Bob row comes from displayName alone.
  • Rejected: "second-PUT duplication rests on unshown harness persistence" — the harness's memo.update applies
    Object.assign(row, data) (apps/api/test/memos.spec.ts:1376), so the second call reads what the first wrote.
  • Deferred: none; the schema/contract, Plaud/changelog and fixture/processor slices passed with no findings.

Write the two exact rungs of the evidence ladder (#1416) as `SpeakerMatch`
rows: a label a track manifest produced is `evidence: 'track'`, any other
named label is `'metadata'`. A row needs an exact folded full name matching
exactly one participant/member; an ambiguous name, a name nobody has, a
numbered voice and a guest produce nothing. Both columns land (`memos`,
`notes`); the notes column has no writer until phase 3's voice rung.

Writers: `importPlaud` in the create, `saveParticipants` re-running the rung
(keeping `voice` rows), and the tracks worker in the transcript update.
`memos.speakers`, `resolveSpeakers` and the wire are untouched.

Refs #1416
The roster test's label and member name were identical, so a writer that
read labels from the PUT instead of the stored transcript would have passed
it. A member named only in the transcript (never in the PUT) now has to
produce a row, and the second-PUT case asserts the first write too.

Refs #1416
@hrustalq
hrustalq merged commit 8a2e123 into dev Dec 3, 2026
3 of 4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant