Skip to content

feat: add conversation landscape gate, producer wiring, and canary test - #1438

Merged
ussaama merged 17 commits into
mainfrom
feat/landscape-gate
Dec 2, 2026
Merged

ussaama merged 17 commits into
mainfrom
feat/landscape-gate

Conversation

@JorimTheuns

@JorimTheuns JorimTheuns commented Nov 30, 2026 •

Copy link
Copy Markdown
Member

Summary

Adds the expand-only conversation landscape gate schema, gate helpers, room producer wiring across all six producer sites, and a canary integration test. Existing non-deleted rows have landscape_status IS NULL and behave unchanged in room producers; home search transcript lookup also now excludes soft-deleted conversations (c.deleted_at is null) so rejected conversations cannot leak in private reads.

Schema and migration

  • Adds 8 nullable columns (landscape_status, landscape_review, landscape_text, landscape_text_hash, landscape_consent_version, landscape_decided_at, landscape_moderation, landscape_entered_at) and 3 check constraints (conversation_landscape_status, conversation_landscape_review, conversation_landscape_entry) to conversation in dembrane/platform/packages/db/src/schema/index.ts.
  • Adds 0064_expand_conversation_landscape.sql (with matching Drizzle snapshot and journal entry): combines all 8 ADD COLUMN IF NOT EXISTS clauses into one ALTER TABLE "conversation" statement and adds all 3 constraints NOT VALID inside idempotent DO blocks so the conversation table is not scanned under lock and migration re-runs remain safe.

Gate helpers and producer sites

  • Exports inLandscapeRoom, inRoomSql, and usesAcceptedText from dembrane/platform/packages/db/src/landscape.ts (re-exported from @dembrane/db), with a pure cross-product unit test in dembrane/platform/packages/db/test/landscape.test.ts.
  • dembrane/platform/packages/analysis/src/recipes/services.ts: gates loadTranscripts and countConversationsWithTranscripts with inRoomSql; gated rows read landscape_text and use the neutral Conversation n label. isoTimestamp in dembrane/platform/packages/legacy-shape/src/directus.ts also handles Date instances returned by raw postgres.js clients.
  • dembrane/platform/packages/popcorn/src/storage.ts: gates transcripts() and waitingConversations() with deleted_at IS NULL and inRoomSql, joins conversation when fetching chunks, and emits landscape_text (with neutral label) for gated rows.
  • dembrane/platform/packages/conversations/src/v1/storage.ts and reply.ts: gates adjacent, adjacentContent, and adjacentConversations with inRoomSql and substitutes landscape_text for both conversation.summary and conversation_chunk.transcript on gated rows.
  • dembrane/platform/packages/canvas/src/storage.ts: gates gatherConversations and gatherChunks with deleted_at IS NULL and inRoomSql, masks participant_name, and returns landscape_text for gated rows.
  • dembrane/platform/packages/conversations/src/search/storage.ts: adds c.deleted_at is null in reachableConversations (behavior fix for soft-deleted conversations, matching searchStorage.conversations() and required so rejected conversation chunks cannot appear in home search).

Canary test

  • Adds dembrane/platform/apps/api/test/landscape-canary.integration.test.ts, seeding a legacy conversation plus gated conversations in pending, accepted (review null), held, host_rejected, rejected (deleted_at set), and entered (landscape_entered_at set). Verifies all six room producer sites (Map/analysis, Popcorn, Explore, and Canvas), DB check constraints (wrapping postgres.js lazy queries in native Promises so Bun expect().rejects exits promptly), and private reads (Ask retrieval, report input, and home search).

Verification

  • bunx drizzle-kit generate < /dev/null: reports No schema changes, nothing to migrate.
  • bun run lint: 0 errors.
  • bun run typecheck: passes.
  • bun run packages check: passes.
  • bun test packages/db/test/landscape.test.ts packages/analysis/test/load-transcripts.test.ts apps/api/test/landscape-canary.integration.test.ts: 12 pass, 0 fail (canary 7 tests). Touched packages: 520 pass; the only failures are a DBOS "already registered" error when several conversations suites share one process, which fails the same way on the base branch.

