Repository navigation
feat(meditations): transcribe a recording when it is added - #968
Conversation
`src/lib/lemonfox/` rather than inside the transcription job: a job folder's supporting code is private to that job (`src/AGENTS.md` rule 2), and #941 wants the same connection for Path Step intro subtitles. Placing it here serves every answer that goal's open question 3 can reach, so this child decides nothing for it. Two files, because `lib-boundary` counts consumers. `transcribe.ts` has two under `src/` — the task, and the writer that must know whether transcription is available before it promises one. `languages.ts` has one, `transcribe.ts` next door, which is inside `src/lib/` and so exempt. Lifted from the closed `claude/feat-881-meditation-transcripts`, with the request changed twice: - No `timestamp_granularities[]`. Nothing stores word timings since #957. - The locale is mapped inside the client, so no caller repeats it. `REQUEST_TIMEOUT_MS` stays at 5 minutes. #941's notes flag it against Cloudflare's 125 s proxy read timeout; that bound governs a request arriving through our zone at the origin, and this is an outbound call from the container made by a queued job with nothing waiting on it. `LEMONFOX_API_KEY` is optional, as every other third-party key here is. An empty value counts as unset, and `vitest.config.mts` sets it empty so no run can spend a real one. The `transcription` queue's autoRun fires at :03, :18, :33 and :48, which collides with no existing tick — two queues on one minute lose a `lastScheduledRun` to each other's write of `payload-jobs-stats`. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MK7jeN7KBvhP2yUt4usdgF
`requestTranscription` is the only place a request is written, so the automatic enqueue and the endpoint cannot drift. It reads the row, returns an in-flight request for the current recording untouched, and otherwise writes `queued` and queues `transcribeMeditation` with `req` — inside the caller's transaction, so a rolled-back write leaves no orphaned job. Three departures from the closed `claude/feat-881-meditation-transcripts`: - **No `sample` provider.** The branch answered a missing key with invented text outside production. #897 line 13 forbids exactly that, and #957 removed `sample` from `TRANSCRIPT_PROVIDERS`. With no key the writer writes `failed` with `TRANSCRIPTION_UNAVAILABLE_ERROR` and queues nothing — queueing a job certain to fail is dishonest latency. - **`segments` survive a request.** The branch cleared them, on the invariant that segments belong to the recording the row names. Line 9 keeps the old transcript readable until the new one is ready, so `audioFilename` names the request and `segments` the last *completed* run. The task's stale-recording guard is unaffected. - **The task returns a `failed` row instead of rethrowing.** `retries: 0`, so an escaping throw left the row `processing` until the stall bound — the "spins forever" state line 10 forbids. The normaliser's own throw on a body with no timestamped speech is inside that catch. `language` is written on every row, the no-key one included: #957 makes it required, and the glossary hook returns the text uncorrected without it. It is the meditation's own `locale`, which both callers already read. `toTranscriptView` reads the stored `outdated` column rather than comparing filenames — a comparison means nothing where a preview key prefixes them. `runQueueSoon` generalises the screening kick, which becomes a one-line wrapper over it. That keeps both at two consumers, so `lib-boundary` passes, and `delayMs` is why the wrapper stays: a hook must wait for its own commit, the endpoint is wrapped in no transaction. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MK7jeN7KBvhP2yUt4usdgF
The two behaviours #897 line 9 distinguishes, as two hooks on `meditations`: - `enqueueMeditationTranscription` (afterChange) fires where audio was added and there was none — the 2026-10-12 Decision, "by itself when a recording is added, with a button to redo it". - `markTranscriptOutdated` (beforeChange) fires on a replacement and marks the row, inside that same save. Not at render: line 9 asks for the mark at the moment of replacement, and a filename comparison means nothing where a preview key prefixes them. It queues nothing — re-transcribing would destroy the text line 9 keeps readable. Both write only `meditation-transcripts`. Nothing here touches the meditation document (line 12): it keeps three versions behind drafts, so a write would burn one and could publish an unfinished draft. `markTranscriptOutdated` sits beside `extractAudioDuration` in the beforeChange chain, which is the hook that already proves `req.file` is readable there. The two endpoints are manager-only and delegate every row write to `requestTranscription`, so a double click queues one job. Both gate on the **request** locale: a manager's roles are per locale, so a request naming none resolves to the default and silently refuses anyone whose role lives elsewhere (#701). The docblocks say the caller must send `?locale=`, because that rule is written for the caller. Neither goes in `CUSTOM_ENDPOINT_PATHS` or `docs/rules/openapi.md`: those are owed to a public, client-facing endpoint, and the precedent for a manager-only one is `POST /api/user-submissions/:id/review`, deliberately absent. `meditation-transcripts` joins `ALWAYS_HIDDEN_COLLECTIONS`. ⚠ Two independent tiers now hide that collection — this list, and its absence from every project (#957) — so the filter cases cannot catch either one's removal alone. The new membership case is a direct assertion for that reason, and it was watched red. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MK7jeN7KBvhP2yUt4usdgF
`tests/int/meditation-transcription.int.spec.ts` — 20 cases, deliberately a different file from #957's `meditation-transcripts.int.spec.ts`, which covers what the table itself enforces. The vendor is mocked at `@/lib/lemonfox/transcribe`, so the suite drives a completed run and cannot make a paid call. `getR2Url` is mocked too: `CLOUDFLARE_R2_DELIVERY_URL` is unset in the lane, so the real one answers `undefined` and the task would refuse every run before reaching the vendor. Every assertion was watched red first, against the defect it exists for: the `?locale=` scope dropped, the stale-recording re-check dropped, `segments` cleared on a redo, `outdated` derived at render, the no-key path writing placeholder text, the normaliser's throw escaping the task, the afterChange hook unwired, the in-flight dedupe dropped, and the task writing the meditation document. Three states the API cannot reach, and how each is seeded: - A **stalled** row is aged through `payload.db.updateOne`, because `payload.update` stamps `updatedAt` itself. - A meditation with **no recording** is seeded through the db layer in both rows. Payload refuses a create with no file and `restrictUploadToAdmin` refuses to clear one, and the `latest: true` version row is the half that matters: `findMeditationRecording` reads the draft, so seeding the main row alone leaves the endpoint reading the recording and the case passes for the wrong reason — the trap `tests/utils/storeInvalidEvent.ts` already records. - Each fixture meditation carries a frame, because `Meditations.frames` refuses an **update** that leaves none, so a recording could not otherwise be replaced. ⚠ #957's suite needed adapting, and two of its cases were vacuous without it: an upload now writes a transcript row, `meditation` is unique, so the two cases asserting a refusal were refused by that constraint rather than by the rule under test — green, and testing nothing. Two findings worth keeping, both from watching a case fail: - A `web-translator` **reads** a transcript. That is implicit project read (`docs/rules/access.md`), not a hole this endpoint opens, and the POST still refuses them because transcribing is an `update`. The GET and the POST diverge there and nothing else in the suite would show it. - An API client has to be called with its own API key. A `managers` session minted for its id refuses for the wrong reason — `clients` sets `disableLocalStrategy` and holds no session at all. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MK7jeN7KBvhP2yUt4usdgF
Findings from /simplify's four lenses. Behaviour is unchanged except where noted. - **`runQueueSoon` takes the fact, not a number.** `delayMs` made every caller choose a delay, so 2000 was written in three places and threaded through `requestTranscription`'s signature. It is now `afterCommit`, and the constant and its reasoning live once, beside the mechanism. - **`runScreeningQueueAfterCommit` is deleted.** After the generalisation its whole body was the string `'screening'`, and its docblock had already moved. Its two callers call `runQueueSoon` directly. - **The job no longer restates the recording read.** It was a byte-for-byte copy of the read this branch had just factored out, comment included. `findMeditationRecording` also moves out of the transcripts folder to `src/collections/Meditations/`, which is the collection whose document it reads — a cross-owner read parked in one owner's folder is what `src/AGENTS.md` rule 4 forbids. The two reads now run in parallel; neither feeds the other. - **`markTranscriptOutdated` is a row-writer beside `requestTranscription`.** The hook reached across and updated `meditation-transcripts` inline, which made "one writer owns the row" untrue the moment it was written. The hook keeps the detection — whether a save replaces audio is `meditations`' knowledge — and is renamed `outdateTranscriptOnReplace` so the trigger and the write do not share a name. - **`TRANSCRIPTION_UNAVAILABLE_ERROR` moves to `@/lib/lemonfox/transcribe`**, beside the predicate that answers for it. The job was importing the collection's writer — and through it the whole queue-kick machinery — to agree on one string. - **The task writes `status`, `provider` and `segments` only.** It was re-clearing `error` and `outdated`, which `requestTranscription` is the only party able to set, so the row's column ownership was unreadable. - **`lemonfoxLanguage` reduces a locale through `baseLanguage`**, the one spelling of that (#957), instead of a second `Intl.Locale` parse — and it takes a `LocaleCode`, so the try/catch for a malformed one goes with it. The vendor's accepted-name list stays the vendor's: deriving it from `LOCALES` would make a twentieth locale silently send a name Lemonfox refuses. A case now pins that every locale we offer maps to an accepted name, which is the property that catches that. - **Two unused clock parameters go**, with the view-building that `isTranscriptionActive` did to read two booleans. - **The re-entrancy guard goes.** Nothing in the enqueue path writes `meditations`, and the line below it already made a second pass a no-op. - **`seedLatestVersion` is extracted** from `storeInvalidEvent`, so the version-row trap it documents has one implementation rather than two. Dismissed, with reasons: - Bound `findTranscriptRow` with a `select`. The row's `segments` are read 2–3 times per job run and once per replacement, which for a 126-recording library is not worth a second code path a reader can lose `segments` through. - Fold the task's final re-read into a `where`-form update. The repo has no such update today, and introducing one for this costs more than the read. - Hand `requestTranscription` a pre-fetched row so the POST parallelises its two reads. That is a parameter one of two callers varies, to save one round trip on a button press. - Drop `draft: true` from the GET's existence check. It would need a second recording read whose only difference is a flag, and the 404 the GET owes child 4 is what that read buys. - Derive `afterCommit` from `req.transactionID` instead of asking. The derivation is unverifiable here — `runQueueSoon` is suppressed under `NODE_ENV=test`, so no spec could catch it being wrong. - Move `normalizeLemonfoxResponse` beside the client. It is #957's module, placed with the collection because two writers share it, and moving it is #941's decision rather than this child's. - Extract the manager + per-locale permission gate into `@/lib/endpoints`. It is the third copy and worth doing, but it refactors two other collections' endpoints — filed rather than folded in. /security-review ran over the diff and found nothing: the gate is the first statement of both handlers, `roleScopeFromLocale` refuses `all` and `union`, every `overrideAccess` write is scoped to the gated meditation, the key is never logged or stored, and the vendor URL's host and scheme come from server environment. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MK7jeN7KBvhP2yUt4usdgF
|
🚅 Deployed to the SahajCloud-pr-968 environment in sahajcloud
1 service not affected by this PR
|
|
🤖 no session running recent dispatchesWritten by the sydevs dispatcher. Sessions never edit this comment. |
The branch registers the `transcribeMeditation` task but shipped no migration, so `enum_payload_jobs_task_slug` has no such label on any database that applies this chain. The afterChange hook queues the task inside the create, so every meditation create on the preview answered 400 `22P02 invalid input value for enum ... "transcribeMeditation"`, and `tests/e2e/meditations.e2e.spec.ts` was the only lane that could see it: `push: !isProduction` syncs the schema for dev and both test lanes, so the unit and integration suites never replay the migration chain. Generated, not hand-written. The delta is the two `ALTER TYPE ... ADD VALUE` statements and nothing else — the snapshot differs from 20261015_070852's by exactly that label in the two task-slug enums. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01GBNqetsktQ2GZKUBdRyVm1
|
Registering a task adds a label to
Two things worth keeping:
🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
sydevs-bot
left a comment
There was a problem hiding this comment.
🧐 Adversarial review
This tracks #953 closely. Every module placement, the dropped sample provider, the stored outdated column and the stale-run guards are the ticket's own, and both deviations from it delete a layer rather than add one — afterCommit replaces a caller-chosen delayMs, and screeningQueue.ts is gone rather than kept as a wrapper. Twelve new modules, each one the ticket names.
One thing does not hold. outdated is cleared when a transcription is requested, not when one completes, so a failed redo leaves the previous recording's text labelled current — the contract child 4 is being built against.
Findings
- blocker —
requestTranscription.ts:49clearsoutdatedbefore the new transcript exists. Thread on that line. - consider —
MeditationTranscripts.ts:79, outside this diff, still sayssegmentsis "cleared tonullwhen a new transcription is requested". This PR reverses that invariant, so the comment describes a system that is gone.
What was checked
Read whole: requestTranscription.ts, view.ts, TranscribeMeditation.ts, both meditations hooks, the three endpoint files, runQueueSoon.ts, lemonfox/{transcribe,languages}.ts, findMeditationRecording.ts. Compared against #953 §1–§9 and its Interfaces, and against #957's collection on main for the outdated, language and segments columns.
Verified by grep over src, scripts, seeds: runQueueSoon has 3 importers and lemonfox/transcribe 2, so lib-boundary passes with KNOWN_SINGLE_CONSUMER untouched; sampleResponse.ts is gone; and the only collection: 'meditations' references in the new code are a hasPermission argument and a findByID read — no write.
Preview: /admin/login answers 200 and GET /api/meditations/1/transcript?locale=en answers 403 anonymously, so both endpoints are mounted.
🤖 Written by the sydevs autonomous loop — see what this is
Generated by Claude Code
The closed list's stated reason did not hold. `enqueueingFiles()` derives the set per call, so the driven-queue case below already covers a third site — unlike `SCHEDULED_TASKS`, whose sweep the comment borrowed the argument from and which genuinely is hand-written. What it did do is pin two paths that #968 makes three, so whichever of the two PRs landed second went red — the one outcome the body claimed could not happen. Non-vacuity is what the case is for, and a count says it without naming anything: `jobs.queue(` is matched as text, so a rename upstream or a narrower `sourceFiles` would empty the set and quietly pass every assertion derived from it. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01RGyh1sT84oQC5g8opVK8V8
`requestTranscription` cleared `outdated` when a transcription was requested, so a redo after a replacement that then failed left the row `failed`, `outdated: false`, carrying the previous recording's `segments` — the GET reported the old transcript as the current one, which is the contract child 4 is built against. #953 §5 and its Interfaces both define the column as true "from the moment the recording is replaced until a run for the current recording completes", and §2 already has the task write `outdated: false` on success. The writer's own clear made that write a no-op, so only the request-time one had to go: the column defaults false, so a first row and the no-key `failed` row are unaffected. The redo case asserted the flip it should have refused. Two cases join it: a failed redo keeps the old cues labelled as the old recording's, and a completed run for the new recording clears the mark. All three were watched red — the first two against the request-time clear, the third against dropping the task's. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WF43x5niA7v7AdGaSFeqmY
The comment said `segments` is "cleared to `null` when a new transcription is requested". This branch reversed that invariant so the previous recording's text stays readable, so the comment described a system that is gone while still explaining why the type is nullable. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01WF43x5niA7v7AdGaSFeqmY
|
Adopted both review findings. Pushed
Body refreshed: the Gate green: lint, typecheck, typecheck:tests, test:unit (2433). 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
…ation-transcription
|
Pushed bdfc5f9 — a base merge. The one open thread needed no code.
Ran: the lean gate on the merged head — lint, both typechecks, 2565 unit specs. Not run: Every thread on this PR is now resolved. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Two hand-rolled guards did what `extractID` from `payload/shared` already does, and the repo was already importing it in `ContentIndexBlock`. The null check stays, because `extractID` reads `.id` unguarded. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01ASR4cqCex3ynhNHLJwt4Eh
Prose is the only thing that stops the next hand-rolled copy, and two grew in one PR without it. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01ASR4cqCex3ynhNHLJwt4Eh
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
|
Pushed c0cf3bc. Two threads answered — and the sweep found a live leak. ⚠ A client key reads the transcript of a meditation it cannot read. Measured: a draft meditation is 0 rows at
Ran: lint, both typechecks, 2565 unit specs, three int suites (28). The body now leads with the blocker, and its Phases carry an unticked box for the narrowing. 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
A client key read the transcript of a meditation it cannot read. The published-only clause and Payload's trash filter are both per collection; `meditation-transcripts` carries neither drafts nor `deletedAt`, so the implicit project read #968 granted was unconstrained. `segments` is the full spoken text and `audioFilename` is a public R2 key. Option A of the question thread, chosen on the measurement the reviewer asked for: `sanitizeJoinQuery` combines the joined collection's own `read` result into the join, and disables the join outright when that result is `false`. So option B — keeping clients off the collection — would have taken the join field with it, and the join read is the whole point. The clause is spelled against the parent relationship, so it rides the join query too rather than resolving an id list per read. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01UkUssf3fUgPxg3zb5rSKa4
|
Pushed 5e578b9 — the blocker is fixed. Option A, on the measurement you asked for.
Ran: lint, both typechecks, 2565 unit specs, three int suites (85). Not run: 🤖 Written by the sydevs autonomous loop — see what this is Generated by Claude Code |
Summary
meditations.transcript, a native join. There are no custom endpoints, and whoever may read a recording may read its transcript — including the narrowing that makes that sentence true for a client key (below).statusanderrorare derived from the retained job row, not stored. A finished job row now survives its run, swept weekly byCleanupJobs.src/lib/retention/sweep.tsis the one definition of a retention sweep, shared byCleanupJobsandPurgeSubmissions. feat(admin): a generic job-stage edit view #960 recorded that engine as blocked on a one-consumer rule; this PR supplies the second consumer.src/migrations/AGENTS.mdnow says how to answer drizzle's rename-vs-create prompt without a person. That guidance is what left this branch's own migration unwritten for a day.The access narrowing (the former blocker, now closed)
A client API key read the transcript of a meditation it cannot read. Measured on
c0cf3bc: a draft meditation returned 0 rows atmeditationsfor awemeditate-web-clientkey, and 1 row atmeditation-transcripts.The published-only clause and the trash filter are both per collection (
accessConfigs.ts).meditationscarries drafts andtrash;meditation-transcriptscarries neither, so the implicit project read this PR granted was unconstrained.segmentsis the full spoken text, andaudioFilenameis a public R2 key.Option A is built (5e578b9), chosen on the measurement @Ardnived asked for. The question was whether option B — keeping clients off the collection — would still reach the transcript through the join. It would not:
sanitizeJoinQueryruns the joined collection's ownreadand sets the join tofalsewhen it denies (payload/dist/database/sanitizeJoinQuery.js:14-22), so B takes the join field with it.So a client read of
meditation-transcriptsis narrowed to its parent's state —{ 'meditation._status': { equals: 'published' }, 'meditation.deletedAt': { exists: false } }— inCLIENT_PARENT_STATE_SCOPESbeside the published-only clause it extends. Three things about it:meditationa hard delete has nulled matches neither key, so no client reads an orphan.Change outline
This is the design the review settled, not the one the branch opened with. All of @Ardnived's threads are answered and landed; the four columns they replaced (
status,outdated,stalled,error) are gone, as are both endpoints and theoutdatedmachinery.Flow — a recording is added, replaced, and re-transcribed
Two hooks, one per collection, and neither knows what the other does.
Reads — a join field, and no endpoint
#249's
virtualJoinFieldworkaround does not apply: it covers a join onto a localized relationship, andmeditation-transcriptslocalizes nothing. The atlas project carries images and files, not meditations, so its key still reads neither — the spec asserts both directions.Status — derived, never stored
segmentsis no longer a state to tell apart: a replaced recording takes its row with it, so cues on a row are always that row's recording's.The task throws now rather than writing a
failedrow (retries: 0, so nothing re-runs). The throw is what the derived status reads — catching it into a row would be a second statement of the same failure, and the one that goes stale.JobStageView(#972) gates the row onstatus: 'processing', withstaleAfterMs: TRANSCRIPTION_STALL_MSreleasing a run lost to a restart.The job row is read through
loadTranscriptJob, which narrows an id-or-row withextractIDfrompayload/sharedrather than a hand-rolled guard. It cannot be read off a populated relationship instead: field hooks run before population (payload/dist/fields/hooks/afterRead/index.js:57-58awaits every field promise, then the population promises), sodata.jobis the bare id in the hook at any?depth=— andmaxDepth: 0means the field never populates anywhere, which is what keeps an admin-only job row out of a client's answer. A join field cannot replace the read either:payload-jobscarries no relationship field, so ajoinhas noonto name.Job rows are retained, and swept weekly — through one engine
#960 settled that engine's shape and recorded it as blocked. Rule 4 puts a cross-owner module in
src/lib/, andlib-boundary.spec.tsfails asrc/lib/module with exactly one consumer — whichPurgeSubmissionswas onmain.CleanupJobsis the second, so the engine lands with the sweep that unblocks it rather than waiting on #912. What is not shared stays in each task: the slug, the schedule, the output shape, and theusersorphan sweep, whichpayload-jobshas no analogue for.Files
Two reads the review asked for went the other way, and are gone rather than moved:
Meditations/findMeditationRecording.tsandMeditationTranscripts/view.tseach wrapped one Payload call, so each call now sits in the file that makes it.The migration for the rewrite
20261017_102331_transcript_job_relationshipaddsjob_idwith its foreign key and index, dropsstatus,outdatedanderror, and drops the now-unusedenum_meditation_transcripts_status. Thedownreverses all four.Until it landed, the preview booted on the old schema and every meditation save 500'd on the missing
job_idcolumn — which is what the smoke lane'smeditations.e2e.spec.tswas reporting. No other lane can see it:push: truesyncs the schema in dev and in both test lanes, so only a Railway boot replays this chain.It was written unattended after all. drizzle's rename-vs-create prompt reads keypresses from a terminal, not from stdin, so
--skip-empty < /dev/nulland a piped newline both leave it unanswered — but over a pty it takes the highlighted default. That default iscreate column, which is correct here: the three dropped columns are drops, not renames. The prompt fires once per ambiguous column and again for the DOWN statements, four times in all.src/migrations/AGENTS.mdnow carries this, in place of the "hand it to a person" row that sent the last run away.No migration is owed for the four review rounds above, the access narrowing included. Nothing in any of them adds a column, an enum label or a table — the retention engine moves code, the hook rename moves a file, and the narrowing is a
Wherebuilt at request time.Two earlier migrations are already on the branch, and neither touches a table, a column or a row — each adds a task-slug enum label, which is what registering a task needs:
src/migrations/20261016_081411_transcribe_meditation_task.tssrc/migrations/20261017_002341_cleanup_jobs_task.tsdownis a no-op. An unused label costs nothingPreview
transcript1with the id you createdData: not seeded yet. A preview carries no content, so the links above open on whatever you upload. The preview inherits the live Lemonfox key, which no local run has — this is the only place a real transcript can be produced.
Phases
runQueueSoon, the view helpers, and the taskmeditationshooks, both endpoints, OpenAPI and docsmainmerged inextractID, the join-field question answeredTest results
5e578b9: ✓pnpm lint,pnpm typecheck,pnpm typecheck:tests,pnpm test:unit(2565 passed, 196 files)5e578b9:meditation-transcripts·role-based-access·meditation-transcription— 85 passedwemeditate-web-clientkey. The editor read in the same case is the control, so a narrowing that denied everyone fails it_statusdefaults todraft, sotestData.createMeditationproduced drafts, and the existing access case asserted a client read that the narrowing now refuses. The fixture publishes by default; without that, the case would have gone green for the wrong reasonjob-retention.spec.tsasserts the window rather than the constant beside it, watched red against a bare-date window — which would sweep a queued row{ text, start, end }key names while converting the values to milliseconds. The column storessubtitleCue—{ content, startTimeMs, endTimeMs }meditations.e2e.spec.ts, a 500 on create against a preview with nojob_idcolumn. The migration above is the fixManual verification
PREVIEW_ADMIN_EMAILand upload a short recording to a new meditation.GET /api/meditations/<id>?depth=1reachestranscript.status: "completed"with timed segments within a few minutes. This is the only check no automated lane can make — the vendor is mocked everywhere else, andLEMONFOX_API_KEYis empty in both test lanes so no run can spend a real key.processingfor the new recording — there is no window in which the previous recording's cues read as current.Notes for reviewer
maxDepth: 0never populates — and left for @Ardnived to settle. Everything else is answered and resolved.sanitizeJoinQuerydisables a join whose collection refuses the reader. Option A is what keeps "whoever may read a recording may read its transcript" true in both directions./security-reviewdid not run over this last push, which matches its trigger paths (src/plugins/access/). The run's lease ran out. The change is one branch, gated onreq.user?.collection === 'clients'and keyed by collection slug, that replaces atruewith aWhere— it can only narrow, and no other caller class reaches it. Worth a sweep anyway before merge.loadTranscriptJobstays instatus.ts, because asrc/lib/home with one consumer fails the samelib-boundary.spec.tsrule feat(admin): a generic job-stage edit view #960 hit. refactor(jobs): move the job-row read into src/lib/jobs/jobStatus.ts #983 makes the move once a second consumer clears that gate, blocked by feat(events): CSV class import as a Payload collection driven by jobs #907.retries: 0, so nothing re-runs, and the throw is exactly whatderiveTranscriptStatusreads off the job row.status: 'failed'covers one case that is not a vendor failure: a job that completed having written no cues, because its recording was replaced mid-flight. The row it would have filled is already deleted in that case.queueTranscription). That is what keepsseeds/meditation-transcripts/from paying to re-transcribe the whole library, and the seed spec pins it.jobis written back in a second update, because the job row does not exist until the hook runs. That update re-enters the hook asupdate, which the first guard returns on.web-translatorcan read a transcript, unchanged:meditation-transcriptssits in the two projects that carrymeditations, which is the same implicit project read a recording already had (docs/rules/access.md). The narrowing is a client clause and touches no manager.requireTranscriptAccesswent with them, whileUserSubmissions/endpoints/review.tsandFrames/endpoints/byNarrator.tsstill carry one. And refactor(jobs): move the job-row read into src/lib/jobs/jobStatus.ts #983, above..claude/settings.jsonallows, and that file is a protected path — so the pty recipe needs an allowlist entry added attended before the next unattended run can use it./security-reviewsweep and worth recording:maxDepth: 0onjobis enforced inrelationshipPopulationPromise, so no?depth=or?populate=can populate a job row;transcriptJobErrorextracts onlymessage, so no stack,inputorlogis exposed; no non-admin role holdscreate/updateonmeditation-transcripts, sojobcannot be repointed; the only reachableerrorstrings are our own orLemonfox returned <status>: …, never a credential; and the vendor host is a hardcoded constant withaudioFilenamerequired to equal the meditation's ownfilename.Detail
src/payload-types.tsmoves for three reasons: the two task slugs, themeditations.transcriptjoin, and the transcript row's own field set (thejobrelationship in, the four columns out). No column was added by hand — child 1 (#957) shipped the table.Fixture pre-mortem. The integration suite mocks
@/lib/lemonfox/transcribe, so it can drive a completed run and cannot make a paid call. The vendor body shape it claims —{ segments: [{ text, start, end }] }in seconds — was verified against the one normaliser, which is the real code under those assertions.getR2Urlis mocked too:CLOUDFLARE_R2_DELIVERY_URLis unset in the lane, so the real one answersundefinedand the task would refuse every run before reaching the vendor.The cue shape is the seam the CI failure was on. The vendor answers seconds under
{ text, start, end }; the column stores milliseconds undersubtitleCue's{ content, startTimeMs, endTimeMs }, closed withz.strictObjectso no unknown key lands. One shape, so a player reading a transcript and one reading subtitles read the same cue (#957).Every assertion was watched red first, against the defect it exists for: the stale-recording re-check dropped, the replaced recording's row left in place, the status derived from a column instead of the job row, a row created with cues queueing a run anyway, the normaliser's throw swallowed, the afterChange hook unwired, the task writing the meditation document, and now the client's unconstrained read of a child row.
extractIDreads.idunguarded, so both call sites keep their own null check.loadTranscriptJobtakesnumber | { id: number } | null | undefinedrather thanunknown;queueTranscriptionkeepsNumber(null)for a row whosemeditationthe foreign key has nulled.The dry run costs one more query per window than it did, in
PurgeSubmissionsonly. Itspurge()returned thefind's owndocs.length; the engine counts. A dry run is an operator action, so the shared branch was worth the query.REQUEST_TIMEOUT_MSstays at 5 minutes. #941's notes flag it against Cloudflare's 125 s proxy read timeout. That bound governs a request arriving through our zone at the origin; this is an outbound call from the Railway container toapi.lemonfox.ai, made by a queued job with no HTTP client waiting on it.The
transcriptionqueue fires at :03, :18, :33 and :48, which collides with no existing tick — two queues on one minute lose alastScheduledRunto each other's write ofpayload-jobs-stats, andtests/unit/job-schedules.spec.tsenforces the stagger.CleanupJobsschedules ontonightly, whose tick is :00, at 05:00 on Sundays.Cross-meditation dedupe is deliberately absent. The two published pairs that carry identical transcripts carry different recordings under different R2 keys, so no filename or row comparison can relate them.
Closes #953
🤖 Generated with Claude Code
https://claude.ai/code/session_01UkUssf3fUgPxg3zb5rSKa4