Skip to content

refactor(transcripts): one shared transcripts collection, with a file source - #1075

Merged
sydevs-bot merged 28 commits into
mainfrom
claude/refactor-1043-transcripts
Nov 10, 2026
Merged

sydevs-bot merged 28 commits into
mainfrom
claude/refactor-1043-transcripts

Conversation

@sydevs-bot

@sydevs-bot sydevs-bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • transcripts replaces meditation-transcripts, with one polymorphic required + unique source to meditations or files, so intro subtitles have somewhere to live.
  • A row's lifetime is now its source's: a beforeDelete cascade on both parents replaces the 7-day orphan sweep.
  • Joined, and not in the ticket: the client read is left on project membership. feat(meditations): transcribe a recording when it is added #968's meditation._status clause 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

 transcripts                                    src/collections/Transcripts/Transcripts.ts
-  slug: 'meditation-transcripts'
+  slug: 'transcripts'
-  meditation  → meditations, unique             # nullable column, no `required`
+  source      → [meditations, files], required, unique
-  custom.retention: { windows: ORPHAN_WINDOWS } # swept 7 days after the parent went
   language required · segments · segmentCount · job · virtual status / error   # unchanged
   admin.hidden · no write grant of its own                       # unchanged

required is the whole exactly-one-of rule: one field holds one value, so there is no "both" to
refuse, and it costs no NOT NULL because the value is not a column.

Contract — the tables

-- meditation_transcripts renamed, its source moved out to a rels table
ALTER TABLE meditation_transcripts RENAME TO transcripts;
CREATE TABLE transcripts_rels (parent_id, path, meditations_id, files_id);
  UNIQUE (meditations_id, path)   -- one transcript per meditation, still
  UNIQUE (files_id, path)         -- and now one per file
  every FK ON DELETE cascade      -- so a parent delete takes the rels row
INSERT INTO transcripts_rels SELECT id, 'source', meditation_id FROM transcripts …;
ALTER TABLE transcripts DROP COLUMN meditation_id;
DELETE FROM transcripts WHERE NOT EXISTS (… its 'source' rels row);
  -- a row the old ON DELETE set null had already orphaned. Last statement, so the
  -- cascades above take its rels and locked-document rows with it

Contract — the client read

 createAccessConfig read, user.collection === 'clients'   src/plugins/access/accessConfigs.ts
-  CLIENT_PARENT_STATE_SCOPES['meditation-transcripts']   # the #968 narrowing
-    { 'meditation._status': published, 'meditation.deletedAt': exists false }
+  (nothing)                                              # project membership is the gate
   transcripts ∈ wemeditate-web, wemeditate-app           # so sahaj-atlas reads none

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 on
the question thread; docs/rules/access.md carries the reasoning and its limit.

Contract — the query shape

Three spellings compile; one works. Where is loosely typed, so the other two fail at run time
only — which is why the ⚠ naming them sits on the source field itself, where a reader of the
field meets it.

+ { source: { equals: { relationTo: 'meditations', value: id } } }   # written at each call site
- { source: { equals: id } }          # APIError('Not supported') when the query is built
- { 'source.value': { equals: 5 } }   # ORs one raw id column per target: meditation 5 OR file 5

Flow — a row's lifetime

 payload.delete meditations|files
+  beforeDelete → deleteChildren({ collection: 'transcripts', field: 'source' })
+    polymorphicField(req, rule)                  # the child's own flattenedFields
+      relationTo is an array → { equals: { relationTo: collection.slug, value: id } }
+      else                   → { equals: id }    # Albums → songs, unchanged
-  FK ON DELETE set null → meditation_id = NULL
-  CleanupCollections nightly → sweeps it 7 days later
 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 transcribeMeditation

Behaviour — two readers the new shape breaks silently

 isDuplicateTranscript(error)                     src/collections/Meditations/endpoints/transcribe.ts
-  path === 'meditation'                          # fieldConstraints has no polymorphic entry
+  path === 'meditations_id, path'                # Postgres's own `detail`, via handleUpsertError

 extractIdsFromDocument(doc, ref, targetCollection)   src/jobs/CleanupOrphanedMedia/schemaUtils.ts
