Repository navigation
refactor(transcripts): one shared transcripts collection, with a file source - #1075
Conversation
`meditation-transcripts` held one row per meditation and nothing else
could use it, so a Path Step's intro subtitles had nowhere to live.
The collection is now `transcripts`, with one polymorphic `source` to
`meditations` or `files` in place of the `meditation` relationship.
`required` on a polymorphic field is the whole exactly-one-of rule and
costs no `NOT NULL`, since the value lives in `transcripts_rels` rather
than a column; `unique` becomes one `UNIQUE(<target>_id, path)` per
target there, so one transcript per meditation still holds and one per
file now does too.
Three costs come with that shape and are paid here. `CascadeRule` grows
an optional `relationTo`, because a bare polymorphic path throws
`APIError('Not supported')` when the query is built. `isDuplicateTranscript`
reads the `Key (…)` list out of Postgres's own `detail`, because
`adapter.fieldConstraints` is filled only for column-backed relationships.
And `CleanupOrphanedMedia`'s id extraction learns the `{ relationTo, value }`
shape, keyed on the target the reference was discovered for — read blind it
would have let meditation 7 protect file 7.
The orphan sweep is replaced by a `beforeDelete` cascade from both
parents. With a rels table there is no `meditation_id` left to null, so a
deleted parent would otherwise leave a row with no source at all, which
`required` makes unloadable.
A fourth cost was not in the plan and is a security clause: the client
read was narrowed by `meditation._status`, and Payload resolves no path
deeper than `source.relationTo` / `source.value` on a `relationTo` array.
The clause cannot be written, so the client read of the collection is
refused instead of weakened. The collection is already admin-only working
data in the public spec and neither consumer repo reads it.
The Lemonfox response normaliser moves to `src/lib/lemonfox/normalize.ts`,
where its two existing consumers can reach it without a cross-owner
import.
Refs #1043
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjW1orNDZGrrU6t9wCJ
…o a rels table The generator answered `create` for both the renamed table and the new rels table, which would have dropped all 122 production transcripts. Every name here is its own; only the statements that lose data are replaced, so `up()` renames the table, the two enums and the locked-documents column, then inserts one `transcripts_rels` row per transcript before dropping `meditation_id`. `down()` recreates the column, reads the ids back out of the rels table and drops it. Verified on a scratch Postgres carrying the whole chain: two pre-migration rows, one rels row each after `up`, and a byte-identical row dump after `down`. Refs #1043 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjW1orNDZGrrU6t9wCJ
…refused client read
Every new assertion was watched failing against its own defect first:
both `beforeDelete` hooks removed, the `queueTranscription` source-kind
guard removed, `required` dropped from `source`, `isDuplicateTranscript`
left reading `path === 'meditation'`, and the orphan-media extractor left
unable to read `{ relationTo, value }` — then, separately, "fixed" by
reading `value` blind, which is what the second half of that pair catches.
The retention cases are gone with the window they covered, and
`retention-discovery` now asserts the collection is absent from the sweep
instead. The client access case inverts: every key is refused, with the
editor as the control.
Docs follow the rename, and architecture.md records why the client read
went rather than being narrowed.
Refs #1043
Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjW1orNDZGrrU6t9wCJ
Four review lenses over the branch diff converged on the same shape: the new seams asked a caller for facts the code can read itself. `CascadeRule.relationTo` is gone. `BeforeDeleteHook` already receives the collection it runs on, and the child's own `flattenedFields` say whether its field is polymorphic — so both registrations now read exactly like `Albums.ts`, and a rule can no longer name a parent that disagrees with where it is registered (which would compile, delete nothing, and leave the parent's delete to fail on the foreign key). That cascade's child delete also stops hydrating rows nothing reads. `FieldReference.targetCollection` is gone the same way: polymorphism is already in `relationTo`, and the swept slug was in scope at the one production call site. `polymorphicId` now branches on the walk's answer instead of sniffing keys off the stored value — the discipline `localeValues` states one function above it. `transcriptSourceWhere` replaces seven hand-spelled copies of the polymorphic `where` and six copies of its hazard comment. The wrong spellings are wrong at run time and fine at build time, so one builder carrying the ⚠ is the only thing that can keep the call sites together. The client refusal moves out of `CLIENT_PARENT_STATE_SCOPES`, which is about narrowing a read to a parent's state and was made to carry `false` plus an undefined-vs-false guard. It has its own named list now. Refs #1043 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjW1orNDZGrrU6t9wCJ
`src/AGENTS.md` enumerates the `src/lib/` folders twice — the external-service clients and the no-barrel list — and the normaliser's new home was in neither. Says why the HTTP client stayed in the job folder, so the split reads as deliberate rather than half-finished. Refs #1043 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjW1orNDZGrrU6t9wCJ
The security sweep found the refusal sitting under the published-only branch, which returns a narrowed `Where` — a grant. Unreachable today, because `transcripts` declares no `versions`, but it fails open: the day the collection gained drafts, that branch would match first and every client key would read every transcript again. So the refusal moves to the top of the block and drops the live-preview exemption, which exists to let a credentialed preview see unpublished work — not to decide which collections a client key may reach at all. `CLIENT_PARENT_STATE_SCOPES` had no entries left once `transcripts` moved out, so it goes rather than sitting empty behind a docblock. Its #968 story is now in `docs/rules/access.md` beside the choice between `CLIENT_UNREADABLE` and `RESTRICTED_COLLECTIONS`, with a row in the decision table. Refs #1043 Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjW1orNDZGrrU6t9wCJ
|
🚅 Deployed to the SahajCloud-pr-1075 environment in sahajcloud
1 service not affected by this PR
|
sydevs-bot
left a comment
There was a problem hiding this comment.
1 question for the reviewer, one per thread.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
|
🤖 no session running recent dispatchesWritten by the sydevs dispatcher. Sessions never edit this comment. |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
The diff matches the ticket: a rename across 13 src/ sites, one shape change, and the four costs #1043 priced in advance. The aggregate question — four bespoke pieces (transcriptSourceWhere, polymorphicId, polymorphicField, targetCollection threaded through three signatures) — is settled by the 2026-11-02 choice of a polymorphic source over two columns. Nothing here is a piece that shape did not force, and three of the four read their answer off the schema instead of taking it as a declared argument.
The contracts hold. transcripts appears in WeMeditateWeb and SahajAtlasWeb only inside their generated copies, so neither the client refusal nor the Transcript rename costs a consumer ticket.
One real gap, in the migration: a pre-migration row with a null meditation_id comes out source-less, and this PR removes the sweep that used to take it.
Findings
- should-fix —
src/migrations/20261102_225511_rename_transcripts.ts:38: a null-meditation_idrow survives with no source, permanently, andrequiredmakes it unsaveable. - consider —
src/lib/meditations/transcriptSource.ts:20: wrong folder for the one module whose point is that transcripts are no longer meditation-specific.
What was checked
Read whole on the branch: Transcripts.ts, cascadeDeletion/index.ts, accessConfigs.ts, schemaUtils.ts, queueTranscription.ts, endpoints/transcribe.ts, both halves of the migration, seeds/lib/expectedCounts.ts. The ticket's rename grep over src seeds scripts tests docs leaves only the seed script name and folder it carves out. Grepped WeMeditateWeb and SahajAtlasWeb for transcript — generated types only. COLLECTION_METADATA.naturalKey has no reader. Preview /admin and the meditations list both answer 200, empty as the body says.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
A pre-migration row whose `meditation_id` was already null gets no `transcripts_rels` row, so it comes out of `up()` with no source at all — and `required` on the new polymorphic `source` makes it unsaveable. The 7-day orphan sweep was the one thing that reached such a row, and this branch removes it, so the row would have stayed forever. The statement goes last, not beside the column drop: deleting before `payload_locked_documents_rels_transcripts_fk` is re-added leaves a lock row pointing at nothing, and `ADD CONSTRAINT` validates existing rows, so the migration would abort. Run last, the two cascades it has just created take the rels row and the lock row with the transcript. Verified on a scratch Postgres carrying the whole chain: two pre-migration rows, one of them null-sourced and locked, leave one transcript, one rels row and no lock row after `up()`. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjW7bcVtY7AFNTZL38G
Its signature accepts a `files` source, which is the whole reason the collection left `MeditationTranscripts/` — so `src/lib/meditations/` claimed the opposite of what the module does. `src/lib/transcripts/source.ts` instead, recorded in `src/AGENTS.md` beside the other barrel-free lib folders. The two `meditations/transcript*` modules stay where they are: those are meditation-specific, and #1016 decides whether they move. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjW7bcVtY7AFNTZL38G
|
Both critic threads adopted, one commit each.
The Gate green: lint, format, typecheck, typecheck:tests, 2993 unit tests, plus the two transcript int specs (27). Security review over these two commits found nothing. Migration re-verified on a scratch Postgres carrying the whole chain: an orphaned, locked pre-migration row leaves no transcript, rels or lock row, and the sourced row survives with its rels row. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
`20261106_094841_clients_one_site` arrived with a timestamp older than the branch's newest snapshot, so `migrate:create` diffed against a snapshot that knew nothing of it and re-emitted its whole `clients` reshape, `DROP TABLE "_clients_v" CASCADE` included. Snapshot kept, DDL emptied; a probe run then writes nothing. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjWFenq4uzxNXbu7gCD
A snapshot heal carries no DDL and heals the chain only as it stood, so one stops doing anything the moment a newer snapshot lands. Three had accumulated, at about 29,700 lines of drizzle schema each; `20261110_172005` is the only one the chain still reads. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjWFenq4uzxNXbu7gCD
|
Two threads answered, and Built. The snapshot files — all three superseded heals dropped, −89,249 lines (e505072). Merged. 0d0e7fe. One conflict, on the migration list: Asked, left open. One path for file and meditation transcription — a decision #1016 owns, so two options, with B built. Lean gate green: 251 files, 3398 passed. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
main's #1087 landed `segmentCount`, the glossary prompt and the `virtualFields` plugin on `meditation-transcripts`, which this branch renamed. Five conflicts, resolved to keep both sides: - `Transcripts.ts` takes `virtualFieldInputs` and drops main's retention imports, since this branch replaced the orphan sweep with a cascade. - `stampSegmentCount.ts` lands in `Transcripts/hooks/`, where git's rename detection pointed it. - `20261107_213230_transcript_segment_count` now names `transcripts`. The rename carries an earlier timestamp, so on a database running the whole chain that statement arrives after it and the old name no longer resolves. - `glossary.spec.ts` and `meditation-transcripts.int.spec.ts` take main's new cases against the new slug, `source` and `Transcript`. - `docs/architecture.md` keeps the vendor-prompt sentence and this branch's own retention line. Three imports main wrote against `@/collections/MeditationTranscripts/` follow the folder. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVrwJ8PmPr3vtULXhb
`20261107_213230_transcript_segment_count` carries a timestamp older than this branch's newest snapshot, so `migrate:create` re-emitted its `segment_count` column. Keeping the generated `.json` and emptying the `.ts` heals the chain; a probe run then writes nothing. `20261110_172005` heals the chain as it stood before this merge, so it is superseded and goes. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVrwJ8PmPr3vtULXhb
The `transcripts` row said nothing about the derived status under a `select`, or the stored cue count behind it, and the glossary row said nothing about the vendor prompt. All three now have assertions on this branch. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjVrwJ8PmPr3vtULXhb
|
One thread answered, and Answered. One path for file and meditation transcription — B, so #1016 settles it and the built option stands. Resolved. Merged. 5ac2e8a. #1087 landed Snapshot chain healed again, and the heal it supersedes dropped. A Lean gate green: 254 files, 3434 passed. 184 passed across 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
main's #1075 renamed the meditation-transcripts collection to transcripts and rewrote that collection's row in the Scheduled jobs table of tests/COVERAGE.md, dropping its retention claim per #1043. This branch added a sentence to the deliverSubmission row of the same table. The whole table conflicted because the rename also narrowed every row's padding. Both rows are kept: main's transcripts row verbatim, and this branch's deliverSubmission sentence about the manager notice being worded from the row's log. Prettier re-padded the table, which is where the line-level conflict came from. No source overlap. main's rename touches transcripts; this branch touches registrations. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjXhvdX4NDzFQkf4LTq
One conflict, in `seeds/AGENTS.md`'s collection-metadata table, where both sides rewrote the same rows. #1075 renamed the collection the `meditation-transcripts` script writes to — `meditation-transcripts` → `transcripts`, natural key `meditation` → `source` — and re-padded every cell to the narrower name. This branch had widened the same column to fit `meditation-transcripts` and appended six `preview-fixture` rows. Resolved as main's rows plus this branch's six. Neither side's padding survives: prettier owns the table and repadded it to `transcripts`. **The script name did not change, only the collection slug.** So the `meditation-transcripts` keys in `expectedCounts.ts`, `dataFiles.ts` and `run.ts` are correct as they stand, and the table's `Script` column keeps spelling it. The two are deliberately different words in the same row. `seeds/lib/expectedCounts.ts` auto-merged and was read rather than trusted: main's rename landed inside the `meditation-transcripts` entry and this branch's `preview-fixture` entries are three separate additions elsewhere in the file, so the hunks do not touch. No code file conflicted. #1075's work is the transcripts collection, its hooks and two migrations; this branch touches none of those paths, and `src/payload-types.ts` is regenerated on main's side alone. **The unit lane's test count moved and nothing conflicted over it**, which is the reverse of `3bbcd32`. #1075 is a refactor: it added 3 cases without adding a spec file, so the four docs kept agreeing on 258 files while `3469` went stale. `perf-figures-pinned.spec.ts` pins the file count to disk and the test count only across the docs, so the gate stayed green on a wrong number. Recounted against the merged tree: 258 files / 3472 tests, in `tests/PERF.md` and its two consumers that state the test count. `tests/PERF.md` gains its own row rather than replacing one, per the file's rule. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjYXNQmP1gdYAbJaSjS
Two conflicts, both additive, neither deciding behaviour. src/migrations/index.ts: both sides appended a migration after 20261107_225000. Kept as the union, in timestamp order — this branch's three snapshot resyncs, then main's 20261110_180359. tests/COVERAGE.md: main rewrote the transcript rows for the #1075 collection rename, and this branch had added a CleverReach clause to the deliverSubmission row. Main's rows kept, that clause restored. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Mg9rjWk7Jt2WdWKgSGcEyT
Summary
transcriptsreplacesmeditation-transcripts, with one polymorphicrequired+uniquesourcetomeditationsorfiles, so intro subtitles have somewhere to live.beforeDeletecascade on both parents replaces the 7-day orphan sweep.meditation._statusclause cannot be written against a polymorphic parent, and the owner accepted the exposure rather than a narrower home.Change outline
The collection and its table are the change; everything else follows from them.
Contract — the collection
requiredis the whole exactly-one-of rule: one field holds one value, so there is no "both" torefuse, and it costs no
NOT NULLbecause the value is not a column.Contract — the tables
Contract — the client read
The narrowing is unwritable against a polymorphic parent, so this reopens #968 on purpose —
including
audioFilename, which resolves to a public unsigned R2 URL. Settled by the reviewer onthe question thread;
docs/rules/access.mdcarries the reasoning and its limit.Contract — the query shape
Three spellings compile; one works.
Whereis loosely typed, so the other two fail at run timeonly — which is why the ⚠ naming them sits on the
sourcefield itself, where a reader of thefield meets it.
Flow — a row's lifetime
transcripts afterChange (create) src/collections/Transcripts/hooks/queueTranscription.ts segments already present → return # a seeded import, not a request + source.relationTo !== 'meditations' → return # the task's input is a meditationId jobs.queue transcribeMeditationBehaviour — two readers the new shape breaks silently
Files
Preview
Railway builds this from the PR number, so the host is live before the build finishes.
PREVIEW_ADMIN_EMAILData: not seeded yet.Both links open on an empty preview.previewUrl.seedis unset for thisrepo, and seeding a remote target needs an
ADMIN_TOKENredeemed from a sign-in link, which anunattended run cannot obtain — so the reviewer creates the meditation. There is no route to link
directly:
transcriptsisadmin.hidden, so/admin/collections/transcripts/<id>404s by designand the tab is the only way in.
Contract impact
src/payload-types.tschanges: the collection key, the interface name (MeditationTranscript→Transcript), andsource's type, now a{ relationTo, value }union. WeMeditateWeb andSahajAtlasWeb are re-synced by the dispatcher's contract sync once this merges; neither names the
collection outside its own generated copy, so neither needs a ticket. SahajAtlasWordpress is
unaffected.
No client-observable change beyond the types. A client key in
wemeditate-weborwemeditate-appreads the collection and gets its
transcriptjoin populated, exactly as before the rename; whatchanged is that the read is no longer narrowed to a published, untrashed meditation.
Migration
src/migrations/20261102_225511_rename_transcripts.tsmeditation_transcripts→transcripts, both enums renamed,payload_locked_documents_rels.meditation_transcripts_idrenamed, and every value inmeditation_transcripts.meditation_idmoved into a newtranscripts_relsrow before that column is dropped. All 122 production rows preserved.meditation_idwas already null gets no rels row, andrequiredonsourcemakes it unsaveable — while the 7-day sweep that was the one thing reaching it goes with this change. The last statement deletes exactly those rows, which is what the sweep would have done.down()recreates the column, reads the ids back out of the rels table, then drops it. Afiles-sourced row has no column to return to, and there can be none, since nothing writes one before this migration. The orphan deletion is not reversible;down()cannot bring those rows back.createfor both. Every name in the file is still the generator's; only the statements that lose data are replaced.main's migrations is hand-edited here too:20261107_213230_transcript_segment_countnow namestranscripts. The rename carries the earlier timestamp, so on a database that runs the whole chain — any fresh PR preview, this PR's own included — thatALTER TABLEarrives after the rename andmeditation_transcriptsno longer resolves. A database that already recorded the migration never replays it, so production, which applied it under the old name when fix(transcripts): a new transcript misspells our words, and select hides status #1087 merged, is unaffected either way. This is the merge resolution worth reading.20261110_180359_merge_1075_main_snapshot_5. Each merge ofmainthat brings migrations puts this branch's rename behind them, so the newest snapshot describes a schema the config no longer matches andmigrate:createre-emits DDL that is already applied. Keeping the generated.jsonand emptying the.tsheals the chain — proved each time by a probe run that writes no files (src/migrations/AGENTS.md). This merge brought20261107_213230_transcript_segment_count, whose timestamp predates the previous snapshot, so the re-emission was itssegment_countcolumn.20261110_180359is the one the chain still reads.Test results
test:unit(254 files, 3434 passed), re-run after the 2026-11-10 merge ofmain's fix(transcripts): a new transcript misspells our words, and select hides status #1087meditation-transcripts,meditation-transcription,virtual-field-select(main's own, now reading the renamed collection),role-based-access,cleanup-orphaned-media. Earlier runs on this branch coveredmeditation-transcripts-seed,globals-client-reads,meditations,albums(the songs cascade, for the unchanged single-target branch),retention-jobs,schema-utilsstampSegmentCount, thevirtualFieldInputsdeclarations, the hand-edited migration andaccessConfigs.tsall match the trigger paths. No finding. Everysourcequery was traced againstgetTableColumnFromPath: the one spelling this branch writes compiles torels.<target>_id = ? AND path LIKE 'source', and a baresourcethrows rather than matching across targets, so the cascade's fallback fails loudly. Thetranscriptjoin was read againstsanitizeJoinFieldand drizzle's join traversal — it carriesrelationTo, so a meditation cannot surface afiles-sourced row of the same id.src/was re-grepped for the old slug: nothing stale survives in any access, project or spec-filter list, andisImplicitlyReadablefails closed for a collection in no project.virtualFieldInputsre-adds onlysegmentCountand thejobid atmaxDepth: 0up/ dump /down/ dump on a scratch Postgres carrying the whole chain, seeded with two pre-migration rows — onetranscripts_relsrow each afterup, and a byte-identical row dump afterdown(the only schema diff was pg_dump's own per-run\restrictnonce). Re-run for the orphan deletion with the chain stopped one migration short, then seeded with a sourced row and a null-sourced row holding an admin edit lock: afterup, onetranscriptsrow, onetranscripts_relsrow, and nopayload_locked_documents_relsrow left behind. Each snapshot heal was proved with amigrate:createprobe that wrote nothing, the one that survives includedEvery new assertion was watched failing against its own defect first: both cascades removed, the
queueTranscriptionsource-kind guard removed,requireddropped fromsource,isDuplicateTranscriptleft onpath === 'meditation', the orphan-media extractor left unable toread
{ relationTo, value }and then separately "fixed" by readingvalueblind,polymorphicFieldforced tofalse(which reds all four cascade cases), the client refusalrestored (which reds both new client cases), and
transcriptsadded to thesahaj-atlasproject(which reds the half that makes the client read a project test rather than a blanket grant).
Manual verification
sourcenames the original meditation. The preview cannot show this — it has no pre-migration rows.Notes for reviewer
Four quality lenses and a security sweep ran over the whole branch, then the adversarial review,
then your answer on the question thread, then your 2026-11-08 and 2026-11-10 reviews. What they
changed, and what I declined:
main's fix(transcripts): a new transcript misspells our words, and select hides status #1087 is merged (5ac2e8a), and it landed on this very collection.segmentCount, the glossary prompt and the newvirtualFieldsplugin all arrived onmeditation-transcripts, which this branch renamed. Five conflicts, each resolved to keep both sides:Transcripts.tstakesvirtualFieldInputsand drops the retention imports this branch's cascade replaced;stampSegmentCount.tslands inTranscripts/hooks/;glossary.spec.tsandmeditation-transcripts.int.spec.tstake main's new cases against the new slug,sourceandTranscript;docs/architecture.mdkeeps the vendor-prompt sentence beside this branch's own retention line. Three imports main wrote against@/collections/MeditationTranscripts/follow the folder. The fifth is the migration hand edit under Migration above — the only one that needed a decision rather than a translation.queueTranscriptionrefuses a source that is not a meditation, and nothing here forecloses A.mainmerge that brings a migration needs one heal and retires the last, so the branch carries exactly one.TranscriptRowalias is gone now that the rename removed the collision that created it (e5b4abf),polymorphicId's shape check is Payload's ownvalueIsValueWithRelation(7099bf8), andtranscriptSourceWhereis inlined at all nine call sites withsrc/lib/transcripts/deleted (648b280). The ⚠ that module carried now sits on thesourcefield; the cost is thatWhere's loose typing no longer refuses a misspelledrelationToat build time. The other three carried an answer with evidence: you resolvedextractId, andisDuplicateTranscriptis still open for you.transcriptsis back onproject membership: no refusal, no narrowing.
CLIENT_UNREADABLEwent with it rather thansitting empty behind a docblock, and so did the ordering hazard its position carried. The join on
a meditation — the read you named as canonical — is populated again for a client key, and has an
assertion of its own now, because
sanitizeJoinQuerywas emptying it silently. refactor(transcripts): one shared transcripts collection, with a file source #1043's criterianeeded no edit: they say the access layer needs the slug renamed and nothing more, which is true
again.
meditation_idcame out ofup()with no source and nothing left to sweep it, so the migration now deletes it — as the last statement, where the cascades it has just created take the rels and locked-document rows with it. Deleting beside the column drop instead would dangle a lock row, and the laterADD CONSTRAINTvalidates existing rows, soup()would abort.CascadeRule.relationTodeleted —BeforeDeleteHookalready receives the collection it runs on, and the child'sflattenedFieldssay whether its field is polymorphic, so both registrations now read exactly likeAlbums.ts:22and a rule can no longer name a parent that disagrees with where it is registered.FieldReference.targetCollectiondeleted the same way. The cascade's child delete stopped hydrating rows nothing reads.isDuplicateTranscriptintosrc/lib/databaseErrors/. That module's own docblock says "Pure by design: no Payload types", and this quirk lives in Payload'sValidationError, not in Postgres's error. The generic half would also be a one-linemapovererror.data.errors, and the collection-specific half (which index) has to stay at the endpoint either way.tests/utils/testData.ts. Pre-existing duplication between two spec files, and the cause iscreateMeditationitself firing a transcription request. Worth doing; not this branch.findper entry, because the preload cache keys onString(doc[naturalKey])and a polymorphic value stringifies to[object Object]for every row. Doing better means reimplementingupsert's skip/update reporting. There is aTODOat the call site naming the cheaper shape.queueTranscriptionreadsdoc.source.value— a property read on the document, which is how the ticket specifies taking the id. The acceptance criterion is about query paths, and noWherein the tree spells one.Detail
The client read, and what accepting it covers.
CLIENT_PARENT_STATE_SCOPESnarrowed a client'stranscript read to
{ 'meditation._status': published, 'meditation.deletedAt': exists false }—the fix for #968, where a client key read the full spoken text and R2 key of draft and trashed
meditations. Verified against payload 3.90.2:
getTableColumnFromPathresolves exactlysource,source.relationToandsource.valueon arelationToarray and throwsAPIError('Not supported')on anything deeper, sosource._statusis not writable in any form.An id-list subquery is the alternative and is what the original clause's own comment rejected, since
the clause is combined into the join query and would cost a round trip per parent row.
So the narrowing is gone and nothing replaced it. ⚠ It is wider than the cues, and worth saying
plainly: the row also carries
audioFilename, whichgetR2Urlturns into a public, unsigneddelivery URL, so a client key in either We Meditate project can reach the recording of an
unpublished meditation. That is what option C on the question thread priced, and it is recorded in
docs/rules/access.mdbeside the limit of the reasoning — "a client reading a transcript reads therecording" holds for a published meditation and not for a draft.
sahaj-atlasreads none of it: implicit read is strictly project-gated since #1068, and thecollection sits in
wemeditate-webandwemeditate-apponly. The integration spec asserts bothdirections, because a blanket grant and a blanket refusal each pass a one-sided test. It was re-run
on the merged tree, because
main's #1058 reshapedsrc/plugins/access/config/under this change.What the security sweep checked and ruled out, over the whole branch, again over the access
change after your answer, and again over the #1087 merge: the
readoperation and its downstreamre-grants, the
meditationsjoin(
sanitizeJoinQuerysuppresses a join whose child access returnsfalse, so it fails closed), aversions read (
readVersionsderives fromupdate, which no client role grants — and thecollection has no
versionsanyway), the live-preview branch, the self-access and document-managerfallbacks (both gated on
isManager, andtranscriptscarries no manager field), the two virtualfields that read the admin-only
payload-jobswithoverrideAccess(both return derived scalars —a status word and an error string — never the job document, its input or its log), the cascade's
authority (the caller must already hold hard-delete on the parent;
Albums.tshas had the identicalhelper for
songs), the orphan-media extractor againsthasManyand localized references,isDuplicateTranscript's string against caller-shaped input, thex-internalspec filter, and themigration's SQL for interpolation. No finding at the bar. The whole
up()body is onesqltemplate with no interpolation, and the only foreign keys pointing at
transcriptsare its own relstable and
payload_locked_documents_rels, so the cascade cannot reachmeditationsorfiles.What #1087 added to that sweep.
segmentCountis a stored scalar with one writer, abeforeChangehook that counts the cues of the same row, so it carries nothing the row did notalready hold.
virtualFieldInputs('segmentCount', 'job')onstatusandvirtualFieldInputs('job')on
errorre-add exactly those two columns to an include-modeselect, andjobismaxDepth: 0,so neither puts a new column in front of a client key — which matters here, since the collection is
reachable with one.
glossaryPromptsends our own spellings to the vendor and reads nothing from acaller.
requiredon a polymorphic relationship costs nothing in the schema. ThenotNullbranch inschema/traverseFields.jssits inside the single-targetelse, so there is no column to constrainand no foreign-key objection — which is why the
beforeValidatehook an earlier draft of the ticketspecified does not exist.
Three names deliberately unchanged, each because it names something that is not the collection:
src/components/admin/MeditationTranscript/is the Meditations Transcript tab, which staysmeditation-specific;
seeds/meditation-transcripts/and themeditation-transcriptsseed scriptname are keyed by script, not collection, and
seeds/run.tsanddataFiles.tsboth index on it.The polymorphic
wherehas no module of its own. An earlier round collapsed its copies intosrc/lib/transcripts/source.ts; your 2026-11-08 review asked for that layer back out, so theliteral is written at each of the nine call sites and the folder is gone. Two sites in
tests/int/meditation-transcription.int.spec.tsand two inmeditation-transcripts-seedalreadyspelled it inline, so that is now the one spelling everywhere. The two
meditations/transcript*modules are meditation-specific and stay where they are, with #1016 deciding whether they move.
Closes #1043