# An occupancy alert, tested against a connected API

**Worked fixture replay.** Six illustrative JSON rows stand in for a public-data endpoint. No live library, public API, or model provider was contacted. The connector, immutable dataset, numerical computation, automation lane, result verification, canvas wiring, and branch comparison are real Synatrail operations in an isolated local app. The hypothesis, direction, and compiled test proposal are scripted fixture inputs so the run is deterministic.

## The question

Can a desk use a **70% occupancy alert** to catch recurring crowding? We register a falsifiable rule: at least **two** rows in the six-row feed must reach 70%. The fixture contains 42, 74, 87, 51, 78, and 62 percent, so three rows qualify. A stricter **85%** alternative retains one row. These counts describe the fixture only; they do not establish any real branch's occupancy or operational alert quality.

## Follow the canvas

1. On **My canvas**, start with the question and add a **Data connection** card. For a real investigation, configure that card with your own accessible HTTPS JSON endpoint, choose the columns to keep, and use **Read** to inspect its sample. The script uses a local replay behind an HTTPS-shaped `library.example.test` endpoint and saves the six returned rows as a versioned dataset. Its URL is illustrative and will not serve data in your browser.
2. Add the alert threshold as a **Parameter** card. In this replay it is 70 percent. Connect a model and grant the relevant automation level if you want the agent to propose and compile tests in the live product. This replay supplies the proposed test directly, with no simulated model call.
3. Inspect the **Agent test** on My canvas: the hypothesis, test, settings, context, connector, result, and derived candidate are visible together. The test binds the connection's exact dataset version to its Data port. At **full** automation, the platform performs the connector read and dispatches the numerical test; at lower levels it asks you to run the read.
4. Open the result panel. The registered metric is “Rows at or above alert” and the rule is “at least 2.” The platform's filter keeps **3 of 6** rows, stores a computation receipt, records a **met** verdict in `discovery_results`, and marks the test **verified**. “Verified” means that the registered computation completed against the pinned fixture; it is not independent verification of the fixture's origin.
5. Compare the 85% branch. The branch reuses the same pinned dataset and changes only the filter value. The computation keeps **1 of 6** rows. Synatrail's comparison records the changed step and a row-count delta of **−2** while retaining the 70% baseline.

## Evidence to inspect

- [My canvas after verification](my-canvas.png)
- [Test plan and bound data panel](result-detail.png)
- [Verification and numerical verdict](verification-detail.png)
- [Saved canvas export](canvas-export.json)
- [Investigation graph snapshot](investigation.json)
- [Run receipt, including both computations and comparison](run-receipt.json)
- [Exact API response replayed](fixture-response.json)

The receipt records the fixture SHA-256, the connector's single read, its dataset version ID, the computation's input hash and result, the registered threshold, the verified verdict, and the branch comparison. IDs and timestamps are generated by each isolated run, so they change on reproduction. The input rows and expected counts do not.

## Reproduce locally

From the repository root with Node 24 and the project's installed dependencies:

```sh
node scripts/cookbook-api-experiment.mjs
```

The script starts a private temporary Synatrail app on localhost, creates a signed-in fixture account, supplies the exact JSON response through the controlled connector reader, runs the real test lane, captures browser screenshots, writes the artifacts in this directory, and removes the temporary app database. The `model_activation` row enables the internal research computation gate for this fixture account; it does not connect a model or grant access to a live provider. Rerunning replaces these public example artifacts with the new run's IDs and timestamps.
