Standalone Intake — Backend-Profile Architecture

craig-intake is a stateless edge: it validates and forwards a SubmitReportRequest, keeping no database of its own (ADR-017). It runs in two modes:

  • integrated: forwards to CRAIG’s own craig-cases

  • standalone: forwards to an external backend

This page walks through the standalone-SHINES path. The architectural decision behind it (four approaches considered, three rejected) is ADR-042.

The flow

forward
X-JWS-Signature
same-origin proxy
POST /signed/v1/keys/register
None
Shines: verify JWS / replay
Shines: ShinesSink writes CpsRequest
craig-intake edge
BackendProfile
IntakeSink trait
Public web form
Signed API client
Keygen page
craig-cases
craig-intake-keyring sidecar
S3 bucket — SHINES ingests by bucket drop

The seam (ADR-042 §D1–D2)

A seam is a place in the code where behavior can be swapped out without editing the code at that point. Here it’s the one boundary where SHINES-specific logic plugs in, so it can be unplugged cleanly:

  • BackendProfile { None, Shines }: resolved once, in boot_standalone. Every SHINES-specific piece lives under services/craig-intake/src/backend/shines/, so removing SHINES support is a two-step operation: flip the profile from Shines to None and delete that one directory. Nothing in the core DTO or the integrated path has to change.

  • IntakeSink trait: abstracts the submission target behind two methods, forward and get_report_status. There are two implementations, CasesForwarderSink and ShinesSink. Crucially, the trait itself never references a SHINES type; ShinesSink parses its own typed views out of the raw submission Value. That’s what lets the generic seam keep compiling even with backend/shines/ deleted.

  • TrackingReference: a backend-agnostic String newtype. The cases backend wraps its report UUID in it; the SHINES backend wraps the reporter’s own client_request_id (there is no backend-assigned record id — see §"Delivery" below).

The SHINES backend (ADR-042 §D3–D7)

