@delta-infra/cli 1.1.17 → 1.1.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/README.md +520 -506
  2. package/checksums.txt +5 -5
  3. package/package.json +3 -2
  4. package/scripts/install-wizard.js +688 -701
  5. package/scripts/install.js +442 -442
  6. package/scripts/run.js +65 -65
  7. package/skills/delta-protein/AGENTS.md +73 -0
  8. package/skills/delta-protein/SKILL.md +389 -0
  9. package/skills/delta-protein/agents/openai.yaml +4 -0
  10. package/skills/delta-protein/references/bfitter.md +64 -0
  11. package/skills/delta-protein/references/catapro_predict.md +63 -0
  12. package/skills/delta-protein/references/catpred_predict.md +65 -0
  13. package/skills/delta-protein/references/caver_tunnel_analyze.md +63 -0
  14. package/skills/delta-protein/references/consensus_mutation.md +61 -0
  15. package/skills/delta-protein/references/consurf_predict.md +67 -0
  16. package/skills/delta-protein/references/crop_sequence.md +69 -0
  17. package/skills/delta-protein/references/dock.md +82 -0
  18. package/skills/delta-protein/references/dock_score.md +70 -0
  19. package/skills/delta-protein/references/easifa_predict_active_site.md +70 -0
  20. package/skills/delta-protein/references/ephod_predict_mutation.md +66 -0
  21. package/skills/delta-protein/references/ephod_predict_protein.md +61 -0
  22. package/skills/delta-protein/references/esmfold2_predict.md +67 -0
  23. package/skills/delta-protein/references/evcouplings_mutation.md +64 -0
  24. package/skills/delta-protein/references/fasta_to_sequence.md +59 -0
  25. package/skills/delta-protein/references/foldseek.md +61 -0
  26. package/skills/delta-protein/references/generate_msa.md +61 -0
  27. package/skills/delta-protein/references/interpro_analyze.md +63 -0
  28. package/skills/delta-protein/references/mpnn_design_sequence.md +71 -0
  29. package/skills/delta-protein/references/multievolve.md +73 -0
  30. package/skills/delta-protein/references/pisa_query.md +70 -0
  31. package/skills/delta-protein/references/plip_analyze.md +65 -0
  32. package/skills/delta-protein/references/pocket_prediction.md +63 -0
  33. package/skills/delta-protein/references/protein_design.md +65 -0
  34. package/skills/delta-protein/references/protein_evolution.md +77 -0
  35. package/skills/delta-protein/references/protein_sol_predict_mutation.md +66 -0
  36. package/skills/delta-protein/references/protein_sol_predict_protein.md +61 -0
  37. package/skills/delta-protein/references/protenix.md +66 -0
  38. package/skills/delta-protein/references/protrek_search.md +90 -0
  39. package/skills/delta-protein/references/pubchem_search.md +68 -0
  40. package/skills/delta-protein/references/pubmed_search.md +79 -0
  41. package/skills/delta-protein/references/reap_design_primer.md +69 -0
  42. package/skills/delta-protein/references/rfd3_design.md +65 -0
  43. package/skills/delta-protein/references/structure_to_sequence.md +61 -0
  44. package/skills/delta-protein/references/summarize_result.md +68 -0
  45. package/skills/delta-protein/references/surface_charge.md +84 -0
  46. package/skills/delta-protein/references/uniprot_batch_query.md +63 -0
  47. package/skills/delta-protein/references/uniprot_query.md +64 -0
  48. package/skills/delta-protein/references/zero_shot_mutant_candidates.md +76 -0
  49. package/skills/delta-protein/scripts/gen_references.py +167 -0
  50. package/skills/delta-protein/scripts/output_metadata.json +275 -0
  51. package/skills/delta-sandbox/SKILL.md +388 -388
  52. package/skills/delta-sandbox/agents/openai.yaml +4 -4
  53. package/skills/delta-sandbox/references/commands.md +58 -58
  54. package/skills/delta-sandbox/references/lifecycle.md +100 -100
  55. package/skills/delta-sandbox/references/recipes.md +138 -138
  56. package/skills/delta-science/AGENTS.md +47 -47
  57. package/skills/delta-science/SKILL.md +227 -185
  58. package/skills/delta-science/agents/openai.yaml +4 -4
  59. package/skills/delta-science/references/antbo.md +105 -100
  60. package/skills/delta-science/references/delta-bo.md +92 -89
  61. package/skills/delta-science/references/gsasii.md +118 -116
  62. package/skills/delta-science/references/lammps.md +68 -66
  63. package/skills/delta-science/references/ldm-bo.md +132 -129
  64. package/skills/delta-science/references/materials-design.md +130 -118
  65. package/skills/delta-science/references/pubchem.md +128 -126
  66. package/skills/delta-science/references/pymatgen.md +69 -68
  67. package/skills/delta-science/references/qe.md +134 -125
  68. package/skills/delta-science/references/rdkit.md +141 -138
  69. package/skills/delta-science/references/strbo.md +95 -87
  70. package/skills/delta-science/references/synbo.md +201 -198
  71. package/skills/delta-science/references/xrd.md +619 -101
  72. package/skills/delta-science/scripts/catalog.py +92 -92
  73. package/skills/delta-science/scripts/generated_catalog.py +69 -69
  74. package/skills/delta-science/scripts/invoke.py +346 -346
  75. package/skills/delta-shared/SKILL.md +113 -111
  76. package/skills/delta-shared/agents/openai.yaml +4 -4
  77. package/skills/manifest.json +20 -19
@@ -1,81 +1,206 @@
1
- # XRD Cloud Compute 详细规则
1
+ # XRD Cloud Compute API Reference
2
2
 
3
- `xrd` 是通过 Science 工具代理访问 XRD cloud compute 的真实工具。所有调用必须经由
4
- `delta-cli`,禁止使用 broker URL、`curl`、`requests`、`httpx`、浏览器或本地 XRD
5
- 科学库绕过 CLI。本文是 `delta-science` 的工具 reference,不是第二套 HTTP 客户端。
3
+ The OpenAPI contract version is `1.2.0`. Business requests and responses use
4
+ `schema_version: 1`.
6
5
 
7
- ## 工具与 endpoint
6
+ This reference covers endpoints, artifact identities, request parameters, call
7
+ sequences, refinement jobs, quality assessment, and error handling. Replace
8
+ `art_<...>`, `<sha256>`, and `refjob_<...>` placeholders with values returned by
9
+ the service in the same workflow.
8
10
 
9
- 执行前使用实时目录确认当前环境中的 canonical 名称和启用状态:
11
+ ## 1. Tool and endpoints
10
12
 
11
- ```text
12
- delta-cli science list
13
- delta-cli science endpoints list xrd
14
- ```
15
-
16
- `xrd` endpoint 名称必须逐字取自第二条命令的结果。当前 reference 覆盖以下稳定契约:
13
+ The registered tool is `xrd`, tool ID `30`. The
14
+ [tool record](http://8.141.101.94:8001/api/v1/tools/30) and
15
+ [endpoint catalogue](http://8.141.101.94:8001/api/v1/tools/30/endpoints)
16
+ identify 27 registered endpoints, all enabled. The catalogue server is a tool
17
+ registry and invocation proxy; it is not the compute service base URL.
17
18
 
18
- | endpoint | 方法/用途 | 请求类型 |
19
- | --- | --- | --- |
20
- | `healthz`、`readyz`、`capabilities`、`xmatcher-status` | 就绪、能力和数据库状态 | 只读 JSON |
21
- | `xmatcher-artifacts` | 上传观测曲线、模型输入、CIF 或仪器参数 | `invoke --file` |
22
- | `xmatcher-artifact`、`xmatcher-artifact-content` | 查询/读取 artifact | `invoke --path-params` |
23
- | `xqueryer-predictions` | XQueryer 单相候选预测 | JSON |
24
- | `xmatcher-detect-peaks`、`xmatcher-match` | 峰检测和单相匹配 | JSON |
25
- | `xmatcher-multiphase-match`、`xdecomposer-predictions` | 多相匹配和相分解 | JSON |
26
- | `xmatcher-cif-xrd`、`xmatcher-pdf-peaks-xlsx` | CIF 模拟及 PDF 峰表导出 | JSON/二进制 |
27
- | `xmatcher-refinement-patterns` | 生成精修输入和 provenance manifest | JSON |
28
- | `refinement-fullprof`、`refinement-gsasii`、`refinement-wpem` | 提交对应后端精修作业 | JSON + header |
29
- | `refinement-job`、`refinement-job-events`、`refinement-job-artifacts` | 查询精修作业 | `invoke --path-params` |
30
- | `refinement-job-cancel` | 请求取消精修作业 | `invoke --path-params` |
31
- | `mp500-cif-exports` | MP500 结构导出为 CIF | JSON |
19
+ Catalogue APIs, relative to `http://8.141.101.94:8001`:
32
20
 
33
- 目录是最终权威。若 endpoint 不在实时目录中,停止并报告配置问题,不改名重试。
21
+ | Method and path | Purpose |
22
+ | --- | --- |
23
+ | `GET /api/v1/tools/30` | Tool identity and configuration |
24
+ | `GET /api/v1/tools/30/endpoints` | All registered XRD endpoints |
25
+ | `GET /api/v1/tools/30/endpoints?status=true` | Enabled XRD endpoints |
26
+ | `GET /api/v1/tools/name/xrd/endpoints` | Endpoint lookup by tool name |
34
27
 
35
- ## CLI 参数映射
28
+ Catalogue responses use `code`, `message`, and `data`; `code=0` indicates success.
29
+ Endpoint records include `id`, `tool_id`, `name`, `path`, `method`, `price`,
30
+ `featurekey`, and `status`. Registration and enabled status do not establish
31
+ backend readiness. Recheck availability and prices before execution:
36
32
 
37
33
  ```text
38
- --data 上游 JSON body
39
- --params 上游 URL query 参数
40
- --path-params 替换 endpoint path 中的 {artifact_id}/{job_id}
41
- --headers 额外上游请求头,例如 Idempotency-Key
42
- --file 将本地文件通过 file_base64 传给工具代理
43
- --content-type file 的原始 MIME 类型
34
+ delta-cli science list
35
+ delta-cli science endpoints list xrd
44
36
  ```
45
37
 
46
- `--params` 不能替代 `--path-params`。不要把本地路径、base64、路径参数或幂等键塞进
47
- 普通业务 `--data`。`science file` 是 QE/Materials Design 等独立文件接口;XRD 的
48
- `xmatcher-artifacts` 属于工具代理 endpoint,应使用 `science invoke --file`。
38
+ Use endpoint names exactly as registered. HTTP paths below are relative to the
39
+ registered upstream compute service. Price values are the catalogue's `price`
40
+ field; they do not specify a currency. All listed records have `status=true`.
41
+
42
+ | Endpoint ID | CLI endpoint | HTTP method and path | Purpose / response | Price |
43
+ | --- | --- | --- | --- | --- |
44
+ | 128 | `healthz` | `GET /healthz` | Process liveness, JSON | 0 |
45
+ | 129 | `readyz` | `GET /readyz` | Service readiness, JSON | 0 |
46
+ | 130 | `capabilities` | `GET /v1/capabilities` | Components, versions, verification, modes, and limits | 0 |
47
+ | 131 | `xqueryer-predictions` | `POST /v1/xqueryer/predictions` | Single-phase model predictions | 3 |
48
+ | 132 | `xmatcher-detect-peaks` | `POST /v1/xmatcher/detect-peaks` | Observed peak detection | 4 |
49
+ | 133 | `xmatcher-match` | `POST /v1/xmatcher/match` | Single-phase matching | 4 |
50
+ | 134 | `xmatcher-multiphase-match` | `POST /v1/xmatcher/multiphase-match` | Multiphase candidate matching | 4 |
51
+ | 135 | `xmatcher-cif-xrd` | `POST /v1/xmatcher/cif-xrd` | Theoretical XRD simulation from CIFs | 4 |
52
+ | 136 | `xmatcher-pdf-peaks-xlsx` | `POST /v1/xmatcher/pdf-peaks-xlsx` | Theoretical peak tables, binary XLSX | 8 |
53
+ | 137 | `xmatcher-status` | `GET /v1/xmatcher/status` | XMatcher database status | 0 |
54
+ | 138 | `xdecomposer-predictions` | `POST /v1/xdecomposer/predictions` | Multiphase model decomposition | 2 |
55
+ | 139 | `xmatcher-refinement-patterns` | `POST /v1/xmatcher/refinement-patterns` | Corrected pattern and provenance manifest | 0 |
56
+ | 140 | `mp500-cif-exports` | `POST /v1/mp500/cif-exports` | Export a CIF by database identity | 0 |
57
+ | 141 | `xmatcher-artifacts` | `POST /v1/artifacts` | Upload file bytes and return an artifact reference | 0 |
58
+ | 143 | `xmatcher-artifact` | `GET /v1/artifacts/{artifact_id}` | Artifact metadata | 0 |
59
+ | 144 | `xmatcher-artifact-content` | `GET /v1/artifacts/{artifact_id}/content` | Artifact content, binary | 0 |
60
+ | 145 | `refinement-job` | `GET /v1/refinement-jobs/{job_id}` | Job status and results | 0 |
61
+ | 146 | `refinement-job-cancel` | `POST /v1/refinement-jobs/{job_id}/cancel` | Request cancellation | 0 |
62
+ | 147 | `refinement-job-events` | `GET /v1/refinement-jobs/{job_id}/events` | Paginated job events | 0 |
63
+ | 148 | `refinement-job-artifacts` | `GET /v1/refinement-jobs/{job_id}/artifacts` | Public job artifacts | 0 |
64
+ | 149 | `refinement-fullprof` | `POST /v1/refinement-jobs` | Submit a FullProf job, HTTP 202 | 15 |
65
+ | 150 | `refinement-gsasii` | `POST /v1/refinement-jobs` | Submit a GSAS-II job, HTTP 202 | 12 |
66
+ | 151 | `refinement-wpem` | `POST /v1/refinement-jobs` | Submit a PyXplore/WPEM job, HTTP 202 | 10 |
67
+ | 160 | `simulation-cif-parse` | `POST /v1/simulation/cif-parse` | Parse CIF data blocks | 1 |
68
+ | 161 | `simulation-cif-peaks` | `POST /v1/simulation/cif-peaks` | Simulate reflections for a selected block and wavelength | 1 |
69
+ | 162 | `pdfreporter-analyses` | `POST /v1/pdfreporter/analyses` | Multiphase peak assignments and charts | 8 |
70
+ | 163 | `pdfreporter-assignments` | `POST /v1/pdfreporter/analyses/assignments` | Recompute analysis with manual assignments | 8 |
71
+
72
+ The three refinement CLI endpoints select backend and billing entries in the
73
+ proxy. The compute service exposes one job submission route. HTTP `backends`
74
+ values are `pyxplore`, `fullprof`, and `gsasii`; `refinement-wpem` corresponds to
75
+ PyXplore/WPEM. Match the CLI endpoint and requested backends to the proxy configuration.
76
+
77
+ ### Chemistry gateway
78
+
79
+ The Chemistry gateway prefix is `/api/v1/chem/xrd`. Allowed business routes are
80
+ exposed as `/api/v1/chem/xrd/v1/...`. The gateway injects an upstream service token,
81
+ rewrites `Location`, `content_url`, and job `links`, and preserves business HTTP
82
+ status codes and download headers.
83
+
84
+ - `GET /api/v1/chem/xrd/health` calls compute `/readyz`.
85
+ This aggregate health endpoint uses the gateway's `BaseResponse` envelope.
86
+ - The gateway allowlist excludes `/v1/xdecomposer/predictions`, both
87
+ `/v1/simulation/...` routes, and both `/v1/pdfreporter/...` routes. Requests to
88
+ these paths through this Chemistry gateway return 404. They are implemented by
89
+ the compute service; access through other proxies depends on their configuration.
90
+ - `/v1/identification/predictions`, `/v1/structures/cif-exports`, and
91
+ `/v1/identification-jobs/...` appear in the gateway allowlist but have no
92
+ corresponding routes in this compute service implementation.
93
+
94
+ ## 2. Request conventions and CLI argument mapping
95
+
96
+ Compute `/v1/...` endpoints require `Authorization: Bearer <token>`, except in
97
+ explicitly configured isolated environments with authentication disabled.
98
+ `/healthz` and `/readyz` have no Bearer dependency.
99
+
100
+ JSON requests use `Content-Type: application/json`. File uploads use
101
+ `Content-Type: application/octet-stream` with raw file bytes in the body.
102
+ Uploads are not multipart requests.
103
+
104
+ The optional `X-Request-ID` header accepts 1–128 characters from letters, digits,
105
+ and `._:-`. Responses also return this header. Business request models reject
106
+ unknown fields.
107
+
108
+ | CLI argument | Upstream meaning |
109
+ | --- | --- |
110
+ | `--data` | JSON request body |
111
+ | `--params` | URL query parameters, including upload metadata and event pagination |
112
+ | `--path-params` | Replace `{artifact_id}` and `{job_id}` in paths |
113
+ | `--headers` | Additional headers, such as `Idempotency-Key` and `X-Content-SHA256` |
114
+ | `--file` | Upload a local file through the tool proxy |
115
+ | `--content-type` | Upload body Content-Type; use `application/octet-stream` |
116
+
117
+ `--params` cannot replace `--path-params`. Keep local paths, base64 content, and
118
+ idempotency keys out of business JSON. Use `science invoke --file` for XRD uploads.
119
+ The `media_type` query parameter describes the stored file format separately
120
+ from the upload body Content-Type.
121
+
122
+ The registry proxy exposes `POST /api/v1/tools/invoke` with required
123
+ `tool_name` and `endpoint_name` fields. Optional fields are `data`, `params`,
124
+ `path_params`, `headers`, `file_base64`, and `content_type`. A supplied
125
+ file_base64 is decoded and forwarded as raw bytes, taking precedence over data;
126
+ content_type defaults to application/octet-stream. Delta CLI maps its invocation
127
+ arguments to these proxy fields. Tool ID 30 is used for catalogue lookup;
128
+ invocation selects `tool_name="xrd"` and a registered endpoint name.
129
+
130
+ ## 3. Call sequence
131
+
132
+ 1. Inspect the CLI catalogue and check readiness and required capabilities.
133
+ 2. Upload observed patterns, model inputs, CIFs, or instrument files. Save the
134
+ returned `artifact_id` and `sha256` together.
135
+ 3. Use XMatcher or XDecomposer for observed data. XQueryer requires a prepared
136
+ `model_input_pattern`.
137
+ 4. Export candidate CIFs by identity or upload CIF files. Run theoretical
138
+ simulations and PDF Reporter peak assignments as needed.
139
+ 5. Generate a corrected pattern and manifest for basic refinement. GSAS report
140
+ mode uses an observed pattern uploaded with its original bytes preserved.
141
+ 6. Submit a job with an idempotency key, query its status and events, and verify
142
+ downloaded artifact hashes.
143
+ 7. Report job status, backend execution status, fit quality, physical validity,
144
+ and scientific acceptance separately.
145
+
146
+ ## 4. Readiness and capabilities
49
147
 
50
- ## 调用顺序
148
+ ```text
149
+ delta-cli science invoke --tool xrd --endpoint healthz
150
+ delta-cli science invoke --tool xrd --endpoint readyz
151
+ delta-cli science invoke --tool xrd --endpoint capabilities
152
+ ```
51
153
 
52
- 1. 用户明确要求诊断或执行时,先读取 `healthz`;需要选择后端时再读取
53
- `capabilities`。
54
- 2. 通过 `xmatcher-artifacts` 上传真实文件,保存返回的 `artifact_id` 和 `sha256`。
55
- 3. 观测数据使用 `xmatcher-match`、`xmatcher-multiphase-match` 或
56
- `xdecomposer-predictions`;XQueryer 使用 `model_input_pattern`。
57
- 4. CIF 模拟使用 `xmatcher-cif-xrd`;精修先调用 `xmatcher-refinement-patterns`,再选择
58
- 与 `data.backends` 一致的 refinement endpoint。
59
- 5. 精修提交后用 `refinement-job`、`refinement-job-events` 和
60
- `refinement-job-artifacts` 读取状态和产物。
154
+ `GET /healthz` returns `200 {"ok":true}` for process liveness.
155
+ `GET /readyz` checks authentication configuration and required components;
156
+ an unready service returns `503 {"ok":false}`.
61
157
 
62
- 不要把服务返回的 queued、scheduler completed 或 backend success 直接描述成科学结论。
63
- 精修至少分开报告传输/作业终态、后端执行状态和科学接受状态。
158
+ `GET /v1/capabilities` returns `components.<name>.available`, component `details`,
159
+ `limits`, and build information. Check the components required for the workflow,
160
+ checksums, asset release approval, and mode availability. Report GPU use only when
161
+ the returned device or backend explicitly supports that conclusion.
64
162
 
65
- ## 就绪检查
163
+ For GSAS report mode, check both:
66
164
 
67
165
  ```text
68
- delta-cli science invoke --tool xrd --endpoint healthz
69
- delta-cli science invoke --tool xrd --endpoint capabilities
166
+ components.gsasii.available
167
+ components.gsasii.details.workflow_modes["gsas-report-initial-v1"].available
70
168
  ```
71
169
 
72
- 只有需要诊断或用户明确要求时才额外调用 readiness/status。能力结果中的每个所需组件
73
- 都必须满足 `available`;生产任务还应检查 `asset_release_approved`、checksum 字段和
74
- warnings。`auto` 不代表实际使用 GPU,只有结果明确返回 GPU backend 才能这样报告。
170
+ Mode fields include `max_phases`, `defaults`, `policy_version`, `official_score`,
171
+ and `accepts_recipe`. The common request model accepts 1–3 phases, while a backend
172
+ mode may impose a lower limit. GSAS report mode supports up to two phases as
173
+ described in its detailed contract; consult the deployed capability for its limit.
174
+
175
+ ## 5. Artifact upload, identity, and download
75
176
 
76
- ## Artifact 上传与身份
177
+ ### Upload
77
178
 
78
- 上传观测曲线:
179
+ `POST /v1/artifacts` returns HTTP 201, an `ArtifactRef`, and a metadata query
180
+ URL in the `Location` header.
181
+
182
+ | Parameter | Location | Requirement |
183
+ | --- | --- | --- |
184
+ | `filename` | Query | Required; 1–255 characters; no `/` or `\` |
185
+ | `kind` | Query | Required; accepted kinds are listed below |
186
+ | `media_type` | Query | Required; 1–255 characters; no line breaks |
187
+ | `preserve_source` | Query | Default false; preserve original observed text pattern bytes |
188
+ | `X-Content-SHA256` | Header | Optional; 64 lowercase hexadecimal characters, hashing the upload bytes |
189
+
190
+ | Accepted upload kind | File and processing rules |
191
+ | --- | --- |
192
+ | `observed_pattern`, `model_input_pattern` | `.csv/.xy/.xye/.dat/.txt/.xrdml/.raw`; normalization to headerless two-column CSV is attempted by default |
193
+ | `background_prepared_pattern`, `background_curve` | Same pattern extensions; stored verbatim for PyXplore prepared mode |
194
+ | `cif` | `.cif/.mcif`; stored verbatim |
195
+ | `instrument_parameters` | `.instprm`; stored verbatim |
196
+ | `pcr`, `irf_profile` | Stored verbatim; upload has no extension restriction |
197
+
198
+ Pattern uploads are limited to the smaller of the configured upload limit and
199
+ 20,000,000 bytes. Instrument uploads are limited to the smaller of that limit
200
+ and 2,000,000 bytes. Other files use `max_upload_bytes`. Empty bodies are rejected.
201
+
202
+ Text patterns that fail conversion may be stored as received and rejected at
203
+ compute time. Vendor-format parsing failures are rejected during upload.
79
204
 
80
205
  ```text
81
206
  delta-cli science invoke --tool xrd --endpoint xmatcher-artifacts `
@@ -84,103 +209,496 @@ delta-cli science invoke --tool xrd --endpoint xmatcher-artifacts `
84
209
  --content-type application/octet-stream
85
210
  ```
86
211
 
87
- 允许的 `kind` 为:`observed_pattern`、`model_input_pattern`、`cif`、
88
- `instrument_parameters`。成功响应中的 `artifact_id` 和 `sha256` 必须成对保存并原样
89
- 传给下游。模式文件会在服务端标准化,返回的 digest 是标准化 artifact 的 digest,
90
- 不是一定等于本地上传字节的 digest。
212
+ For GSAS report mode, add `"preserve_source":true` to `--params`. This requires
213
+ `kind=observed_pattern` and a `.csv/.xy/.xye/.dat/.txt` filename. It preserves
214
+ original bytes, line endings, and sigma values, and returns
215
+ `metadata.source_preserved=true`.
216
+
217
+ The upload response includes `artifact_id`, `kind`, `filename`, `media_type`,
218
+ `size_bytes`, `sha256`, `created_at`, `content_url`, `metadata`, and `producer`.
219
+ For normalized patterns, the returned digest identifies the converted artifact
220
+ and may differ from the local upload digest.
91
221
 
92
- 查询 artifact 时使用路径参数:
222
+ ### Downstream references
223
+
224
+ An input artifact reference contains exactly two fields:
225
+
226
+ ```json
227
+ {"artifact_id":"art_<returned-id>","sha256":"<sha256>"}
228
+ ```
229
+
230
+ Artifact IDs contain `art_` followed by 32 lowercase hexadecimal characters.
231
+ SHA-256 values contain 64 lowercase hexadecimal characters. Pass only these
232
+ fields to `ArtifactInput`; fields such as `filename` and `content_url` are rejected.
93
233
 
94
234
  ```text
95
235
  delta-cli science invoke --tool xrd --endpoint xmatcher-artifact `
96
236
  --path-params '{"artifact_id":"art_<returned-id>"}'
237
+
238
+ delta-cli science invoke --tool xrd --endpoint xmatcher-artifact-content `
239
+ --path-params '{"artifact_id":"art_<returned-id>"}'
97
240
  ```
98
241
 
99
- 二进制内容响应可能返回 `data._binary=true`、`content_base64`、`media_type` 和
100
- `content_length`。只有用户要求保存或工作流需要时才解码,并按服务返回的 SHA-256
101
- 校验;不要凭文件名猜测格式。
242
+ The HTTP content response contains file bytes with `ETag` and
243
+ `X-Artifact-SHA256` headers. A CLI proxy may wrap binary data with `data._binary`,
244
+ `content_base64`, `media_type`, and `content_length`. Verify saved content against
245
+ the returned SHA-256, and determine its format from the media type and content.
102
246
 
103
- ## 相识别与匹配
247
+ ## 6. Phase identification and matching
104
248
 
105
- XQueryer 的 `model_input_pattern` 必须正好包含 3500 个样本,覆盖 10 到 90 度 2theta,
106
- 强度不超过服务能力限制:
249
+ ### XQueryer: `POST /v1/xqueryer/predictions`
250
+
251
+ `pattern` must reference a `model_input_pattern` containing exactly 3,500 points
252
+ on a uniform 10–90° 2theta grid. Maximum grid error is `1e-6`. Intensities must be
253
+ nonnegative within `1e-8` tolerance and normalized to a maximum of 100 within
254
+ `1e-6` tolerance. Upload format conversion does not guarantee these constraints.
107
255
 
108
256
  ```text
109
257
  delta-cli science invoke --tool xrd --endpoint xqueryer-predictions `
110
- --data '{"schema_version":1,"pattern":{"artifact_id":"art_<model>","sha256":"<sha>"},"top_k":10,"radiation_profile":"CuKa"}'
258
+ --data '{"schema_version":1,"pattern":{"artifact_id":"art_<model>","sha256":"<sha256>"},"top_k":10,"elements":["Mn","O"],"radiation_profile":"CuKa"}'
111
259
  ```
112
260
 
113
- XMatcher 观测曲线:
261
+ `top_k` defaults to 50 and accepts 1–5000. `elements` defaults to an empty array,
262
+ accepts up to 16 entries, and supports H through U. `radiation_profile` is `CuKa`.
263
+ Optional `expected_versions` can pin checkpoint, MP500 database, and XMatcher
264
+ database digests.
265
+
266
+ The response includes `backend`, `status`, `duration_ms`, `candidates`,
267
+ `provenance`, and `request_id`. Candidates include rank, class_id, entry_id,
268
+ mp_id, formula, score, and available structure information. The score is a
269
+ softmax probability.
270
+
271
+ ### Peak detection and single-phase XMatcher
272
+
273
+ `POST /v1/xmatcher/detect-peaks` accepts `schema_version`, `pattern`, `params`,
274
+ and optional `expected_xmatcher_database_sha256`. XMatcher accepts
275
+ `observed_pattern` or `model_input_pattern` artifacts.
114
276
 
115
277
  ```text
278
+ delta-cli science invoke --tool xrd --endpoint xmatcher-detect-peaks `
279
+ --data '{"schema_version":1,"pattern":{"artifact_id":"art_<observed>","sha256":"<sha256>"},"params":{"n_peaks":8}}'
280
+
116
281
  delta-cli science invoke --tool xrd --endpoint xmatcher-match `
117
- --data '{"schema_version":1,"pattern":{"artifact_id":"art_<observed>","sha256":"<sha>"},"top_n":10,"element_filter_mode":"contains"}'
282
+ --data '{"schema_version":1,"pattern":{"artifact_id":"art_<observed>","sha256":"<sha256>"},"top_n":10,"elements":["Mn","O"],"element_filter_mode":"contains","formula":"Mn2O3"}'
118
283
  ```
119
284
 
120
- 多相匹配:
285
+ Single-phase `top_n` defaults to 10 and accepts 1–5000. Element filtering uses
286
+ `contains` by default, allowing additional elements; `exact` requires a matching
287
+ element set. Optional `formula` must be nonempty and at most 128 characters.
288
+
289
+ XMatcher matching responses include `status=ok`, `results`, `detected_peaks`,
290
+ `processed_spectrum`, `params`, `ranking`, and `calibration`. The runtime adds
291
+ duration, request_id, and provenance. Candidates retain native score or
292
+ peak_match_score values and include calibration_adjusted_score. Interpret ranks
293
+ using `ranking` and `effective_settings`. Learned mode explicitly reports
294
+ `score_is_probability=false`; do not average these scores with XQueryer probabilities.
295
+
296
+ ### Multiphase XMatcher: `POST /v1/xmatcher/multiphase-match`
121
297
 
122
298
  ```text
123
299
  delta-cli science invoke --tool xrd --endpoint xmatcher-multiphase-match `
124
- --data '{"schema_version":1,"pattern":{"artifact_id":"art_<observed>","sha256":"<sha>"},"max_phases":3,"candidate_pool":8}'
300
+ --data '{"schema_version":1,"pattern":{"artifact_id":"art_<observed>","sha256":"<sha256>"},"top_n":10,"max_phases":3,"candidate_pool":20,"prefer_multiphase":false}'
301
+ ```
302
+
303
+ | Parameter | Default / range |
304
+ | --- | --- |
305
+ | `top_n` | 10; 1–50 |
306
+ | `max_phases` | 3; 1–3 |
307
+ | `candidate_pool` | 20; 2–30 |
308
+ | `elements`, `element_filter_mode` | Empty array, contains; up to 16 elements |
309
+ | `known_phase_elements`, `known_phase_formulas`, `known_phase_mpids` | Optional string or array of strings |
310
+ | `prefer_multiphase` | false |
311
+ | `params` | XMatcher parameter object |
312
+ | `expected_xmatcher_database_sha256` | Optional database digest pin |
313
+
314
+ ### XMatcher `params`
315
+
316
+ These are request model defaults. The runtime forwards explicitly set values
317
+ using `exclude_unset`; use returned evidence and the deployed adapter to determine
318
+ effective settings.
319
+
320
+ | Parameter | Model default | Constraint |
321
+ | --- | --- | --- |
322
+ | `min_peak_height` / `min_peak_prominence` | 3.0 / 2.0 | >0 / ≥0 |
323
+ | `min_peak_distance` / `smooth_window` | 0.1 / 7 | >0 / integer 1–255 |
324
+ | `baseline_window_fraction` | 0.05 | (0,1] |
325
+ | `n_peaks` / `min_matched_peaks` | 8 / 4 | 1–100 / 1–50 |
326
+ | `position_tolerance` | 0.2 | (0,2] |
327
+ | `intensity_weight` / `position_weight` | 0.15 / 0.85 | Both ≥0; sum >0 |
328
+ | `scoring_method` | hybrid | hybrid / weighted / fom / combined |
329
+ | `max_shift` / `shift_step` | 0.5 / 0.02 | (0,5] / (0,1] |
330
+ | `shift_warning_fraction` / `shift_penalty_max_fraction` | 0.60 / 0.20 | (0,1] / [0,1] |
331
+ | `fixed_zero_shift` / `specimen_displacement` | 0 / 0 | Finite numbers |
332
+ | `multiphase_n_peaks` | 20 | null or integer 1–80 |
333
+ | `learned_ranking` / `learned_candidate_pool` | true / 24 | Boolean / 1–30 |
334
+ | `learned_missing_peak_weight` / `learned_phase_penalty` | 0.15 / 3.0 | ≥0 |
335
+ | `learned_minimum_contribution` / `learned_evidence_weight` | 3.0 / 4.0 | [0,100) / ≥0 |
336
+ | `multiphase_diversify_candidates` | true | Boolean |
337
+ | `multiphase_missing_peak_weight` / `multiphase_phase_penalty` | 0.5 / 3.0 | ≥0 |
338
+ | `multiphase_minimum_phase_contribution_percent` | 8.0 | [0,100) |
339
+
340
+ ### XDecomposer: `POST /v1/xdecomposer/predictions`
341
+
342
+ ```text
343
+ delta-cli science invoke --tool xrd --endpoint xdecomposer-predictions `
344
+ --data '{"schema_version":1,"pattern":{"artifact_id":"art_<observed>","sha256":"<sha256>"},"top_k":5,"radiation_profile":"CuKa"}'
125
345
  ```
126
346
 
127
- `xqueryer-predictions` 的 `score` 是 softmax probability;XMatcher 的 `score` 是
128
- `raw_score / 100`。两者不可直接平均或当作同一校准概率。
347
+ `pattern` must reference an `observed_pattern`. `top_k` defaults to 5 and accepts
348
+ 1–20. The response includes `phases`, `provenance`, duration, and request ID.
349
+ Each phase includes `phase_index`, `active`, `activity_probability`, `mp_id`,
350
+ `match_score`, `row_id`, and `alternatives`. Phase indices may start at 0 here;
351
+ map them to unique indices in 1–3 when constructing refinement requests.
129
352
 
130
- ## CIF 模拟与峰表
353
+ ## 7. CIFs, theoretical patterns, and peak tables
131
354
 
132
- `cifs` 中的每个 artifact 都必须同时提供 `artifact_id` 和 `sha256`:
355
+ ### XMatcher simulation and XLSX export
356
+
357
+ `POST /v1/xmatcher/cif-xrd` and `/v1/xmatcher/pdf-peaks-xlsx` share a request model.
133
358
 
134
359
  ```text
135
360
  delta-cli science invoke --tool xrd --endpoint xmatcher-cif-xrd `
136
- --data '{"schema_version":1,"cifs":[{"artifact":{"artifact_id":"art_<cif>","sha256":"<sha>"},"name":"phase"}],"two_theta_range":[5.0,90.0],"wavelength":"CuKa"}'
361
+ --data '{"schema_version":1,"cifs":[{"artifact":{"artifact_id":"art_<cif>","sha256":"<sha256>"},"name":"phase","weight":1.0}],"two_theta_range":[5.0,90.0],"wavelength":"CuKa","fwhm":0.12,"step":0.02,"normalize":true}'
137
362
  ```
138
363
 
139
- `xmatcher-pdf-peaks-xlsx` 返回二进制 XLSX;只有用户要求导出时才读取和保存它。
364
+ `cifs` contains 1–5 entries, each with an `artifact`, optional name, and
365
+ nonnegative weight defaulting to 1. `two_theta_range` must be finite and
366
+ increasing. `min_intensity` defaults to 0 and must be nonnegative; fwhm and step
367
+ must be positive. `wavelength` is a string, separate from the numeric `lambda`
368
+ field in the simulation API below. `expected_xmatcher_database_sha256` is optional.
369
+
370
+ The peak-table endpoint returns XLSX bytes with media type
371
+ `application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`.
140
372
 
141
- ## 精修作业
373
+ ### MP500, RRUFF, and OPXRD CIF export
142
374
 
143
- 先生成校正曲线和 provenance manifest:
375
+ `POST /v1/mp500/cif-exports` requires both the candidate entry_id and its identity:
376
+
377
+ ```text
378
+ delta-cli science invoke --tool xrd --endpoint mp500-cif-exports `
379
+ --data '{"schema_version":1,"entry_id":1235,"expected_mp_id":"mp-<candidate-id>"}'
380
+ ```
381
+
382
+ `entry_id` is a positive integer. `expected_mp_id` comes from the selected
383
+ candidate and accepts up to 128 characters. Entries above 100315 use the local
384
+ RRUFF/OPXRD namespace, where expected_mp_id identifies a cryst_id such as
385
+ `RRUFF:...` or `OPXRD:...`.
386
+
387
+ Optional `expected_database_sha256` must identify the database being queried.
388
+ The response includes `entry_id`, `mp_id`, `structure`, and `cif_artifact`.
389
+ Use the returned CIF artifact identity downstream. Identity mismatches produce
390
+ MP500 or RRUFF mismatch errors; do not substitute guessed identifiers.
391
+
392
+ ### CIF block parsing and reflection simulation
393
+
394
+ CLI endpoint: `simulation-cif-parse`. Request for `POST /v1/simulation/cif-parse`:
395
+
396
+ ```json
397
+ {"schema_version":1,"cif":{"artifact_id":"art_<cif>","sha256":"<sha256>"}}
398
+ ```
399
+
400
+ ```text
401
+ delta-cli science invoke --tool xrd --endpoint simulation-cif-parse `
402
+ --data '{"schema_version":1,"cif":{"artifact_id":"art_<cif>","sha256":"<sha256>"}}'
403
+ ```
404
+
405
+ The response contains `blocks[]`. Successful blocks include block_index,
406
+ block_name, formula, cell, volume, site_count, spacegroup, and warnings. Failed
407
+ blocks include block_index and error. Inspect individual blocks even when HTTP
408
+ status is 200.
409
+
410
+ CLI endpoint: `simulation-cif-peaks`. Request for `POST /v1/simulation/cif-peaks`:
411
+
412
+ ```json
413
+ {"schema_version":1,"cif":{"artifact_id":"art_<cif>","sha256":"<sha256>"},"block":0,"lambda":1.5406,"min_angle":5.0,"max_angle":90.0}
414
+ ```
415
+
416
+ ```text
417
+ delta-cli science invoke --tool xrd --endpoint simulation-cif-peaks `
418
+ --data '{"schema_version":1,"cif":{"artifact_id":"art_<cif>","sha256":"<sha256>"},"block":0,"lambda":1.5406,"min_angle":5.0,"max_angle":90.0}'
419
+ ```
420
+
421
+ `block` selects a block index or name. It may be omitted only when exactly one
422
+ structure block was parsed successfully. `lambda` is the required JSON field
423
+ name, accepting (0,5] Å. min_angle accepts [0.1,174], and max_angle accepts
424
+ [0.2,175]; calculation also validates the angle range.
425
+ The response identifies the selected block and contains `peaks[]`.
426
+ Neither simulation endpoint depends on XMatcher search assets.
427
+
428
+ ## 8. PDF Reporter peak assignments
429
+
430
+ CLI endpoint: `pdfreporter-analyses`. Request for `POST /v1/pdfreporter/analyses`:
431
+
432
+ ```json
433
+ {
434
+ "schema_version":1,
435
+ "observed_pattern":{"artifact_id":"art_<observed>","sha256":"<sha256>"},
436
+ "phases":[{"cif":{"artifact_id":"art_<cif>","sha256":"<sha256>"},"name":"phase","color":"#226ba0","visible":true}],
437
+ "wavelength_angstrom":1.5406,
438
+ "tolerance":0.20,
439
+ "intensity_threshold_percent":10,
440
+ "min_peak_distance":0.08,
441
+ "min_prominence_percent":0,
442
+ "render":true
443
+ }
444
+ ```
445
+
446
+ ```text
447
+ delta-cli science invoke --tool xrd --endpoint pdfreporter-analyses `
448
+ --data '{"schema_version":1,"observed_pattern":{"artifact_id":"art_<observed>","sha256":"<sha256>"},"phases":[{"cif":{"artifact_id":"art_<cif>","sha256":"<sha256>"},"name":"phase","color":"#226ba0","visible":true}],"wavelength_angstrom":1.5406,"tolerance":0.20,"intensity_threshold_percent":10,"min_peak_distance":0.08,"min_prominence_percent":0,"render":true}'
449
+ ```
450
+
451
+ The request accepts 1–8 phases. Phase name and color are optional; color is a
452
+ six-digit hexadecimal color, and visible defaults to true. The observed artifact
453
+ may be observed_pattern or model_input_pattern. Each pattern or CIF is limited
454
+ to 4,000,000 bytes, and observed patterns to 500,000 points.
455
+
456
+ Wavelength accepts (0,5] Å; tolerance accepts (0,2]°; both percentage parameters
457
+ accept [0,100]; min_peak_distance must be nonnegative.
458
+
459
+ The response includes per-phase theory tables in `phases`, flattened theory in
460
+ `th`, observed peaks in `pk`, `peaks_csv`, `theory_csv`, `chart.svg`, and optional
461
+ `chart.png`. Charts are downloadable artifact references. PNG is null when
462
+ rasterization dependencies are unavailable.
463
+ Peak statuses are `unmatched`, `unique`, `ambiguous`, and `manual`.
464
+
465
+ CLI endpoint: `pdfreporter-assignments`. For
466
+ `POST /v1/pdfreporter/analyses/assignments`, resubmit the complete analysis input
467
+ and add this field:
468
+
469
+ ```json
470
+ {"selections":{"38.45|0":"0:0","30.05|0":"none"}}
471
+ ```
472
+
473
+ ```text
474
+ delta-cli science invoke --tool xrd --endpoint pdfreporter-assignments `
475
+ --data '{"schema_version":1,"observed_pattern":{"artifact_id":"art_<observed>","sha256":"<sha256>"},"phases":[{"cif":{"artifact_id":"art_<cif>","sha256":"<sha256>"},"name":"phase","color":"#226ba0","visible":true}],"wavelength_angstrom":1.5406,"tolerance":0.20,"intensity_threshold_percent":10,"min_peak_distance":0.08,"min_prominence_percent":0,"render":true,"selections":{"38.45|0":"0:0","30.05|0":"none"}}'
476
+ ```
477
+
478
+ This is a field fragment, not a complete request. Keys have the form
479
+ `<observed-2theta>|<phase-id>`, with zero-based phase IDs. Values are a returned
480
+ matches[].key, `none` to exclude a phase, or `auto` to restore automatic assignment.
481
+ The endpoint recomputes statelessly; it does not update an analysis by analysis_id.
482
+ Theory uses a simplified Z scattering approximation. Results support preliminary
483
+ assignments and do not establish phase confirmation or weight fractions.
484
+
485
+ ## 9. Asynchronous refinement
486
+
487
+ ### Basic input preparation
144
488
 
145
489
  ```text
146
490
  delta-cli science invoke --tool xrd --endpoint xmatcher-refinement-patterns `
147
- --data '{"schema_version":1,"source_pattern":{"artifact_id":"art_<observed>","sha256":"<sha>"}}'
491
+ --data '{"schema_version":1,"source_pattern":{"artifact_id":"art_<observed>","sha256":"<sha256>"}}'
148
492
  ```
149
493
 
150
- 然后使用与 `data.backends` 匹配的 endpoint。示例结构如下,所有 artifact 身份必须来自
151
- 当前调用链:
494
+ The response includes `refinement_pattern_id`, `cache_hit`, `artifact`,
495
+ `manifest_artifact`, and `manifest`. Use artifact for corrected_pattern and
496
+ manifest_artifact for provenance_manifest.
497
+ This endpoint accepts schema_version, source_pattern, and optional expected_versions.
498
+ `normalize=false`, `remove_baseline=true`, and `smooth=false` are fixed internal
499
+ processing settings, not additional request fields.
500
+
501
+ ### Basic job submission
502
+
503
+ `POST /v1/refinement-jobs` requires `Idempotency-Key` with 8–200 characters:
152
504
 
153
505
  ```text
154
506
  delta-cli science invoke --tool xrd --endpoint refinement-gsasii `
155
- --data '{"schema_version":1,"radiation_profile":"CuKa","refinement_pattern":{"observed_pattern":{"artifact_id":"art_<obs>","sha256":"<sha>"},"corrected_pattern":{"artifact_id":"art_<corrected>","sha256":"<sha>"},"provenance_manifest":{"artifact_id":"art_<manifest>","sha256":"<sha>"}},"phases":[{"phase_index":0,"name":"phase","cif":{"artifact_id":"art_<cif>","sha256":"<sha>"}}],"wavelengths_angstrom":[1.540593,1.544414],"backends":["gsasii"]}' `
507
+ --data '{"schema_version":1,"radiation_profile":"CuKa","refinement_pattern":{"observed_pattern":{"artifact_id":"art_<observed>","sha256":"<observed-sha>"},"corrected_pattern":{"artifact_id":"art_<corrected>","sha256":"<corrected-sha>"},"provenance_manifest":{"artifact_id":"art_<manifest>","sha256":"<manifest-sha>"}},"phases":[{"phase_index":1,"name":"phase","cif":{"artifact_id":"art_<cif>","sha256":"<cif-sha>"}}],"wavelengths_angstrom":[1.540593,1.544414],"backends":["gsasii"],"options":{"timeout_seconds":900,"gsasii":{"workflow_mode":"basic-v1"}}}' `
156
508
  --headers '{"Idempotency-Key":"<stable-unique-key>"}'
157
509
  ```
158
510
 
159
- `refinement-fullprof`、`refinement-gsasii`、`refinement-wpem` 选择计费/后端入口;不要
160
- 因为它们映射到同一路径就互换 endpoint 名或 `backends`。提交、取消、重试和审核是
161
- 远端变更,必须得到用户明确授权;超时或连接中断时不要盲目重试,先查询是否已经创建
162
- 作业。
511
+ | Common field | Rule |
512
+ | --- | --- |
513
+ | `schema_version` | Required; 1 |
514
+ | `radiation_profile` | Default and enum CuKa; actual wavelengths are specified separately |
515
+ | `refinement_pattern` | Required; basic mode uses observed, corrected, and a valid manifest |
516
+ | `phases` | Required; 1–3 phases; unique phase_index values in 1–3; name and cif required; mp_id and entry_id optional |
517
+ | `wavelengths_angstrom` | Required; 1–2 finite positive numbers in Å; single line or doublet, preserving order |
518
+ | `backends` | 1–3 unique values; defaults to all three backends; explicit selection is recommended |
519
+ | `options.timeout_seconds` | Default 900; integer 1–3600 |
520
+ | `expected_versions` | Optional asset digest pins |
521
+
522
+ Basic mode verifies manifest source/output hashes, point counts, a shared 2theta
523
+ grid, and the fixed preprocessing policy. Basic doublet intensity ratio is 0.5.
524
+ GSAS instrument files must match requested wavelengths.
525
+
526
+ ### Backend options
527
+
528
+ | Backend | Field | Default / constraint |
529
+ | --- | --- | --- |
530
+ | PyXplore | `iterations` | 10; integer 1–200 |
531
+ | PyXplore | `initialization_epoch` | 2; strict integer ≥0; rejects Boolean, float, string, and null |
532
+ | PyXplore | `peak_generation_range` | null or two finite increasing angles; explicit endpoints must be at least 5° inside the observed range |
533
+ | PyXplore | `structure_solve` | false; true runs per-phase presolving against the full observed pattern |
534
+ | PyXplore | `low_bound` / `up_bound` | Optional; effective defaults 20 / 70; separate from peak generation range |
535
+ | PyXplore | `background` | Overrides LFctg, lowAngleRange, poly_n, bac_split, bac_num, window_length, and polyorder |
536
+ | FullProf | `cycles` / `continuations` | 12 / 2; integer 1–100 / 0–5 |
537
+ | FullProf | `stages` | Empty by default, using backend defaults; supports explicit staged actions |
538
+ | FullProf | `start_from_pcr` | Optional pcr reference; continuation requires explicit stages |
539
+ | FullProf | `raw_pattern` | false; true requires FullProf only and bypasses XMatcher lineage |
540
+ | GSAS basic | `workflow_mode` | basic-v1 |
541
+ | GSAS basic | `cycles` | 8; integer 1–100 |
542
+ | GSAS basic | `refine_zero` / `refine_profile` / `refine_cell` | true / true / true |
543
+ | GSAS basic | `refine_atoms` | false only |
544
+ | GSAS | `instrument_artifact` / `instrument_calibrated` | null / false; calibration requires server-verified records |
545
+
546
+ FullProf stage group values are scale, background, zero, cell, profile_w,
547
+ displacement, coordinates, adp, and occupancy. background_terms accepts 1–5;
548
+ cycles and continuations may be overridden per stage. Structure groups support
549
+ atoms and adp_link values site/species. A script cannot release both zero and
550
+ displacement. In raw_pattern mode, corrected_pattern is still required and must
551
+ reference observed_pattern or model_input_pattern.
552
+
553
+ PyXplore `background.prepared=true` requires a PyXplore-only job. corrected_pattern
554
+ must be background_prepared_pattern, and background.background_curve must be
555
+ background_curve; the manifest may be omitted. The service verifies all three
556
+ grids and identities and skips BackgroundFit. Caller settings are not reported
557
+ as server-measured execution evidence.
558
+
559
+ Basic PyXplore BackgroundFit operates on the observed pattern. The theoretical
560
+ peak generation range does not crop the original fitting or assessment pattern.
561
+ Execution configuration, iteration metrics, and download evidence are available
562
+ in `summary.wpem_evidence`.
563
+
564
+ ### GSAS report mode
565
+
566
+ `options.gsasii.workflow_mode="gsas-report-initial-v1"` requires
567
+ `backends=["gsasii"]`. Upload the original observed text pattern with
568
+ preserve_source=true. This mode prohibits corrected_pattern,
569
+ provenance_manifest, and basic-mode cycles/refine switches.
570
+
571
+ Request for `POST /v1/refinement-jobs`, with an idempotency header:
572
+
573
+ ```json
574
+ {
575
+ "schema_version":1,
576
+ "radiation_profile":"CuKa",
577
+ "refinement_pattern":{"observed_pattern":{"artifact_id":"art_<original>","sha256":"<sha256>"}},
578
+ "phases":[{"phase_index":1,"name":"phase","cif":{"artifact_id":"art_<cif>","sha256":"<sha256>"}}],
579
+ "wavelengths_angstrom":[1.540593,1.544414],
580
+ "backends":["gsasii"],
581
+ "options":{"timeout_seconds":900,"gsasii":{"workflow_mode":"gsas-report-initial-v1"}}
582
+ }
583
+ ```
163
584
 
164
- 查询作业时:
585
+ Optional `recipe` controls single-phase baseline/candidates, multiphase baseline,
586
+ physical bounds, selection rules, and residual peak definitions. Omission uses
587
+ the backend default recipe. Complete recipe types are defined in OpenAPI and
588
+ the GSAS reference. The official scoring implementation is pinned by version
589
+ and module SHA-256; callers cannot replace it.
590
+
591
+ Report mode accepts a finite nonnegative `ka2_ka1_intensity_ratio` for doublets.
592
+ This field is prohibited for a single wavelength. When omitted, a generic
593
+ doublet instrument uses 0.5 and a custom instrument uses its actual ratio.
594
+
595
+ `summary.evidence` records the selected checkpoint, input hashes, actual
596
+ wavelengths, fitting range, native Rwp, full-pattern relative L2, original-sigma
597
+ Rwp, official score, and execution stages. Two-column inputs use unit numerical
598
+ weights and report `sigma_is_measured=false`; three-column original inputs
599
+ contain measured sigma.
600
+
601
+ Published GPX files require native reopen verification. Downloaded byte hashes
602
+ must match evidence. Complete execution and publication require channel success,
603
+ `workflow_complete=true`, and `publication_complete=true`. Inspect
604
+ `structure_consistency` and diagnostics as well. Artifacts marked
605
+ `diagnostic_only=true` are for failure review and are not accepted final structures.
606
+ Uncalibrated instrument results remain provisional; uploading a file does not
607
+ establish calibration.
608
+
609
+ ### Acceptance, queries, and cancellation
610
+
611
+ Successful submission returns HTTP 202 with schema_version, job_id,
612
+ status=queued, submitted_at, and links.self/events/artifacts. Location points
613
+ to the job query route.
614
+
615
+ The same idempotency key and canonical request reuse the original job.
616
+ The same key with a different request returns 409 IDEMPOTENCY_CONFLICT.
617
+ Use a new key for an intentional new calculation. After a timeout or disconnect,
618
+ retain the original key and investigate whether a job exists before resubmitting.
165
619
 
166
620
  ```text
167
621
  delta-cli science invoke --tool xrd --endpoint refinement-job `
168
622
  --path-params '{"job_id":"refjob_<returned-id>"}'
169
623
 
170
624
  delta-cli science invoke --tool xrd --endpoint refinement-job-events `
625
+ --path-params '{"job_id":"refjob_<returned-id>"}' `
626
+ --params '{"after_seq":0,"limit":100}'
627
+
628
+ delta-cli science invoke --tool xrd --endpoint refinement-job-artifacts `
629
+ --path-params '{"job_id":"refjob_<returned-id>"}'
630
+
631
+ delta-cli science invoke --tool xrd --endpoint refinement-job-cancel `
171
632
  --path-params '{"job_id":"refjob_<returned-id>"}'
172
633
  ```
173
634
 
174
- ## 结果与错误
635
+ Job IDs contain `refjob_` followed by 32 lowercase hexadecimal characters.
636
+ Event after_seq defaults to 0 and must be nonnegative; limit defaults to 100
637
+ and accepts 1–500. Pass response next_after_seq for the next page.
638
+ Artifact lists are deduplicated by artifact_id; download through the content API.
639
+
640
+ Cancellation returns the job's current state. Continue querying until a terminal
641
+ state is reached. Cancelling completed or failed jobs returns JOB_STATE_CONFLICT.
642
+
643
+ | Layer | Status / interpretation |
644
+ | --- | --- |
645
+ | Job `status` | queued / running / cancelling / completed / failed / cancelled |
646
+ | Pipeline `result.status` | success / partial / failed / skipped |
647
+ | Channel `result.results.<backend>.status` | success / failed / skipped / cancelled |
648
+ | `quality`, `scientific_status`, `diagnostics` | Inspect fit quality, scientific state, physical validity, and evidence completeness separately |
649
+
650
+ `completed` means the scheduling workflow finished; individual backends may
651
+ have failed. Channel success alone does not establish convergence, physical
652
+ validity, or scientific acceptance. Preserve null or unknown values for unavailable metrics.
175
653
 
176
- - 只有 CLI 退出码为 0 且顶层 JSON `ok` 为 `true` 才算调用成功。
177
- - 原样保留服务返回的 `data`、warnings、错误 detail 和稳定错误码。
178
- - `202`、`queued` 或 `running` 只代表作业接收/执行状态,不代表 solver 收敛或科学接受。
179
- - `TIER_CONCURRENCY_EXCEEDED`、`Endpoint is disabled`、`ARTIFACT_MISSING`、
180
- `MP500_IDENTITY_MISMATCH` 等错误应停止当前调用链并报告原始 detail;不要换 endpoint、
181
- 改名、猜参数或用本地算法替代。
182
- - 付费 endpoint 的价格和可用状态以实时目录为准;执行前确认用户确实要求该业务调用。
654
+ ## 10. Responses and errors
655
+
656
+ Compute endpoints generally return business JSON directly, without a common
657
+ top-level `ok` or `data` success envelope. Health probes, CLI responses, and
658
+ gateway aggregate health endpoints each use their own response conventions.
659
+
660
+ A successful Delta CLI invocation requires exit code 0 and top-level ok=true;
661
+ business results are in data. Decode binary responses according to Content-Type.
662
+
663
+ Compute error response:
664
+
665
+ ```json
666
+ {
667
+ "schema_version":1,
668
+ "error":{"code":"VALIDATION_ERROR","message":"Request validation failed.","retryable":false,"details":[{"field":"body.pattern","reason":"missing"}]},
669
+ "request_id":"req_example"
670
+ }
671
+ ```
183
672
 
184
- 证据边界:仅限当前 Delta CLI `data` 中的业务结果。
185
- 调用链:`delta-cli`。
186
- 禁止补充未返回内容:是。
673
+ Gateway-generated errors include error and request_id but may omit schema_version.
674
+
675
+ | Common error | Meaning / action |
676
+ | --- | --- |
677
+ | AUTHENTICATION_REQUIRED / SERVICE_MISCONFIGURED | Missing authentication or unconfigured service authentication |
678
+ | VALIDATION_ERROR / UNSUPPORTED_MEDIA_TYPE / PAYLOAD_TOO_LARGE | Invalid fields, media type, or upload size |
679
+ | ARTIFACT_NOT_FOUND / ARTIFACT_HASH_MISMATCH / PATTERN_KIND_MISMATCH | Verify artifact ID, SHA-256, and required kind |
680
+ | PATTERN_INVALID / MODEL_INPUT_SHAPE_INVALID / CIF_INVALID / XMATCHER_INVALID | Invalid pattern, model grid, CIF, or matching input |
681
+ | CAPABILITY_UNAVAILABLE / CAPABILITY_VERSION_MISMATCH | Unavailable component or mismatched asset version |
682
+ | MP500_IDENTITY_MISMATCH / RRUFF_IDENTITY_MISMATCH | entry_id does not match the expected candidate identity |
683
+ | REFINEMENT_LINEAGE_INVALID / INSTRUMENT_INVALID | Invalid provenance, source preservation, or instrument data |
684
+ | IDEMPOTENCY_CONFLICT / JOB_NOT_FOUND / JOB_STATE_CONFLICT | Conflicting key, missing job, or operation incompatible with job state |
685
+ | REDIS_UNAVAILABLE / XMATCHER_TIMEOUT | Queue unavailable or matching wait timeout |
686
+ | UPSTREAM_UNAVAILABLE / NOT_FOUND | Chemistry gateway connection failure or route not exposed |
687
+
688
+ HTTP 429 responses may include Retry-After. Proxy errors such as Endpoint is
689
+ disabled and TIER_CONCURRENCY_EXCEEDED are separate from native compute errors.
690
+ Preserve returned code, message, details, warnings, and request_id. Do not switch
691
+ endpoints, guess parameters, or replace failed business results with local algorithms.
692
+
693
+ ## 11. Contracts and references
694
+
695
+ - [Registered XRD tool](http://8.141.101.94:8001/api/v1/tools/30)
696
+ - [Registered XRD endpoint catalogue](http://8.141.101.94:8001/api/v1/tools/30/endpoints)
697
+ - [Registry proxy OpenAPI](http://8.141.101.94:8001/openapi.json)
698
+ - [Compute OpenAPI](xrd-cloud-compute-handoff/contracts/openapi.yaml)
699
+ - [Compute routes](xrd-cloud-compute-handoff/src/xrd_cloud_compute/api.py)
700
+ - [Compute request and response models](xrd-cloud-compute-handoff/src/xrd_cloud_compute/models.py)
701
+ - [Compute runtime and input validation](xrd-cloud-compute-handoff/src/xrd_cloud_compute/runtime.py)
702
+ - [Chemistry gateway allowlist](delta-sandbox-server/api_server/api/chem_xrd.py) and [forwarding implementation](delta-sandbox-server/api_server/server/xrd_service_client.py)
703
+ - [GSAS-II reference](xrd-cloud-compute-handoff/docs/GSASII_REFINEMENT_API_20261012.md)
704
+ - [PyXplore reference](xrd-cloud-compute-handoff/docs/PYXPLORE_API_20261010.md)