# Metamorphose civil diagnostics integration

## Boundaries
Read-only equipment health and lab planning handoff. No tracking, weapon control,
autopilot commands, live tactical fusion, private server feeds or autonomous action.
This is not universal vendor qualification. Test your device specification before use.

## In the platform
Open Developer hub, import output from the existing equipment-health adapter, or
test the synthetic diagnostics sample. Imports stay in the current browser tab.
Valid Lab engineering calculations join the same snapshot and are available as
context when ORION answers. Readings expire 30 minutes after receipt; the original
device timestamp is retained so an old measurement is not presented as current.
Snapshot export preserves the current values and evidence labels. Clear removes
the shared readings, not the Lab inputs. No cross-tab or team synchronization.

## Local field mapping
Use the existing `/edge/equipment-health.py` and its configuration file to map
vendor CSV/JSONL fields. Pass its output to Developer hub as a local file. Only
device_id, timestamp, status, battery_pct and temperature_c are allowed.

## HTTPS API
POST /api/public/integration/normalize accepts `{ "records": [...] }`.
GET on the same URL returns the OpenAPI 3.1 contract. No key is required because
the endpoint only validates your input and stores nothing. Do not send secrets.
1–200 records; 128 KiB body; JSON; timestamps with timezones; battery 0–100%;
temperature -273.15–10000 °C. Unknown or command fields are rejected.
This is request/response, not a persistent feed or telemetry upload service.

## JavaScript (browser or modern Node)
Download monitoring-client.mjs; no package publication is implied.

```js
import { DiagnosticsClient } from './monitoring-client.mjs';
const client = new DiagnosticsClient();
const result = await client.normalize([{
  schema: 'equipment-health/v1', device_id: 'LAB-01',
  timestamp: new Date().toISOString(), status: 'ok', battery_pct: 84
}]);
console.log(result.stored); // false
```

## Python (3.8+, Windows/macOS/Linux; tested on Linux)
Download monitoring_client.py beside your program; no pip package is implied.

```python
from monitoring_client import DiagnosticsClient
from datetime import datetime, timezone
result = DiagnosticsClient().normalize([{
    "schema": "equipment-health/v1", "device_id": "LAB-01",
    "timestamp": datetime.now(timezone.utc).isoformat(), "status": "ok"
}])
assert result["stored"] is False
```

## Embed (any web portal that permits custom elements)
```html
<script src="https://metamorphosesystems.com/integration/diagnostics-viewer.js"></script>
<metamorphose-diagnostics></metamorphose-diagnostics>
```
The widget reads local files or a `records` property set by your portal. It sends
nothing over the network. It exposes no token attribute, avoids HTML interpolation,
and emits `diagnostics-loaded` with a count only. Its data does not implicitly join
the platform tab snapshot. Styling uses --surface, --ink and --line custom properties.
Publish the updated app before using the hosted download/widget URLs externally.