# iSynth 输入方式与校验 / Input formats and validation

反应 JSON 是统一数据规范；CSV/Excel 列映射仅导入每行一个单步、单阶段反应。原始表格保留为来源证据。多步、多阶段及复杂测量使用 JSON/JSONL。

Reaction JSON is the common data specification. CSV/Excel mappings import one single-step, single-stage reaction per row; retain source tables as evidence. Use JSON/JSONL for multiple steps or stages and complex measurements.

[逐字段映射 / Field mapping](reaction-table-mapping.md) · [Machine-readable mapping](reaction-table-mapping.json)

## 分组 / Grouping

每行独立解析，不按编号或步骤列跨行合并；多步、多阶段实验使用 JSON/JSONL。

Parse each row independently, without grouping by identifiers or step columns. Use JSON/JSONL for multistep or multistage experiments.

## REST

`POST /api/reaction-contract/validate`：需登录，不保存数据。接受一个反应 JSON、一个表格行，或 `{"rows": [...]}`（恰好一个独立反应行）。单行请求或 rows 信封均可在顶层附带 `column_mapping`、`source_units`；它们是请求参数，不是数据列。响应的 record 是内部存储对象，上传使用原始已校验输入；公开导出使用 Step.products。

Authenticated, non-persisting validation accepts one reaction JSON object, one table row, or a rows envelope containing one reaction row. Both a single row and a rows envelope accept top-level column_mapping and source_units as request metadata, not data columns. The response record is internal storage, not an upload object; public export restores Step.products.

```json
{
  "rows": [
    {
      "reaction_identifier": "EXP-001",
      "reactant_1_structure": "CCO",
      "product_structure": "CC=O"
    }
  ]
}
```

单行映射示例 / Single-row mapping example:

```json
{
  "Substrate": "CCO",
  "Product": "CC=O",
  "Yield": "80",
  "column_mapping": {
    "Substrate": "reactant_1_structure",
    "Product": "product_structure",
    "Yield": "product_yield"
  },
  "source_units": {
    "Yield": "%"
  }
}
```

## MCP

`validate_reaction_records(records=[...])`：需 uploads:write；每次 1–50 行或对象，参数序列化后最多 1048576 字节（1 MiB）。一次调用视作一个数据工作表；每行独立解析，可校验多个反应。结果 source_rows 标明原始行号（从 1 开始）；不同工作表分开调用。

Use uploads:write; validate 1–50 rows or objects, at most 1048576 serialized UTF-8 bytes including mapping/unit arguments. One call represents one sheet and may contain multiple independent reactions. source_rows identifies original 1-based row positions. Use separate calls for separate sheets.

## 大小限制 / Size limits

REST 请求最多 2097152 字节（2 MiB）；REST/MCP 校验及完整上传解析均检查普通单元格 64000 字符、JSON 记录 512000 字符的限制。结构化 JSON 按上传时紧凑序列化后的字符数检查。上传批次另限 1048576 字节（1 MiB），可在同一 upload_id 下分批发送；不拆分一个 JSON 记录。

REST requests: 2097152 bytes (2 MiB). REST/MCP validation and full upload parsing enforce 64000 characters per ordinary cell and 512000 characters per JSON record, using compact JSON for objects. Upload batches have a separate 1048576-byte (1 MiB) limit; send smaller batches under the same upload_id. Do not split one JSON record.

上传页文件预览仅抽样展示，并可能截断长文本，不代表科学校验或完整解析。 / File previews sample data and may truncate text; they are not scientific validation or a full parse.

校验通过不等于已上传或已入库；上传后检查解析报告与最终计数。 / Validation is not an upload receipt; inspect the final parse report and committed counts.
