Skip to content

feat(memos): call participants 3.3 — resolveSpeakers precedence, rejection and tests - #1567

Merged
hrustalq merged 1 commit into
devfrom
feat/1564-speaker-precedence
Dec 4, 2026
Merged

hrustalq merged 1 commit into
devfrom
feat/1564-speaker-precedence

Conversation

@hrustalq

@hrustalq hrustalq commented Dec 4, 2026

Copy link
Copy Markdown
Owner

Closes #1564
Refs #1404
Refs #1400

What

resolveSpeakers now reads the machine answers phase 1 and 3.2 store, in one precedence under the uploader's own choice: confirmed > remembered > metadata > auto > suggested, first match wins.

  • MemoSpeaker.source gains 'metadata' and 'auto' — additive on the wire; a stored confirmed/remembered row reads exactly as today.
  • track and metadata rows both read as source: 'metadata'. The wire keeps two evidence values because the writer knows which exact rung answered; source says how a name was decided, and both are source-provided facts.
  • A voice row becomes auto only when confidence and margin are both non-null and each reaches its SPEAKER_AUTO_* line. Below either line, or with a null margin, the row only fills suggestedUserId and never a userId; the shipped 1.0/1.0 defaults keep auto off until phase 5.
  • member() stays the one filter on every rung: a machine row naming someone who has left is not evidence and falls through, while a chosen id stays final (answering userId: null and no suggestion) and a chosen null — "not them" — suppresses every machine row for its label.
  • A numbered voice (Speaker 1, Участник 2) takes metadata, auto and a suggestion, and is still never remembered or read as a name.
  • readSpeakerMatches moved from participants.ts to speakers.ts, and loadSpeakers takes the two lines from its caller so the resolver stays pure. MemosService reads them once in its constructor; the secretary reads them per run from svc.config.

The read is additive: no stored row changes, and no route, DTO, schema or migration. memos.speakers is still never written by a machine. The web page's 'remembered' hint needs no change — the chips are phase 4.

Divergences

  1. The doc's five-rung precedence ships, not the epic's four. feat(memos): call participants phase 3 — match diarized voices to enrolled members #1404's line omits metadata; docs/features/89 § Matches states confirmed > remembered > metadata > auto > suggested and names the omission, so the doc wins.
  2. readSpeakerMatches moved from participants.ts to speakers.ts. participants.ts already imports isNumberedVoice from speakers.ts, so importing back would be a module cycle. The reader sits beside readChoices — both parse the memo's speaker-shaped JSON — and participants.ts keeps the exact-rung writer speakerMatches().
  3. One stale sentence corrected. SPEAKER_MIN_SECONDS' JSDoc and .env.example line said no pipeline reads it until 3.2 wired the sampler; the sampler shipped in feat(memos): speaker sampling and per-label embeddings #1562, so both now name speaker-sampling.ts. No value change.
  4. Generated drift. make api-client moved exactly the MemoSpeaker.source enum in openapi.json, contract-schemas.json and schema.d.ts; reference.generated.json did not change because the endpoint and MCP-tool inventories did not. No earlier feature's rows were carried, so nothing had to be reverted.

Acceptance (#1564)

criterion evidence
Precedence case by case: confirmed > remembered, remembered > metadata, metadata > auto, auto > suggested; a stale member dropped from every rung apps/api/test/memo-speakers.spec.ts → resolveSpeakers precedence (3.3): the six ordering cases plus drops someone who has left from every rung and reads a stale exact row as no evidence
Above both lines source: 'auto'; below either or a null margin suggestedUserId with userId: null makes a voice row auto only above both lines, and a question below either — the lines are inclusive (0.85/0.1 clears), and 0.84, 0.09, a null margin and a null confidence each only suggest
A metadata/track row not overridden by a .99 voice row lets a track or metadata row beat a 0.99 voice row, and a track beat a metadata row
A numbered voice takes metadata/auto/suggested, never remembered or byName lets a numbered voice take metadata, auto and a suggestion, but never remembers or reads its name; the fixture includes a member whose display name is Speaker 1
PUT /v1/memos/:id/speakers with null suppresses its machine row on the next read apps/api/test/memos.spec.ts → MemosService speaker matches → answers a "not them" choice by suppressing the machine row on the next read — the route is a thin wrapper over matchSpeaker
make api-client committed, make verify green make api-client exited 0 (contract schemas, API build, OpenAPI, docs reference, typed client, web + admin typecheck); make verify exited 0 with @knowledge/api:test and @knowledge/api:typecheck cache misses: 357 files, 5574 passed, 1 skipped

What #1404 gains

#1404 acceptance row this task moves state
A track/metadata match is not overridden by a weaker voice match met by the read: metadata outranks auto unconditionally, and only an exact row naming a non-member falls through
A manual correction wins over auto; "not them" suppresses it met by the read and the write: a chosen label answers confirmed and the machine row is never consulted; the matchSpeaker case pins the stored null
Two enrolled members auto-labelled, an unenrolled third unknown; low confidence/margin only suggested; too-short label never auto 3.2's writer and this read's threshold rule; the end-to-end proof stays 3.4's
A revoked profile stops matching; workspace A's profile never matches a workspace B memo 3.2 (#1563) and 3.4's isolation spec — untouched here

Review

Independent review before opening this PR (spec + work, fresh context, five area slices: resolver, precedence spec, wiring, service spec, changelog).

  • Fixed: nothing — no blocking finding survived.
  • Rejected (slice artifact): "apps/api/src/memos/speakers.ts:1 — absent; loadSpeakers required-threshold signature unverified" on the wiring slice — that diff carries the call sites, not the callee. speakers.ts:210-218 declares thresholds: SpeakerThresholds as a required third parameter, and the slice holding it passed. Re-dispatched with the callee's file:line inline → pass.
  • Deferred: none.

The first dispatch wave was interrupted provider-side ("waiting for model response", all children at the same wall-clock) and re-sent at the same slices; no verdict was read from an interrupted call.

…achine answers

`MemoSpeaker.source` gains `metadata` and `auto`, and `resolveSpeakers` reads
the stored `SpeakerMatch` rows in one precedence under the uploader's own
answer: confirmed > remembered > metadata > auto > suggested. A `null` choice
is "not them" and suppresses every machine row for its label; a machine row
naming someone who has left is not evidence and falls through; a `voice` row
above both `SPEAKER_AUTO_*` lines becomes `auto`, and below either line it only
fills `suggestedUserId`. A numbered voice takes metadata/auto/suggested and is
still never remembered or read as a name.

`readSpeakerMatches` moves from `participants.ts` to `speakers.ts` —
`participants.ts` already imports `isNumberedVoice` from there, so the back
import would be a module cycle — and `loadSpeakers` takes the two thresholds
from its caller, keeping the resolver pure. Both write their own env values:
`MemosService` reads them once in its constructor, the secretary per run.

The thresholds keep their 1.0/1.0 defaults, so auto stays off until phase 5's
labelled corpus sets them, and an old confirmed/remembered answer reads as
before. The `SPEAKER_MIN_SECONDS` copy now names the sampler that reads it.

Refs #1564
@hrustalq
hrustalq merged commit 280bcb9 into dev Dec 4, 2026
2 checks passed
@hrustalq
hrustalq deleted the feat/1564-speaker-precedence branch December 4, 2026 09:38
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