Repository navigation
fix: redact PII on manual Verify artifact edits in anonymised projects - #1437
Merged
Merged
Conversation
JorimTheuns
force-pushed
the
fix/verify-manual-edit-pii-redaction
branch
from
December 1, 2026 22:29
98ffb51 to
7c2d14e
Compare
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
ussaama
approved these changes
Dec 2, 2026
Contributor
|
Now on staging, deployed 2026-12-02 13:44 UTC. |
ussaama
added a commit
that referenced
this pull request
Dec 2, 2026
…st (#1438) ## 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 #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. --------- Co-authored-by: Usama <reach.usamazafar@gmail.com> Co-authored-by: Usama <59267656+ussaama@users.noreply.github.com>
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Manual edits to Verify artifacts (
PUT /api/verify/artifact/:artifact_idwithcontent) previously bypassed PII redaction even when the project hadanonymize_transcriptsenabled. This change runs deterministic PII redaction synchronously on manual edits for anonymised projects before storing and returning the artifact.Changes
@dembrane/transcriptionas a workspace dependency of@dembrane/verify(namespace->capability) and updateddembrane/platform/PACKAGES.mdanddembrane/platform/bun.lock.updateArtifactindembrane/platform/packages/verify/src/service.tsto passbody.contentthroughregexRedactPiiwhenproject.anonymize_transcripts === true, leaving non-anonymised projects (falseornull) untouched.dembrane/platform/packages/verify/test/manual-edit-redaction.test.tsand database-backed route tests indembrane/platform/packages/verify/test/prompt-privacy.integration.test.tsverifying both anonymised and non-anonymised projects.Verification
bun test packages/verify(34 pass, 0 fail; 35 Postgres-backed integration tests skipped locally withoutTEST_DATABASE_ADMIN_URL)bun run packages checkbun run typecheckbunx biome ci .bun install --frozen-lockfileReview fixes (supersede the Changes above where they differ)
text_fast, no thinking) that only lists PII spans. Code does the replacing, so the markdown and the typed text stay intact.verify.generation_failedand nothing is stored.verify.edit_redaction: 20 per conversation per 10 minutes.contentis capped at 20,000 characters (422 above that).Known limits