A submission under the Shines profile is conformed to SHINES’s CpsRequest:

  1. Typed carriers, not a Value bag: top-level SHINES inputs arrive as sibling JSON keys and parse into a typed ExtraFields; per-person fields extend the existing ChildEntry/AdultEntry; the nine narrative question* fields come from an extended NarrativeView. All of this has to stay in lockstep across four encodings of the report contract: the server plus the Rust, Python, and TS SDKs.

  2. Field-relevance rule engine: a single declared table of { field, relevant_when, required_when_relevant } entries drives the form’s show/hide/required behavior, the API, and server-side validation — one source of truth, so the three can’t drift apart.

  3. Typed mapper + RefVals crosswalk: a pure function maps CRAIG’s model onto CpsRequest, using a placeholder numeric RefVals crosswalk (craig-reference::shines, tracked in #692).

  4. Boot fidelity gates: boot_standalone refuses to start — fails closed — if any SHINES-required field has no source, a crosswalk enum is left unmapped, the object-store key prefix (CRAIG_INTAKES3_KEY_PREFIX) could escape its namespace, or the store backend is local (a local-disk drop would acknowledge reports SHINES never ingests). The bucket / endpoint / credentials load from CRAIG_STORE*, which itself refuses a missing backend.

  5. ShinesSink — delivery: GA SHINES ingests by S3 bucket drop, so ShinesSink writes to an object store via craig_store::store_blob_create (digest-verified, read-back-prechecked, no-overwrite). Per submission, under {prefix}/{client_request_id}/, it writes craig_receipt.json first (the server receipt time plus the conformed CpsRequest digest), then each signed-path attachment at attachments/{sha256}, then cps_request.json last as the completeness marker. The public nest receives no files, so it refuses a body whose supporting_documents manifest names any file with the signed path’s value-free 400 attachment-manifest-mismatch before the sink runs, and only an empty manifest reaches it (#2512). dateReported / intakeDate and the returned submitted_at are the server’s receipt time, never the client-minted id’s; a retry reads the receipt, so it converges on the same bytes and answers the original time, and the same id with different substance is the typed 409 IDEMPOTENCY_CONFLICT before any attachment is written. The claim is sticky: after a store fault between the receipt and cps_request.json, an identical retry converges, while an edited resubmission under the same id is that 409. The public form answers it by keeping every field, minting a fresh client_request_id and telling the reporter that the next Submit Report sends the report as a new submission; it never resubmits on its own, and every other failure keeps the held id (#2110). Sequential identical retries converge on every backend; on Garage (no If-None-Match) two simultaneous identical first attempts converge on the bytes but may answer different submitted_at values, and two simultaneous different submissions under one id can end last-writer-wins. The TrackingReference returned to the reporter is the client_request_id — a durable receipt, not a lookup key; there is no status-read route under the Shines profile (ADR-042 §D7). Operator requirements: the edge credential needs s3:GetObject + s3:PutObject on {bucket}/{prefix}/*, plus s3:ListBucket on the bucket conditioned on s3:prefix = {prefix}/* (without List, S3 answers a missing key 403 instead of 404, and the receipt read and the read-back precheck depend on the 404), and no s3:DeleteObject; the bucket is dedicated to the drop; configure bucket default encryption (SSE-S3, or SSE-KMS with kms:GenerateDataKey + kms:Decrypt on the key, because the read-back GET decrypts), never a policy that denies a PutObject lacking an SSE header (craig-store sends none); ACLs and retention are operator responsibilities (the objects are plaintext PII-bearing JSON).

See ADR-042 § "Amendment 2026-08-31" for the delivery decision and the (superseded) proposed API for the CpsRequest object shape.

Signed-API + keyring topology (ADR-042 §D8–D9)

Standalone-SHINES has no partner tenancy: anyone can submit through the API, as long as their detached JWS verifies against an active kid (JOSE terminology for "key id" — the header field naming which registered public key signed the request) in a known-key registry. That verification happens in a distinct handler, submit_report_signed, which isn’t bound to any partner id and accepts the full reporter-type set. It checks the JWS over the raw inbound bytes, before any typed parsing happens, against the craig-intake-keyring sidecar — the one piece of state a stateless edge actually needs — and dedupes replays by jti.

The registration page creates a passkey in the reporter’s authenticator and proposes it through a same-origin intake proxy; the keyring itself stays internal-only. See the craig-intake API reference for the full endpoint catalog.

Browser pages and passkeys

Under the SHINES profile a mandated reporter signs in the browser with a passkey (ADR-082). No key file exists: nothing is downloaded and nothing is imported. Detached JWS remains the path for SDK and machine clients.

Page What it does

/keygen

Takes a user identifier and a display name, asks the browser to create a passkey bound to those labels, and posts the ceremony to POST /signed/v1/keys/register. The passkey is pending until an administrator approves it.

/report

On submit of a mandated report, asks a passkey to sign the hash of the canonical report and posts the assertion in X-WebAuthn-Assertion. The page makes no approval check beforehand. A 401 shows one hedged message (the passkey may still be awaiting approval) and keeps the filled form.

/passkeys

Shows the identity’s passkeys once one of them signs, and lets the reporter rename the identity, revoke a passkey, or add a device. Each action is one assertion posted to POST /signed/v1/passkeys. The passkey that signed the first view signs the later actions, so a device added on the page never vouches for itself.

  • RP ID. The pages create and use passkeys under the keyring’s RP ID, which intake serves to them in /ui/config.js.

  • No passkey available. On an origin that is not a secure context, or in a browser without WebAuthn, each page says a passkey cannot be used and shows no control that would start a ceremony; a mandated submit is refused in the page and nothing is posted.

  • Dismissed prompt. A prompt the reporter dismisses or lets time out leaves a plain notice ("Signing was cancelled. Nothing was sent."), keeps the form, and sends nothing. A browser reports an authenticator that could not verify the user the same way, so the pages cannot tell the two apart.

  • Scripts. passkey.js holds the ceremonies, craig-sign.js the canonical JSON form and the attachment hash; each page has its own factory module. All are same-origin files, so the CSP stays script-src 'self'.

Theming the embedded UI (ADR-036 §4 amendment / ADR-043)

The embedded public form is themed from the jurisdiction’s bundle, not a hardcoded palette. At boot — in any mode that mounts the UI, integrated as well as standalone — the edge loads the bundle of the configuration layers CRAIG_CONFIG_SOURCE names (as the BFF and stateful services do, in src/bundle.rs) and renders the bundle’s ThemeContribution to CSS through the shared craig_state_bundle::materialize_theme_css renderer (#710), serving the result from GET /assets/theme.css. That route exists because the strict CSP (style-src 'self', no 'unsafe-inline') rules out an inline <style> tag, so the per-jurisdiction palette has to arrive over a same-origin route instead, the same approach craig-web uses. Boot fails fast if the configuration source is unset or refused, or if a resolved palette is structurally incomplete.

This was the first step of the portal-consolidation program (ADR-043), whose goal is making the edge the single themed public portal for every deployment.

The integrated edge mounts this same UI too, since P3.6 (#721, unit L7): boot_integrated sets embed_ui=true, so an integrated deployment now serves the themed, localized, accessible, attachment-capable form — at parity with the standalone one — under the UI-enabled CSP (default-src 'self') instead of the API-only default-src 'none'. The integrated devstack service carries CRAIG_CONFIG_SOURCE as a result. craig-web’s own duplicate /report was removed in Phase 5 (#736); the edge is now the sole public report portal, reached through path-based ingress (ADR-043).

Localization (ADR-044 / epic &60 Phase 3)

The embedded public pages — report, status, keygen, keys, passkeys — are localizable through the shared craig-i18n Fluent engine, the same one craig-web’s worker UI uses. That means the public string catalog is shared rather than forked.

The pages themselves are Askama templates (templates/.html) whose visible strings resolve through a t() filter, while the accompanying JS pulls its strings from window.CRAIG_I18N, emitted by GET /ui/i18n.js along with a CRAIG_T(key) helper. At boot, I18n::load resolves from craig-i18n’s *embedded public catalog — the edge ships no on-disk `locales/ directory, per ADR-017 — and overlays it with the active bundle’s terminology. A session-less locale_layer, scoped to the UI subtree, negotiates the locale by checking ?lang=, then Accept-Language, then falling back to en, and sets <html lang> accordingly.

Today this ships en-only: the localization machinery and externalized keys are in place, but authoring a second language (es) is tracked separately (#722). A key-coverage gate asserts that every template and JS key actually resolves.

Report wizard + accessibility (ADR-044 / epic &60 Phase 3)

The public report form is a staged 6-step wizard — Reporter, Incident, Adults, Children, Additional information, Review — matching craig-web’s public wizard step for step, but built on the edge’s own reportForm Alpine component. The field model, the fetch-based submit, and the $store.relevance profile gating all carry over unchanged. report-form.js tracks step state with nextStep/prevStep/goToStep; a forward move is gated on a per-step validateStep, and advancing moves focus to the newly revealed step’s heading. Step 5, "Additional information", always shows the additional_info field plus a profile-gated SHINES block, so the step is never empty even under the None/cases profile. Step 6 is a read-only review with per-section Edit jumps back. It lists the named adults and children with their counts, the same lists the submit sends.

Accessibility is first-class: a skip link; header[role=banner], nav[aria-label], and main landmarks on all four public pages; a progress nav with :aria-current; two role="alert" aria-live="polite" regions, one for per-step validation and one for submit/server errors; and step headings with tabindex="-1" so that the focus-on-advance behavior actually lands. The WCAG 2.1 A/AA gate (accessibility-audit.spec.ts) has an env-guarded Edge block that walks the wizard under both the None and SHINES profiles and audits the status, keys, and keygen pages too, so the edge — the future sole public portal — is held to zero violations.

Public attachment upload (ADR-044 / epic &60 Phase 3)

POST /public/v1/reports/{id}/attachments lets a reporter attach a file to an anonymously-submitted report. It’s anonymous by design: since a reporter has no account, the capability is simply the unguessable report UUID v7 in the path — the same model the public status read uses — and there’s no api-key or ownership check on top of it. The handler buffers the multipart body, PRE-VALIDATES it at the edge (#1324: the same compiled craig_store policy cases runs — the per-file cap while buffering, the MIME allow-list, the magic-byte sniff — plus the §U field shapes and the declared-digest check; each forwarded text part, client_request_id and file_sha256, is capped while buffering at craig-common’s MULTIPART_TEXT_PART_MAX_BYTES, 8 KiB, an over-cap part being a malformed-multipart 400 that names the part and never its value, #2632), and re-emits it to craig-cases over the service-to-service identity, sharing the same forward_upload_to_cases path the partner upload uses. Validation failures are intake’s OWN RFC-9457 errors with actionable detail (the #933 redaction only ever applied to UPSTREAM bodies, which now stay a rare defense-in-depth backstop — cases re-verifies everything). The edge per-file cap (CRAIG_INTAKEPUBLIC_MAX_FILE_BYTES, 10 MiB default) is boot-validated ⇐ the declared downstream cap (CRAIG_INTAKECASES_MAX_UPLOAD_BYTES) per the typed limit-capability contract. The public router rate-limits the endpoint per hashed client IP, and the global body limit bounds how much can be buffered — a whole-body breach mid-stream is the honest 413 payload-too-large problem document.

The route is mounted only for the cases-backed profile — BackendProfile::None, covering both integrated and standalone-None deployments. Under SHINES there is no cases backend to forward to, so the route is absent (404). build_router expresses this as attachments_sink: Option<CasesForwarderSink>: its presence both mounts the route and supplies the sink the forward needs. There is deliberately no list endpoint: a reporter only ever sees the status enum.

Success-view upload form (P3.5 / #720)

The reporter-facing UI for the endpoint above lives on the report form’s confirmation view (the x-if="submitted" success card). After a report is accepted, a single-file form with Select File and Upload Document buttons POSTs multipart/form-data to the endpoint via fetch. The report id returned by the submit call is the capability, and the outcome is reported through an aria-live feedback line. There is no list view here either.

The form only renders under the cases-backed (None) profile. The underlying gate is x-show on a non-SHINES backend_profile, so the form stays hidden under SHINES, mirroring the absent endpoint.

Its accept hint and help text describe the actual cases/craig-store default policy: PDF, images, Word, Excel, plain text, and CSV, at 10 MB each. That’s intentionally broader than craig-web’s stricter "no photographs" copy, since the store’s default policy does allow images.

Integration aids (epic &60 Phase 2)

Debug CpsRequest panel (#713)

For SHINES integration testing, the standalone-SHINES edge can echo back the exact CpsRequest it wrote to the object store, right in the submit response. It’s surfaced as a copyable debug panel below the success card, so an integrator can see and replay the payload. Because that CpsRequest carries third-party and minor PII (child and adult SSNs), the panel is fail-safe by construction:

  • Explicit-ack gate, default off. The panel only activates when CRAIG_INTAKE__DEBUG_EMIT_CPS_REQUEST is set to the exact literal value EXPOSE_SSN_PII — a stray =true won’t do it. validate() also requires backend_profile=shines and logs a loud boot warning when the flag is on. This is meant for dev and integration testing only, never production.

  • Contained. ShinesSink writes the conformed CpsRequest, as pretty JSON, into a borrowed capture slot on ForwardRequest (the same value it stores as cps_request.json), and it is never logged. The handler returns a craig-intake-local DebugReportConfirmation: a Serialize-only superset that isn’t part of the OpenAPI/SDK contract, with Cache-Control: no-store. The shared ReportConfirmation wire shape itself doesn’t change.

View-keys list + page (#714, #715)

For signer-key onboarding (register → approve → sign), the standalone-SHINES edge can list registered keys' metadata: kid, holder display name, an effective lifecycle status, and timestamps. The effective status is expired for an approved key past its expires_at, mirroring how lookup_active treats it. No key material and no holder PII identifier are ever included.

  • Gated metadata-only endpoint (#714). The keyring’s GET /keys is mounted only when CRAIG_INTAKE_KEYRING__ENABLE_KEY_LIST is set. When it’s off, the route is simply absent, so a request 404s without giving away whether the feature exists at all. The browser reaches it through a same-origin intake proxy at GET /signed/v1/keys, since the keyring itself stays internal-only (ADR-042 §D8). That proxy relays the list as-is, relays a gate-off 404 as-is, and redacts any keyring-side fault down to a generic 500.

  • View-keys page + per-profile nav (#715). A SHINES-only /keys page renders the list as a table with effective-status badges. The top-of-page nav is profile-aware: SHINES pages link Register a Key and View Keys, but never Check Status, since status lookup isn’t mounted under SHINES at all (ADR-042 §D7). The non-SHINES form links Check Status instead, in the nav and on the confirmation view. These conditional links, on the shared report.html, are driven by the relevance store’s backend_profile.

Edit this page · latest