Review fixes

  • Merged the updated feat: add ParticipantTokens.require and portal X-Participant-Token header plumbing #1439, which now includes current main.
  • The migration was renumbered from 0060 to 0064 with a fresh journal timestamp, because main's support migrations took 0060 to 0063 and an older when would make Drizzle skip it. The SQL is the same hand-written idempotent expand with NOT VALID checks.
  • Policy is written down in landscape.ts and pinned by a canary: room producers (Map, Popcorn, Canvas, Explore) are gated, while host-private reads (search, Ask, reports) only drop soft-deleted rows. The new canary test checks that host search still finds pending, held and host-rejected conversations.
  • Gates: typecheck, biome, packages check, canary 7/7. The landscape, popcorn, canvas, conversations and verify suites all pass. Some pipeline files fail only when run together in one process (DBOS registry); each passes on its own.

Merge order: #1437, then #1439, then #1438.

@JorimTheuns
JorimTheuns changed the base branch from main to feat/portal-participant-token November 30, 2026 12:19
@JorimTheuns
JorimTheuns force-pushed the feat/portal-participant-token branch from 24b8fbb to ee3da74 Compare December 1, 2026 22:33
… it on finish

- A participant.token_invalid answer clears the stored token and resends the call
  once without it (the server checks the token before doing anything), so a chunk
  upload is not lost. The retry logs a warning.
- Only participant.token_invalid counts as a rejection; other 403s keep the token.
- The finish screen keeps the token while open (report sign-up, the landscape
  step) and clears it on leaving, deferred so StrictMode's dev remount does not
  count; /start still clears every token.
- Verify helpers take the conversation id as a required string.
The regex pass alone let names through. After it, a fast model call names the
personal details left and code replaces exactly those spans (any casing, whole
words, capitalised name parts too, never a joining word like van/los/des
alone), so the markdown and the rest of the text stay as typed.

- Only edited text is checked; approving the unedited draft makes no call.
- A failed or non-JSON answer (after one retry) saves nothing:
  verify.generation_failed.
- content is capped at 20,000 characters and the check is rate limited per
  conversation (20 per 10 minutes), since it runs outside the AI allowance.
…t-pii-redaction

# Conflicts:
#	dembrane/platform/PACKAGES.md
…participant-token

# Conflicts:
#	dembrane/frontend/src/locales/cs-CZ.po
#	dembrane/frontend/src/locales/de-DE.po
#	dembrane/frontend/src/locales/en-US.po
#	dembrane/frontend/src/locales/es-ES.po
#	dembrane/frontend/src/locales/fr-FR.po
#	dembrane/frontend/src/locales/it-IT.po
#	dembrane/frontend/src/locales/nl-NL.po
#	dembrane/frontend/src/locales/uk-UA.po
# Conflicts:
#	dembrane/platform/packages/db/migrations/meta/0060_snapshot.json
#	dembrane/platform/packages/db/migrations/meta/_journal.json
Base automatically changed from feat/portal-participant-token to main December 2, 2026 13:44
@ussaama
ussaama merged commit 33428bd into main Dec 2, 2026
18 checks passed
@ussaama
ussaama deleted the feat/landscape-gate branch December 2, 2026 13:56
@ussaama
ussaama deployed to pr-preview December 2, 2026 13:56 — with GitHub Actions Active
@github-actions

github-actions Bot commented Dec 2, 2026

Copy link
Copy Markdown
Contributor

Now on staging, deployed 2026-12-02 14:08 UTC.

This branch was successfully deployed

1 active deployment
pr-preview — c0d88593 Deployed Dec 2, 2026 by ussaama via 51-teardown-pr-preview #1630
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants