# Inkspect agent review API v1

Default origin: `https://app.inkspect.si`. An operator can set
`INKSPECT_REVIEW_ORIGIN` to a trusted alternative HTTPS origin. Plain HTTP is
allowed only on loopback for local development. Use the agent's existing file,
comparison and authenticated HTTP tools. No executable helper or extra runtime
is required. The server calculates snapshot IDs.

Use `Authorization: Bearer <INKSPECT_API_KEY>` and `Content-Type: application/json`.
Do not include any GitHub credentials. Source is sent to Inkspect Cloud and its
configured model provider. There is no local engine and no requirement for a PR,
GitHub App or pushed commit.

## Task

```json
{
  "id": "task-local-identifier",
  "instructions": "The user's original task, including subsequent corrections.",
  "criteria": [
    {"id": "C1", "text": "The required source behavior", "verification": "source"},
    {"id": "C2", "text": "The required runtime behavior", "verification": "execution"}
  ]
}
```

## Requests

- `GET /api/agent-reviews`: authenticated capabilities and feature availability.
- `POST /api/agent-reviews`: submit the payload below. Returns `202` with `id`,
  `status`, `snapshot_id`, `report` and `replayed`. No background job is created
  while the feature is disabled. Review usage consumes the key's workspace credits.
- `GET /api/agent-reviews?id=<id>`: poll the same workspace's job. `202` means
  `queued` or `running`. `200` means `completed`, `failed` or `unmeasured`.
  Inspect `status`, not just the HTTP code. `401` means the key has expired or
  been revoked; `402` means credits are unavailable; `429` means the existing
  workspace API concurrency/rate limit applies.

Payload fields below are required; unknown fields are rejected. `snapshot_id`
is optional at both the request and test-record level:

```json
{
  "schema_version": 1,
  "task": {"id": "task-id", "instructions": "Original user request", "criteria": [{"id": "C1", "text": "Acceptance criterion", "verification": "source"}]},
  "baseline": {"kind": "revision", "reference": "resolved local commit SHA"},
  "files": [{"path": "src/example.ts", "before": "old source\n", "after": "new source\n", "role": "changed"}],
  "tests": [],
  "omissions": []
}
```

`before=null` means added; `after=null` means deleted. Both cannot be null.
Context files use `role=context` and equal before/after contents. A rename is a
deletion and an addition. Paths are repository-relative. Include the full text
of selected files, never an invented or truncated diff. The server's Rust engine
computes changed lines from before/after contents. Baseline provenance is
client-supplied; the server checks supplied contents, not remote repository truth.

Omit `snapshot_id` when submitting through the skill. Cloud derives it from the
supplied files and returns it in submission/status responses. The client does
not need a local hashing tool. Existing integrations may supply a digest as an
integrity check; an incorrect value is rejected. The digest is SHA-256 of the
UTF-8 compact JSON file array sorted by path, with each file's keys ordered
`path`, `before`, `after`, `role`, prefixed with `sha256:`. Paths must be portable
relative paths without astral Unicode characters.

Tests have `id`, `command`, `exit_code` and `output`. Cloud binds them to the
submitted snapshot. If a test includes an optional `snapshot_id`, it must match
the file digest. They are always `client_supplied` evidence, never a claim of
server-executed tests. Execution criteria remain unverified. Server-side digest
assignment does not prove that the client ran a test against those exact files.
Omissions have `path` and `reason` and make coverage incomplete. If no omissions
were declared, coverage refers only to the supplied scope; the server cannot
discover an omitted local file on its own.

## Collect with existing tools

Resolve the selected local baseline once and read full before/current source
with the agent's existing tools. Include untracked additions and deletions. Do
not follow symlinks, read real environment/credential files, or include generated
output and dependencies. Apply `.inkspectignore` from the baseline, not a policy
modified by the change being reviewed. If the available tools cannot determine
an exclusion or baseline reliably, surface that gap instead of guessing.

Capture source before running newly authorized checks. Before submission,
compare covered files with that capture using the available tools. If source
changed, capture again and discard test results that no longer apply. Preserve
the exact submitted payload for idempotent recovery and the returned job ID for
polling. If source changes after submission, label the report as covering the
earlier submitted snapshot. Never install a helper or runtime for these steps.

Limits: 750,000 bytes per JSON request; 80 files; 64,000 UTF-8 bytes per before or
after value; 400,000 source bytes in total; 1–30 criteria; 10 tests with 8,000
bytes of output each; 200 omissions. Sensitive paths and recognized credentials
are rejected before admission. This filtering is not an exhaustive secret scan.

Identical canonical payloads return the same workspace job with no second model
call or charge, including after completion or a lost response. An optional
`Idempotency-Key` (up to 110 characters) can name an operation; using it with a
different payload returns `409`. A changed task, criterion, source or test is a
different request and may incur another charge.

## Result

A completed job's `report` contains `schema_version`, `snapshot_id`, `review`,
`assessments` and `evidence`. `review` follows Inkspect's report format and
includes the engine-derived decision, findings and verification gaps.
Assessments contain `criterion_id`, `status`, `reason`, `verification` and
`evidence_ids`. Source evidence has exact path, side, start/end lines and excerpt
from the submitted snapshot. Test evidence references the submitted test ID and
is explicitly client-reported. A model's unsupported citation cannot satisfy a
criterion. Missing, duplicate or unsupported assessments become `unverified`.

Raw requests are held while queued/running and cleared at terminal settlement.
Reports retain cited excerpts; private usage journals are retained for crash
reconciliation. Interrupted paid requests are not automatically replayed.

## Install the skill

Copy the `inkspect-review` directory into `.agents/skills/` for Codex or
`.claude/skills/` for Claude Code (or the corresponding user-level skill folder).
Configure the API key through the agent's local environment. Invoke the skill
with `$inkspect-review` in Codex or `/inkspect-review` in Claude Code. No hook or
automatic task-end behavior is installed by this version.