-  extractId(value)                               # reads .id → null → file reads as an orphan
+  Array.isArray(ref.relationTo)                  # the walk's answer, not a key off the value
+    → polymorphicId(value, targetCollection)     # valueIsValueWithRelation, then extractId

Files

 src/collections/
-├── MeditationTranscripts/            # renamed wholesale
+├── Transcripts/                      # slug, config, folder
 src/lib/
+└── lemonfox/normalize.ts             # was the collection's; two consumers already
 src/components/admin/MeditationTranscript/   # unchanged name: it IS the Meditations tab
 seeds/meditation-transcripts/                # unchanged name: it IS the script

Preview

Railway builds this from the PR number, so the host is live before the build finishes.

Data: not seeded yet. Both links open on an empty preview. previewUrl.seed is unset for this
repo, and seeding a remote target needs an ADMIN_TOKEN redeemed from a sign-in link, which an
unattended run cannot obtain — so the reviewer creates the meditation. There is no route to link
directly: transcripts is admin.hidden, so /admin/collections/transcripts/<id> 404s by design
and the tab is the only way in.

Contract impact

src/payload-types.ts changes: the collection key, the interface name (MeditationTranscript →
Transcript), and source's type, now a { relationTo, value } union. WeMeditateWeb and
SahajAtlasWeb
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-web or wemeditate-app
reads the collection and gets its transcript join populated, exactly as before the rename; what
changed is that the read is no longer narrowed to a published, untrashed meditation.

Migration

  • New migration: src/migrations/20261102_225511_rename_transcripts.ts
  • Impact: meditation_transcripts → transcripts, both enums renamed, payload_locked_documents_rels.meditation_transcripts_id renamed, and every value in meditation_transcripts.meditation_id moved into a new transcripts_rels row before that column is dropped. All 122 production rows preserved.
  • One deliberate deletion: a pre-migration row whose meditation_id was already null gets no rels row, and required on source makes 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.
  • Reversible for every sourced row — down() recreates the column, reads the ids back out of the rels table, then drops it. A files-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.
  • ⚠ Hand-written over the generator's output, which dropped the table. It saw an unrelated table plus an unrelated column and answered create for both. Every name in the file is still the generator's; only the statements that lose data are replaced.
  • ⚠ One of main's migrations is hand-edited here too: 20261107_213230_transcript_segment_count now names transcripts. The rename carries the earlier timestamp, so on a database that runs the whole chain — any fresh PR preview, this PR's own included — that ALTER TABLE arrives after the rename and meditation_transcripts no 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.
  • One snapshot-only file carries no DDL: 20261110_180359_merge_1075_main_snapshot_5. Each merge of main that brings migrations puts this branch's rename behind them, so the newest snapshot describes a schema the config no longer matches and migrate:create re-emits DDL that is already applied. Keeping the generated .json and emptying the .ts heals the chain — proved each time by a probe run that writes no files (src/migrations/AGENTS.md). This merge brought 20261107_213230_transcript_segment_count, whose timestamp predates the previous snapshot, so the re-emission was its segment_count column.
  • A heal is superseded the moment a newer snapshot lands. Four have accumulated over five merges and all four are dropped, at about 29,700 lines of drizzle schema each, as every migration in this folder carries; 20261110_180359 is the one the chain still reads.

