Skip to content

feat(memos): the participants column, its contract and the memo detail read - #1547

Merged
hrustalq merged 2 commits into
devfrom
feat/1413-memo-participants
Dec 3, 2026
Merged

hrustalq merged 2 commits into
devfrom
feat/1413-memo-participants

Conversation

@hrustalq

@hrustalq hrustalq commented Dec 3, 2026

Copy link
Copy Markdown
Owner

Closes #1413
Refs #1402
Refs #1400

What

memos.participants — one JSONB column beside speakers — MemoParticipant in @knowledge/contracts, and the memo detail read returning it. No write route, no email mapping, no tracks, no voice: #1414–#1416 own those.

The column

participants Json @default("[]") @map("participants")

Not nullable: the default backfills every existing row, so the read never meets null in the column, and an empty list means "nobody was named", which is not "unknown". The migration is one additive statement:

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

No FK, no index, no backfill and no other table (make db-migrate-new cannot run on the shared dev database — the app user does not own _prisma_migrations — so the DDL was generated with prisma migrate diff --from-schema-datamodel and proven on a throwaway database, below). Rollback is DROP COLUMN and loses only the column.

The wire type

MemoParticipant is the doc's § Participants table as a type: name, optional email/userId/trackKey, required external and source: 'manual' | 'metadata'. external is derived on read as userId === null after the membership check and is never stored, so a guest who joins or a member who leaves needs no rewrite of the row. userId is a member resolved from a verified email (write side, #1414); the read re-checks membership and drops the link when the person is gone.

Detail, not list

participants is top-level on MemoDetailResponse, after speakers. It is not on MemoInfo: that is the list row, and the list route omits the array by design (#1413, doc § Backward compatibility). toInfo is untouched.

The read and the loadSpeakers trap

MemosService.get reads participants through a private readParticipants(row), never through loadSpeakers' members map. That map is new Map() whenever the transcript has no labels (speakers.ts:96), so a roster listed before the memo is transcribed would read every userId as gone. Membership is its own read — one workspaceMember.findMany({ where: { workspaceId, userId: { in: ids } }, select: { userId: true } }), only when at least one participant names a userId — and the two questions ("who is this transcript label" and "who did the recording say was present") stay separate.

The parse refuses instead of guessing, mirroring notes.service.ts's participantsOf: a stored value that is not an array of objects with a non-empty string name reads as [], never a partial list; unknown keys are dropped; every absent optional is null on the wire, so a client never distinguishes absent from null. source defaults to 'manual' only when the key is absent — a hand-edited-row default, not a back-compat policy — and a present value outside the two refuses the list, because mapping it would be a claim the code cannot check. Nullability: email, userId and trackKey are ?: string | null; external: boolean and source are required; the API always sends all six.

The MCP read gains it for free

knowledge_get_memo returns memos.get(principal, id) whole (mcp/tools/workspace.ts:40) inside wrapUntrusted, so #1402's "MCP read includes participants" is met by this read with no change of its own and no page-text spec moving.

Generated outputs

MemoDetailResponse is on the wire (@Returns('MemoDetailResponse')), so make api-client was run once from the final tree. It regenerated apps/api/openapi.json, apps/api/src/config/contract-schemas.json and packages/api-client/src/schema.d.ts; apps/api/src/common/contract-responses.generated.ts and apps/web/src/modules/help/docs/reference.generated.json were byte-identical (no new @Returns name, no new route/tool), so they are not in the commit.

Divergences from the issue

  • The issue's Files list names five files; this PR also carries apps/api/src/config/contract-schemas.json, apps/api/openapi.json, packages/api-client/src/schema.d.ts and CHANGELOG.md, because the response type is on the wire and a schema change is notable. The other two generated outputs in the brief's list are no-ops.
  • apps/api/openapi.json's info.version moves 0.64.0 → 0.65.0. That is not this change: the committed document lagged PRODUCT_VERSION (apps/api/src/config/version.ts), and make api-client from this tree carries the catch-up. Named here so the hunk is not read as scope creep.
  • Nothing else diverges: the doc's § Participants, § Backward compatibility and § Matches are implemented as written; the doc wins where the issue and the doc differ, and they do not here.

Acceptance — #1402 (phase 1)

criterion status evidence
A two-track manifest yields two named speakers and a participant list; a mixed file yields numbered speakers plus the roster deferred to #1415 tracks and per-track transcription are 1.3
A participant email matching a verified member becomes userId; a guest stays external; a deleted member loses the link partly — the read half met, the write half deferred to #1414 readParticipants drops an id the workspace no longer holds and derives external; no email is mapped anywhere yet
A named transcript maps an exact single name; two members with the same name produce no match deferred to #1416 1.4
PUT participants is uploader-only (or the note owner), and a participant cannot be used to grant access deferred to #1414 no route ships; a participant is detail only and reaches no permission check
make verify; specs cover the manifest, email mapping, guest and ambiguous name partly make verify green; the roster read's specs are here, the manifest/email/ambiguity specs come with #1415/#1414/#1416
MCP read includes participants met knowledge_get_memo returns memos.get whole

Verification

  • make verify — exit 0: 350 test files, 5363 tests passed (pnpm --filter @knowledge/api test: Test Files 350 passed, Tests 5363 passed).
  • make db-migrate on the shared dev database — fails with permission denied for table _prisma_migrations, before and after this change (the app user does not own that table). Not a fault in this diff; the migration was proven on a throwaway database the app user owns:
    • prisma migrate deploy applied all migrations including 20270221100000_memo_participants; a second run said No pending migrations to apply.
    • information_schema.columns → participants | jsonb | NO | '[]'::jsonb; an INSERT that named no participants returned []; status, locale and source took their defaults.
    • Rollback: ALTER TABLE "memos" DROP COLUMN "participants"; removed the column and left memos' other 30 columns intact; re-applying the ADD restored [] on the existing row. The database was dropped afterwards.
  • make api-client — exit 0 (both web apps' typecheck ran as part of it).
  • Load-bearing checks (scripts/load-bearing-check.py, file restored after each): replacing the membership read with an empty set → 3 cases red; dropping workspaceId from the membership where → 3 red; letting the parse skip a bad entry instead of refusing the list → 1 red.

Review

Independent review before opening this PR — six fresh-context slices over the committed range (spec + work axes), then a delta round on the fix.

  • Fixed: the "leaves the row as stored" case compared the fixture array to itself, so an in-place mutation of the stored entry still passed. The expectation is now a written-out literal, and it was proven load-bearing — mutating the stored entry in place turns that case red → 3598a936.
  • Rejected: "participants added to toInfo, so the list route gains the field" — the added line is inside get's return object (memos.service.ts:287); toInfo begins at line 654 and never names participants, and list maps toInfo into MemoInfo, which has no such field.
  • Deferred: none.

@hrustalq
hrustalq merged commit 79e9903 into dev Dec 3, 2026
2 checks passed
@hrustalq
hrustalq deleted the feat/1413-memo-participants branch December 3, 2026 09:58
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