# HealthCam: ingestion boundary test report

The local agent submits structured telemetry to the cloud. This report records an actual execution of the existing contract and API tests, not a live production probe.

## Verified behavior

| Check | Observed assertion |
| --- | --- |
| Missing API key | 401; user lookup not called |
| Unknown API key | 401; payload creation not called |
| Malformed JSON | 400; JSON error returned |
| Wrong payload source | 400; validation issues returned; payload creation not called |
| Valid request | 201; returned segment ID matches; write call includes authenticated user ID |
| Stored-payload count at cap | 429; Retry-After is 60; payload creation not called |

Nine schema tests additionally accept a valid agent payload, reject another source, reject reversed segment timestamps, reject a negative timestamp, reject an analyzer result without a status, accept an analyzer error result, accept a timestamp with an offset, reject missing sent_at, and reject sent_at without a timezone.

## A concrete walkthrough

1. The test supplies a valid synthetic payload and a dummy API key.
2. The user-lookup mock returns user-1. The stored-payload-count mock returns the configured cap.
3. The real POST handler is called directly using a Request object.
4. Assertions confirm HTTP 429, Retry-After: 60, and no call to create a recording payload.

This demonstrates an explicit rejection path before persistence is requested. It does not demonstrate an atomic limit under concurrent requests.

## Provenance

- HealthCam revision: `f8778a113914f161d15793eeecbda15c12743aa0` (clean working tree).
- Run: 30 September 2026, Europe/Rome.
- Runner: Vitest 3.2.7, Node test environment.
- Command: `npm test -- --reporter=verbose`.
- Result: 2 test files passed; 15 tests passed; 0 failed.
- API tests: `tests/ingest-payloads.test.ts`.
- Contract tests: `tests/payload-contract.test.ts`.
- Synthetic fixtures: `tests/fixtures/healthcam-payload.ts`.
- Handler: `app/api/recordings/payloads/route.ts`.
- Schema: `app/contracts/payload-contract.ts`.
- Rate-limit configuration: `lib/ingest-rate-limit.ts` (30 stored payloads within 60 seconds).

## Reproduction and limits

With authorized access to the private HealthCam repository, check out the revision above, install the lockfile dependencies with npm ci, then run the command above. The test configuration limits discovery to tests/**/*.test.ts. The Prisma module is mocked; no real database or webcam is required by these suites.

The repository remains private, so this public report is a recorded result rather than an independently runnable test package. A representative test excerpt is published in the portfolio case study.

These are isolated tests. They do not verify real database persistence, the deployed HTTP stack, concurrent rate limiting, upload retries, deletion of video files, aggregation/reconciliation, or biometric accuracy. Accepting an analyzer error at the schema boundary does not prove the agent dispatches such results. No production reliability, throughput, or accuracy metric is inferred from this run.