Test results

  • Lean gate: ✓ lint, format:check, typecheck, typecheck:tests, test:unit (254 files, 3434 passed), re-run after the 2026-11-10 merge of main's fix(transcripts): a new transcript misspells our words, and select hides status #1087
  • Targeted specs for that push: 184 passed — meditation-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 covered meditation-transcripts-seed, globals-client-reads, meditations, albums (the songs cascade, for the unchanged single-target branch), retention-jobs, schema-utils
  • Security sweep: run over the whole branch, then over the five review commits, then again after the fix(transcripts): a new transcript misspells our words, and select hides status #1087 merge — stampSegmentCount, the virtualFieldInputs declarations, the hand-edited migration and accessConfigs.ts all match the trigger paths. No finding. Every source query was traced against getTableColumnFromPath: the one spelling this branch writes compiles to rels.<target>_id = ? AND path LIKE 'source', and a bare source throws rather than matching across targets, so the cascade's fallback fails loudly. The transcript join was read against sanitizeJoinField and drizzle's join traversal — it carries relationTo, so a meditation cannot surface a files-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, and isImplicitlyReadable fails closed for a collection in no project. virtualFieldInputs re-adds only segmentCount and the job id at maxDepth: 0
  • Migration: up / dump / down / dump on a scratch Postgres carrying the whole chain, seeded with two pre-migration rows — one transcripts_rels row each after up, and a byte-identical row dump after down (the only schema diff was pg_dump's own per-run \restrict nonce). 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: after up, one transcripts row, one transcripts_rels row, and no payload_locked_documents_rels row left behind. Each snapshot heal was proved with a migrate:create probe that wrote nothing, the one that survives included
  • Build: N/A — Railway builds it

Every new assertion was watched failing against its own defect first: both cascades removed, the
queueTranscription source-kind guard removed, required dropped from source,
isDuplicateTranscript left on path === 'meditation', the orphan-media extractor left unable to
read { relationTo, value } and then separately "fixed" by reading value blind,
polymorphicField forced to false (which reds all four cascade cases), the client refusal
restored (which reds both new client cases), and transcripts added to the sahaj-atlas project
(which reds the half that makes the client read a project test rather than a blanket grant).

Manual verification

  1. An existing transcript survives the migration. On a database with pre-migration rows, open a meditation that had one: the Transcript tab shows its cues, its language and its job link, and source names the original meditation. The preview cannot show this — it has no pre-migration rows.
  2. The Transcribe-again button. Fail a run, wait out the cooldown, and retry from the tab. The 409 and 429 refusals are covered by specs, but the button's own wiring is not.
  3. A file-sourced row has no UI yet. feat(lessons): make intro subtitles from the recording, per language #1016 brings it. Nothing in the admin creates one today, which is why its coverage is all integration-level.

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 new virtualFields plugin all arrived on meditation-transcripts, which this branch renamed. Five conflicts, each resolved to keep both sides: Transcripts.ts takes virtualFieldInputs and drops the retention imports this branch's cascade replaced; stampSegmentCount.ts lands in Transcripts/hooks/; 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 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.
  • Taken, from your 2026-11-10 answer. B: one path for file and meditation transcription is feat(lessons): make intro subtitles from the recording, per language #1016's to settle. The built option stands, so there is no commit — queueTranscription refuses a source that is not a meditation, and nothing here forecloses A.
  • Taken, from your 2026-11-10 review. The superseded snapshot heals are dropped (e505072, and the one this merge superseded with it). Each main merge that brings a migration needs one heal and retires the last, so the branch carries exactly one.
  • Taken, from your 2026-11-08 review. Five of the eight threads are built: both cascade pointer comments are gone (5106c17, 4ff4e9a), the TranscriptRow alias is gone now that the rename removed the collision that created it (e5b4abf), polymorphicId's shape check is Payload's own valueIsValueWithRelation (7099bf8), and transcriptSourceWhere is inlined at all nine call sites with src/lib/transcripts/ deleted (648b280). The ⚠ that module carried now sits on the source field; the cost is that Where's loose typing no longer refuses a misspelled relationTo at build time. The other three carried an answer with evidence: you resolved extractId, and isDuplicateTranscript is still open for you.
  • Taken, from your answer on the question thread. The client read of transcripts is back on
    project membership: no refusal, no narrowing. CLIENT_UNREADABLE went with it rather than
    sitting 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 sanitizeJoinQuery was emptying it silently. refactor(transcripts): one shared transcripts collection, with a file source #1043's criteria
    needed no edit: they say the access layer needs the slug renamed and nothing more, which is true
    again.
  • Taken, from the adversarial review. A pre-migration row with a null meditation_id came out of up() 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 later ADD CONSTRAINT validates existing rows, so up() would abort.
  • Taken. CascadeRule.relationTo deleted — BeforeDeleteHook already receives the collection it runs on, and the child's flattenedFields say whether its field is polymorphic, so both registrations now read exactly like Albums.ts:22 and a rule can no longer name a parent that disagrees with where it is registered. FieldReference.targetCollection deleted the same way. The cascade's child delete stopped hydrating rows nothing reads.
  • Declined — isDuplicateTranscript into src/lib/databaseErrors/. That module's own docblock says "Pure by design: no Payload types", and this quirk lives in Payload's ValidationError, not in Postgres's error. The generic half would also be a one-line map over error.data.errors, and the collection-specific half (which index) has to stay at the endpoint either way.
  • Declined — a shared "meditation with no transcript" fixture in tests/utils/testData.ts. Pre-existing duplication between two spec files, and the cause is createMeditation itself firing a transcription request. Worth doing; not this branch.
  • Declined — rewriting the transcript seed importer to preload in one query. It now takes one find per entry, because the preload cache keys on String(doc[naturalKey]) and a polymorphic value stringifies to [object Object] for every row. Doing better means reimplementing upsert's skip/update reporting. There is a TODO at the call site naming the cheaper shape.
  • Not a violation, despite the grep. queueTranscription reads doc.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 no Where in the tree spells one.
Detail

The client read, and what accepting it covers. CLIENT_PARENT_STATE_SCOPES narrowed a client's
transcript 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: getTableColumnFromPath resolves exactly source,
source.relationTo and source.value on a relationTo array and throws
APIError('Not supported') on anything deeper, so source._status is 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, which getR2Url turns into a public, unsigned
delivery 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.md beside the limit of the reasoning — "a client reading a transcript reads the
recording" holds for a published meditation and not for a draft.

sahaj-atlas reads none of it: implicit read is strictly project-gated since #1068, and the
collection sits in wemeditate-web and wemeditate-app only. The integration spec asserts both
directions, 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 reshaped src/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 read operation and its downstream
re-grants, the meditations join
(sanitizeJoinQuery suppresses a join whose child access returns false, so it fails closed), a
versions read (readVersions derives from update, which no client role grants — and the
collection has no versions anyway), the live-preview branch, the self-access and document-manager
fallbacks (both gated on isManager, and transcripts carries no manager field), the two virtual
fields that read the admin-only payload-jobs with overrideAccess (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.ts has had the identical
helper for songs), the orphan-media extractor against hasMany and localized references,
isDuplicateTranscript's string against caller-shaped input, the x-internal spec filter, and the
migration's SQL for interpolation. No finding at the bar. The whole up() body is one sql
template with no interpolation, and the only foreign keys pointing at transcripts are its own rels
table and payload_locked_documents_rels, so the cascade cannot reach meditations or files.

What #1087 added to that sweep. segmentCount is a stored scalar with one writer, a
beforeChange hook that counts the cues of the same row, so it carries nothing the row did not
already hold. virtualFieldInputs('segmentCount', 'job') on status and virtualFieldInputs('job')
on error re-add exactly those two columns to an include-mode select, and job is maxDepth: 0,
so neither puts a new column in front of a client key — which matters here, since the collection is
reachable with one. glossaryPrompt sends our own spellings to the vendor and reads nothing from a
caller.

required on a polymorphic relationship costs nothing in the schema. The notNull branch in
schema/traverseFields.js sits inside the single-target else, so there is no column to constrain
and no foreign-key objection — which is why the beforeValidate hook an earlier draft of the ticket
specified 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 stays
meditation-specific; seeds/meditation-transcripts/ and the meditation-transcripts seed script
name are keyed by script, not collection, and seeds/run.ts and dataFiles.ts both index on it.

The polymorphic where has no module of its own. An earlier round collapsed its copies into
src/lib/transcripts/source.ts; your 2026-11-08 review asked for that layer back out, so the
literal is written at each of the nine call sites and the folder is gone. Two sites in
tests/int/meditation-transcription.int.spec.ts and two in meditation-transcripts-seed already
spelled 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

`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
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-1075 November 3, 2026 00:00 Destroyed
@railway-app

railway-app Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

🚅 Deployed to the SahajCloud-pr-1075 environment in sahajcloud

Service Status Web Updated
SahajCloud ✅ Success (View Logs) Web Nov 10, 2026 at 6:20 pm UTC
1 service not affected by this PR
  • mailpit

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 question for the reviewer, one per thread.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread src/plugins/access/accessConfigs.ts Resolved
@sydevs-bot

sydevs-bot commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor Author

🤖 no session running

recent dispatches
  • 17:54Z address-review · attempt 1 · session · done
  • 17:54Z address-review · attempt 1 · session
  • 17:14Z address-review · attempt 1 · session · done
  • 17:14Z address-review · attempt 1 · session
  • 23:23Z address-review · attempt 1 · session · done

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 3, 2026
@sydevs-bot sydevs-bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 3, 2026

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 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_id row survives with no source, permanently, and required makes 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

Comment thread src/lib/transcripts/source.ts Resolved
@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 3, 2026
@sydevs-bot sydevs-bot moved this from Working to Pending in SYDevelopers Technical Roadmap Nov 3, 2026
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 3, 2026
@sydevs-bot sydevs-bot moved this from Pending to Working in SYDevelopers Technical Roadmap Nov 3, 2026
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
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-1075 November 3, 2026 00:46 Destroyed
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Both critic threads adopted, one commit each. origin/main merged in cleanly, no conflict.

The accessConfigs.ts question thread still waits on you. Option A stays built.

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

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 3, 2026
@sydevs-bot sydevs-bot moved this from Working to Pending in SYDevelopers Technical Roadmap Nov 3, 2026
@sydevs-bot
sydevs-bot marked this pull request as ready for review November 3, 2026 01:00
@sydevs-bot
sydevs-bot requested a review from Ardnived November 3, 2026 01:00
@sydevs-bot
sydevs-bot enabled auto-merge November 3, 2026 01:00
`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
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-1075 November 10, 2026 17:26 Destroyed
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

Two threads answered, and main merged.

Built. The snapshot files — all three superseded heals dropped, −89,249 lines (e505072).

Merged. 0d0e7fe. One conflict, on the migration list: main's 20261106_094841_clients_one_site and this branch's newest heal both claimed the slot after 20261105_201411, and both are kept in timestamp order. That merge needed a heal of its own (7639ed7), so the branch carries exactly one.

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. meditation-transcripts, meditation-transcription and role-based-access re-run on the merged tree, 150 passed.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 10, 2026
@sydevs-bot sydevs-bot moved this from Working to Awaiting in SYDevelopers Technical Roadmap Nov 10, 2026
@sydevs-bot sydevs-bot added the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 10, 2026
@sydevs-bot sydevs-bot moved this from Awaiting to Working in SYDevelopers Technical Roadmap Nov 10, 2026
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
@railway-app
railway-app Bot temporarily deployed to sahajcloud / SahajCloud-pr-1075 November 10, 2026 18:14 Destroyed
@sydevs-bot

Copy link
Copy Markdown
Contributor Author

One thread answered, and main's #1087 merged.

Answered. One path for file and meditation transcription — B, so #1016 settles it and the built option stands. Resolved.

Merged. 5ac2e8a. #1087 landed segmentCount, the glossary prompt and the virtualFields plugin on the collection this branch renames. Five conflicts, both sides kept. One needed a decision: 20261107_213230_transcript_segment_count now names transcripts, because the rename carries the earlier timestamp and that ALTER TABLE lands after it on any database running the whole chain. One that already recorded the migration never replays it, so production is unaffected.

Snapshot chain healed again, and the heal it supersedes dropped. A migrate:create probe writes nothing.

Lean gate green: 254 files, 3434 passed. 184 passed across meditation-transcripts, meditation-transcription, virtual-field-select, role-based-access, cleanup-orphaned-media. Security sweep re-run over the merged surface: no finding.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Nov 10, 2026
@sydevs-bot sydevs-bot moved this from Working to Pending in SYDevelopers Technical Roadmap Nov 10, 2026
@sydevs-bot
sydevs-bot added this pull request to the merge queue Nov 10, 2026
Merged via the queue into main with commit df12381 Nov 10, 2026
25 of 27 checks passed
@sydevs-bot
sydevs-bot deleted the claude/refactor-1043-transcripts branch November 10, 2026 18:42
sydevs-bot added a commit to sydevs/WeMeditateWeb that referenced this pull request Nov 10, 2026
@sydevs-bot sydevs-bot moved this from Pending to Done in SYDevelopers Technical Roadmap Nov 10, 2026
sydevs-bot pushed a commit that referenced this pull request Nov 10, 2026
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
sydevs-bot pushed a commit that referenced this pull request Nov 10, 2026
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
sydevs-bot pushed a commit that referenced this pull request Nov 10, 2026
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

This branch was successfully deployed

No deployments
sahajcloud / SahajCloud-pr-1075 — 277a268a Deployed Nov 10, 2026 by railway-app[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

refactor(transcripts): one shared transcripts collection, with a file source

3 participants