# The job adapter, live — 2026-09-12

Evidence for `182.C.15` (submit, read, list, cancel) and `182.C.26` (likeness
authorizations and their withdrawal). Five responses from a BFF this session
started against the local Postgres, not from a schema.

## Method

`apps/oshun/bff/src/server.ts` under `tsx` on :4010, with
`OSHUN_V1_DATABASE_URL` pointed at `oshun_dev`. Secrets were sourced through a
throwaway `/tmp` script, deleted at the end; none is in this directory, and the
captures were grepped for key material before committing. The server was torn
down and `:4010` confirmed free. Tokens were minted with `createDevAuthToken`.

## The finding that unblocked everything else

The previous capture's README said the environment's prisma CLI "is 6.19 and
cannot regenerate the v7 schema". **That was wrong, and it was the only reason
five adapters reported unbound.** The root `pnpm exec prisma` resolves to
nothing; `libs/oshun/persistence/node_modules/.bin/prisma` is 7.8.0 and
regenerates the schema in 1.5 seconds. With the client regenerated, the boot
line changes from one bound port to seven:

```
human-video api: 32 endpoints live; bound: preset catalogue, project drafts,
idempotency records, upload sessions, identity packs, audio takes, jobs;
answering 503 until bound: candidates, reviews (queue and decisions), releases,
erasure, project listing
```

`boot-line.txt` carries it verbatim.

## The 500 that was hiding behind the 503s

With the idempotency port bound for the first time, **the first POST of every
idempotent operation answered 500**:

```
new row for relation "human_video_idempotency" violates check constraint
"human_video_idempotency_response_only_when_complete"
```

Prisma writes a JS `null` into a `Json?` column as the JSON **value** null, and
jsonb `'null'` is not `IS NULL`. The reservation row therefore carried a
response while its status was `in-flight`, which the CHECK refuses — correctly.

The fix is to **omit the column** rather than write `null` to it: an omitted
column takes its default, which is SQL NULL. Prisma's `DbNull` sentinel would
also work, but it lives behind `@prisma/client/runtime/client`, which the BFF's
vitest alias maps into a file path — so importing it makes every spec in the app
unloadable. Omission needs no sentinel and no import.

The two values are genuinely different facts: "no body was kept" against "the
body was the value null", and a response body can legitimately be null. The row
type now says so — `response?: StoredResponse | null` — and `rowFor` spreads the
key in only when there is one.

Measured after the fix, on the same database:

```
   key    |  status   | response_is_sql_null
 k-omit-1 | completed | f
 k-ev-1   | abandoned | t
```

An abandoned key holds SQL NULL; a completed one holds the body it owes a retry.

This could not have been found by a test against a double. It needed a real
client and a real constraint, which is the argument for this capture existing. A
double that fires on the same condition now stands in
`human-video-api-store.spec.ts` so it cannot come back.

## Idempotency, end to end

`POST /jobs` twice under `Idempotency-Key: k-omit-1` returned **202** both times
with the same `jobId` (`3d49ccf4…`), and the job table held three rows, not
four. The second call replayed the first answer rather than submitting again.

## The four captures

| file                                | request                                         | status                                                |
| ----------------------------------- | ----------------------------------------------- | ----------------------------------------------------- |
| `submit-202.json`                   | `POST /jobs`, real pack, live consent           | **202** — job written, `authorizationIds: [auth-ama]` |
| `submit-403-consent-withdrawn.json` | the same after a whole withdrawal               | **403** `hv.consent.missing`, terminal                |
| `submit-403-scope-exceeded.json`    | the same after a withdrawal of `proj-live` only | **403** `hv.consent.scope_exceeded`                   |
| `list-200.json`                     | `GET /jobs`                                     | **200** — keyset page, `hasMore: false`               |

## The withdrawal, measured

One authorization covering `proj-live` and `proj-other`, withdrawn for
`proj-live` only:

- `POST /jobs` for **proj-live** → 403 `hv.consent.scope_exceeded`,
  `"proj-live" is not one of the 1 project(s) named`.
- `POST /jobs` for **proj-other** → 202, `authorizationIds: ["auth-ama"]`.

The store takes the withdrawn projects out of `projectIds` and returns what is
left. A withdrawal that empties the list drops the scope entirely rather than
returning one with no projects — an empty `projectIds` makes `coversUse` throw
`dimension_unspecified`, and the caller turns that into "this record is
incomplete", which is a complaint about our bookkeeping in place of the fact
that somebody took their permission back. Dropped, the answer is
`hv.consent.missing`: true, terminal, and the sentence the creator needs.

## What the submitted row actually holds

```
 job_id  | stage      | cast_ids   | authorization_ids | unmeasured | attempts
 a38ede84| validating | {cast-ama} | {auth-ama}        |          5 |        0
```

Five named unmeasured facts and zero attempts, both stored as arrays because the
migration requires them to be. `unmeasuredFacts` empty would say every
pre-generation check ran; absent would say the same thing more cheaply. The five
are real — no frame exists before a render, no reference embeddings were
supplied, the pack records no viewing angle, and no approved audio is attached.

## What is still unbound

`candidates`, `reviews`, `releases`, `erasure` and `project listing`. A job can
be submitted, read, listed and cancelled; nothing yet produces a candidate from
one, because there is no provider adapter behind the render.

## What a real end-to-end render is blocked on, measured rather than assumed

`182.C.40.01` asks for at least one production-configured render demonstrated
end to end. As of this commit the CODE path is complete and proven hermetically
in `human-video-render-end-to-end.spec.ts`: a planned job goes through the
request builder, the provider transport, the download, the container probe and
the candidate store, with only the four boundaries a test may replace standing
in — the database driver, the object store, the HTTP transport and ffprobe.

Two things stop that from being run for real from this machine, and **neither is
a money problem**. ~$4.35 of the approved canary budget remains and is not the
constraint.

1. **A consented reference.** A human-video render needs an identity pack, and a
   pack needs photographs of a real person who agreed to this use. That is
   `182.C.33.01`'s corpus, which is blocked. Rendering a stand-in face would be
   the exact thing this phase refuses.
2. **A reference URL the provider can fetch.** `placeReferences` hands the
   provider a URL per reference, and the provider fetches it. The local object
   store is MinIO on a private port; a presigned URL to it is unreachable from
   OpenRouter. A render with no references is not a likeness render, so it
   cannot demonstrate the item either.

So `182.C.40.01` is **blocked on a consented corpus and on a publicly reachable
object store**, not on the pipeline. That is a different sentence from the one
this item carried before today, when the pipeline itself did not exist.
