Skip to content

Retain on-prem captures for website-owned presets - #47

Draft
pjeweb wants to merge 1 commit into
mainfrom
pje/preset-captures
Draft

pjeweb wants to merge 1 commit into
mainfrom
pje/preset-captures

Conversation

@pjeweb

@pjeweb pjeweb commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

Describe your changes

Retain camera captures on the rack until cams-manager confirms delivery to website storage, and expose a read-only preset export for the website's initial import. The website owns subsequent preset edits.

sequenceDiagram
    actor User as Website or chat user
    participant Site as Website permissions and DB
    participant Worker as cams-manager
    participant API as control-api
    participant Disk as Capture volume
    participant S3 as Website S3
    User->>Site: Save current view via UI or monorepo chatbot tRPC
    Site->>Worker: Authorized operation ID
    Worker->>API: Capture before deadline
    API->>Disk: Persist immutable image and metadata
    API-->>Worker: Capture ID, position and SHA-256
    Worker->>Site: Request scoped upload URL
    Worker->>S3: Upload retained bytes
    Worker->>Site: Verify and commit preset with image
    Site-->>Worker: Durable delivery confirmation
    Worker->>API: Acknowledge matching capture hash
Loading
  • Add authenticated capture creation, metadata, image and receipt endpoints under /captures. Saving reads the current position and JPEG without moving the camera. Position checks around the image read reject detected changes; external movement between those observations remains possible.
  • Publish image/metadata together using durable filesystem writes. Bind each capture UUID to its original camera, verify retained bytes against their size/hash, and recover the same capture after retries or restart. Expired requests cannot create a later replacement image.
  • Add authenticated /presets/export, reading PRESETS_IMPORT_PATH. Accept a preset-only dump or the legacy chatbot export, validate preset fields and omit unrelated bot state. Missing or unreadable input returns an error.
  • Allow optional autofocus alongside focus on the existing PTZ load endpoint, forwarding only supplied values. Brightness and autoiris remain capture metadata.
  • Enable the capture/export modules and initialize retained storage at startup. Document CAPTURE_STORAGE_PATH and the separate export source in the environment example.

Companion to the draft website preset stack, based directly on main. Website migration #2443 consumes the export; Worker delivery #2444 creates/retrieves captures, uploads them to website S3, and acknowledges the matching hash after the website confirms delivery. Infrastructure #59 supplies the durable volume and read-only import mount.

Before deployment, provide a current rack export and agree on capture storage, backups and retention. Acknowledged captures remain retained; automatic pruning is not implemented.

Notes for testing your change

  • Use a simulated camera with PTZ/screenshot capabilities, a writable capture directory and a disposable preset export. Authenticate with Authorization: ApiKey <key>. GET /presets/export should work without a camera header, contain only validated preset data, and fail when its source is unavailable.
  • Send POST /captures/<uuid> with x-camera-name and an expiresAt timestamp in milliseconds within the next 60 seconds. Inspect metadata and GET /captures/<uuid>/image; the camera should not move. Repeat after the deadline and after restart: the same UUID should return the original bytes. A new expired UUID should return 410, and reusing an ID for another camera should return 409.
  • Submit the retained SHA-256 to POST /captures/<uuid>/receipt. Matching/repeated receipts should succeed, a different hash should fail, and acknowledgement should leave the capture available. Change the simulated position during capture and confirm detected movement rejects the save.
  • With the mock PTZ endpoint, compare loads with autofocus supplied and omitted; omitted optical settings should stay omitted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant