# Noodle Interpret developer preview
The local API interprets a short voice note or text using a project-owned context endpoint. Every resolved field carries evidence. A partial result keeps supported values and lists outstanding claims.

## Start
Use Node 24.16.0 and pnpm 11.5.2. From the service root (`Noodle-Interpret/` in Borg Lite), run `pnpm install --frozen-lockfile`, `pnpm ops:init`, then `pnpm dev:up`. The console is at /console on the loopback server. The owner key stays in the .state directory. Set NSI_MODE=openrouter and explicit NSI_OPENROUTER_SPEECH_MODEL and NSI_OPENROUTER_FIELDS_MODEL for real inference. PUT {"key":"…"} to /v1/connections/openrouter/key using an authenticated local owner. Inference uses only that project’s ordinary key. An owner can also use Connect OpenRouter in the console to authorize the account in a browser. Fixture mode accepts the sample text and is intended for offline validation.

## Submit a note
POST raw audio to /v1/assets with a project bearer, an Idempotency-Key, and Content-Type. Submit POST /v1/interpretations with another Idempotency-Key, profile "field-service/labor@1" and a source such as {"id":"s1","role":"input","media_type":"audio/ogg","asset":"<asset ID>"}. Supply context.scope_ref, context.as_of and context.bindings.approvals. Poll the Location header until succeeded or failed. Inspect each claim’s state and evidence before taking a business action.

## Register a context endpoint
POST /v1/context-bindings with {"url":"https://your-service.example/approval","bearer":"<dedicated credential>"}. Save the returned challenge at that handler. When the service sends {"purpose":"verify","challenge_id":"…"}, respond with {"proof":"<challenge>"}. POST /v1/context-bindings/{id}/verify. Normal read requests contain scope_ref, as_of, purpose, query and request_id. Return scope_ref, revision, effective_at, valid_until and rows such as [{"id":"A","approved_minutes":120}]. Missing, inconsistent, or unauthorized records cannot resolve the variance.

## Revisions, profiles and evaluation
POST /v1/interpretations/{id}/revisions with parent_revision and additional sources. GET /v1/interpretations/{id}/revisions/{n} for the immutable earlier result. GET /v1/profile-templates for complete examples of field manifests. POST /v1/profiles to freeze a custom definition and receive a versioned reference. POST /v1/datasets and /v1/evaluations to compare registered profiles on private snapshot fixtures. Supply a JSON array of cases, each with id, scope, as_of, sources, snapshots and expect.fields. POST /v1/evaluations with dataset, candidates and an optional split (holdout or development). It returns 202. Poll GET /v1/evaluations/{id} for per-case and per-language results. Both supplied and private profiles use the same frozen inputs. A live evaluation can spend the project’s OpenRouter credits once per case per candidate. An owner can POST a version, evaluation ID and expected_current to /v1/profiles/{domain}/{name}/promotions to move @production. The first promotion uses null for expected_current. A rollback uses the same endpoint and a qualifying evaluation for the target version.

## Errors and scope
Foreign project resources return 404. Paid call outcomes that cannot be determined are failures. Reuse your Idempotency-Key only with the same request. This local transport has no hosted release or verified cloud receipts. See SPEC.md and RUN.md for full beta requirements.

## SDK downloads and MCP
Run `pnpm sdk:build` before starting the local download service. GET /downloads/manifest.json for versioned filenames and SHA-256 digests. Install the verified tarball with npm install or the verified wheel with python -m pip install. The public endpoints are /downloads/noodleseed-interpret-0.1.0.tgz and /downloads/noodleseed_interpret-0.1.0-py3-none-any.whl.

A local MCP client can use Streamable HTTP at /mcp with the separate MCP bearer generated by ops:init. It supports list_profiles, interpret, get_interpretation, clarify_interpretation, run_evaluation, get_evaluation and interpret://docs/guide. It enforces the same project authorization as REST. Production OAuth consent is a separate hosted release gate.

## Receive completion events
Register a project subscription with POST /v1/webhooks using url and events, e.g. ["interpretation.succeeded","revision.failed","evaluation.succeeded"]. Save the one-time signing_secret securely. Install the challenge at your receiver and POST /v1/webhooks/{id}/verify. The verification POST to your receiver contains only purpose and challenge_id. Respond with a JSON proof as for context bindings.

For each delivery, verify the HMAC-SHA256 of the timestamp, a period and the exact raw request body using the signing secret. Compare the hex digest to Nsi-Signature after removing v1= using a constant-time comparison. Reject timestamps farther than five minutes from the current time. Verify the event ID in the signed body, deduplicate it before processing, and return 2xx to acknowledge. Poll /v1/webhook-deliveries for attempts. A project owner can POST /v1/webhook-deliveries/{id}/redeliver with an idempotency key; the signed event ID persists across attempts.

## Project vocabulary
A private profile can set voice.vocabulary (up to 50 phrases) and voice.refinement to "uncertain". An operator can pin NSI_OPENROUTER_REVIEW_MODEL alongside the speech and field models. A qualifying voice note can then make one additional project-funded audio review call. The service rejects proposed transcript changes that alter digits or substitute a business name for ordinary words without supporting evidence.

## Correct an observation
Include corrects in a revision body, e.g. {"parent_revision":1,"sources":[{"id":"clarification","role":"input","media_type":"text/plain","text":"Actually three hours"}],"corrects":["reported_minutes"]}. Use an observed claim ID. The revised result links changes to the prior revision and recomputes dependent values against the original snapshot by default. If the new evidence is insufficient the targeted field becomes unresolved. The previous result remains readable under its original revision number.

## Hosted owner access

Open the private owner invitation on the final HTTPS origin in a browser supporting WebAuthn JSON credential parsing. Select **Enroll owner passkey** and complete local user verification. Return to the console and choose **Sign in with a passkey** on later visits. Enrollment binds one project to this owner. The project needs its own authorized budget and tested route before paid processing.

**Connect OpenRouter** starts account consent for the signed-in project. A freshly verified passkey is required to start and finish the exchange. The provider callback returns to the console after the service validates and encrypts the ordinary key. For app access the owner can POST `{"scopes":["runs:read"]}` to `/v1/keys` with the session cookie and the CSRF token from `GET /auth/session`. Capture the returned token privately. DELETE `/v1/keys/{id}` with a fresh owner session to revoke it.

## Hosted comparisons, notifications and MCP

Create a private dataset from labeled cases with a development or holdout split. Import copies referenced audio into project-private dataset retention. POST an evaluation with immutable candidate versions, dataset ID, optional split and a positive integer `budget_micro_usd`. The service rejects a budget below the sum of the pinned per-job bounds. Evaluation jobs use frozen context. A successful holdout report can authorize an owner to promote an eligible private version. Supply the expected current alias, target version, evaluation ID and an idempotency key. Rollback uses the same checks on a prior version.

Register interpretation success or failure subscriptions at `/v1/webhooks`. Keep the returned signing secret privately and answer the ownership challenge before delivery. Inspect attempts at `/v1/webhook-deliveries`. To retry a completed or dead delivery, POST its `/redeliver` operation. Receivers should deduplicate using Nsi-Event-Id.

The hosted MCP resource is the exact public origin plus `/mcp`. Register a named public client through `pnpm ops:mcp-client --manifest /secure/nsi-beta.json --client NAME --name LABEL --redirect EXACT_CALLBACK`. Discovery advertises the S256 authorization-code flow. The signed-in owner reviews the project, client, scopes and paid permissions and follows the return link. Send the same resource when exchanging or refreshing a token. Refresh tokens rotate and a reused refresh token revokes its family. MCP tokens are audience-specific.

## Usage export

With a key scoped to `usage:read`, request `GET /v1/usage` for a page of platform records or `GET /v1/usage.csv?month=2026-11` for a UTC calendar month. A blank provider amount with cost source `unknown` means the provider did not report a usable charge. The platform unit identifies an interpretation revision or evaluation case/candidate. Use the customer's OpenRouter statement for billing reconciliation.
