@delta-infra/cli 1.1.18 → 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 (50) hide show
  1. package/README.md +11 -4
  2. package/checksums.txt +5 -5
  3. package/package.json +3 -2
  4. package/scripts/install-wizard.js +18 -31
  5. package/skills/delta-protein/AGENTS.md +73 -0
  6. package/skills/delta-protein/SKILL.md +389 -0
  7. package/skills/delta-protein/agents/openai.yaml +4 -0
  8. package/skills/delta-protein/references/bfitter.md +64 -0
  9. package/skills/delta-protein/references/catapro_predict.md +63 -0
  10. package/skills/delta-protein/references/catpred_predict.md +65 -0
  11. package/skills/delta-protein/references/caver_tunnel_analyze.md +63 -0
  12. package/skills/delta-protein/references/consensus_mutation.md +61 -0
  13. package/skills/delta-protein/references/consurf_predict.md +67 -0
  14. package/skills/delta-protein/references/crop_sequence.md +69 -0
  15. package/skills/delta-protein/references/dock.md +82 -0
  16. package/skills/delta-protein/references/dock_score.md +70 -0
  17. package/skills/delta-protein/references/easifa_predict_active_site.md +70 -0
  18. package/skills/delta-protein/references/ephod_predict_mutation.md +66 -0
  19. package/skills/delta-protein/references/ephod_predict_protein.md +61 -0
  20. package/skills/delta-protein/references/esmfold2_predict.md +67 -0
  21. package/skills/delta-protein/references/evcouplings_mutation.md +64 -0
  22. package/skills/delta-protein/references/fasta_to_sequence.md +59 -0
  23. package/skills/delta-protein/references/foldseek.md +61 -0
  24. package/skills/delta-protein/references/generate_msa.md +61 -0
  25. package/skills/delta-protein/references/interpro_analyze.md +63 -0
  26. package/skills/delta-protein/references/mpnn_design_sequence.md +71 -0
  27. package/skills/delta-protein/references/multievolve.md +73 -0
  28. package/skills/delta-protein/references/pisa_query.md +70 -0
  29. package/skills/delta-protein/references/plip_analyze.md +65 -0
  30. package/skills/delta-protein/references/pocket_prediction.md +63 -0
  31. package/skills/delta-protein/references/protein_design.md +65 -0
  32. package/skills/delta-protein/references/protein_evolution.md +77 -0
  33. package/skills/delta-protein/references/protein_sol_predict_mutation.md +66 -0
  34. package/skills/delta-protein/references/protein_sol_predict_protein.md +61 -0
  35. package/skills/delta-protein/references/protenix.md +66 -0
  36. package/skills/delta-protein/references/protrek_search.md +90 -0
  37. package/skills/delta-protein/references/pubchem_search.md +68 -0
  38. package/skills/delta-protein/references/pubmed_search.md +79 -0
  39. package/skills/delta-protein/references/reap_design_primer.md +69 -0
  40. package/skills/delta-protein/references/rfd3_design.md +65 -0
  41. package/skills/delta-protein/references/structure_to_sequence.md +61 -0
  42. package/skills/delta-protein/references/summarize_result.md +68 -0
  43. package/skills/delta-protein/references/surface_charge.md +84 -0
  44. package/skills/delta-protein/references/uniprot_batch_query.md +63 -0
  45. package/skills/delta-protein/references/uniprot_query.md +64 -0
  46. package/skills/delta-protein/references/zero_shot_mutant_candidates.md +76 -0
  47. package/skills/delta-protein/scripts/gen_references.py +167 -0
  48. package/skills/delta-protein/scripts/output_metadata.json +275 -0
  49. package/skills/delta-science/references/xrd.md +704 -197
  50. package/skills/manifest.json +2 -1
@@ -1,197 +1,704 @@
1
- # XRD Cloud Compute reference
2
-
3
- `xrd` is a real tool for accessing XRD cloud compute through the Science tool proxy. Route every
4
- call through `delta-cli`; do not bypass the CLI with broker URLs, `curl`, `requests`, `httpx`, a
5
- browser or local XRD libraries. This is a tool reference for `delta-science`, not a second HTTP
6
- client.
7
-
8
- ## Tool and endpoints
9
-
10
- Before execution, use the live catalogue to confirm the canonical names and enabled status in the
11
- current environment:
12
-
13
- ```text
14
- delta-cli science list
15
- delta-cli science endpoints list xrd
16
- ```
17
-
18
- Copy `xrd` endpoint names exactly from the output of the second command. This reference covers
19
- the following stable contracts:
20
-
21
- | endpoint | Method/purpose | Request type |
22
- | --- | --- | --- |
23
- | `healthz`, `readyz`, `capabilities`, `xmatcher-status` | Readiness, capabilities and database status | Read-only JSON |
24
- | `xmatcher-artifacts` | Upload an observed pattern, model input, CIF or instrument parameters | `invoke --file` |
25
- | `xmatcher-artifact`, `xmatcher-artifact-content` | Query/read an artifact | `invoke --path-params` |
26
- | `xqueryer-predictions` | XQueryer single-phase candidate prediction | JSON |
27
- | `xmatcher-detect-peaks`, `xmatcher-match` | Peak detection and single-phase matching | JSON |
28
- | `xmatcher-multiphase-match`, `xdecomposer-predictions` | Multiphase matching and phase decomposition | JSON |
29
- | `xmatcher-cif-xrd`, `xmatcher-pdf-peaks-xlsx` | CIF simulation and PDF peak-table export | JSON/binary |
30
- | `xmatcher-refinement-patterns` | Generate refinement inputs and a provenance manifest | JSON |
31
- | `refinement-fullprof`, `refinement-gsasii`, `refinement-wpem` | Submit a refinement job to the corresponding backend | JSON + header |
32
- | `refinement-job`, `refinement-job-events`, `refinement-job-artifacts` | Query a refinement job | `invoke --path-params` |
33
- | `refinement-job-cancel` | Request refinement-job cancellation | `invoke --path-params` |
34
- | `mp500-cif-exports` | Export an MP500 structure as CIF | JSON |
35
-
36
- The live catalogue is authoritative. If an endpoint is absent from it, stop and report a
37
- configuration issue; do not retry under a different name.
38
-
39
- ## CLI argument mapping
40
-
41
- ```text
42
- --data Upstream JSON body
43
- --params Upstream URL query parameters
44
- --path-params Replace {artifact_id}/{job_id} in the endpoint path
45
- --headers Additional upstream headers, such as Idempotency-Key
46
- --file Send a local file to the tool proxy via file_base64
47
- --content-type The file's original MIME type
48
- ```
49
-
50
- `--params` cannot replace `--path-params`. Do not put local paths, base64, path parameters or
51
- idempotency keys in ordinary business `--data`. `science file` is a separate file interface for
52
- tools such as QE and Materials Design. XRD's `xmatcher-artifacts` is a tool-proxy endpoint; use
53
- `science invoke --file` for it.
54
-
55
- ## Call sequence
56
-
57
- 1. When the user explicitly asks for a diagnosis or execution, read `healthz` first; read
58
- `capabilities` only when you need to select a backend.
59
- 2. Upload real files through `xmatcher-artifacts` and save the returned `artifact_id` and `sha256`.
60
- 3. Use `xmatcher-match`, `xmatcher-multiphase-match` or `xdecomposer-predictions` for observed
61
- data; XQueryer uses `model_input_pattern`.
62
- 4. Use `xmatcher-cif-xrd` for CIF simulation. For refinement, call
63
- `xmatcher-refinement-patterns` first, then choose a refinement endpoint matching
64
- `data.backends`.
65
- 5. After submitting a refinement job, read its status and artifacts with `refinement-job`,
66
- `refinement-job-events` and `refinement-job-artifacts`.
67
-
68
- Do not present a returned `queued` state, scheduler completion or backend success as a scientific
69
- conclusion. For refinement, report the transport/job final state, backend execution state and
70
- scientific acceptance state separately.
71
-
72
- ## Readiness checks
73
-
74
- ```text
75
- delta-cli science invoke --tool xrd --endpoint healthz
76
- delta-cli science invoke --tool xrd --endpoint capabilities
77
- ```
78
-
79
- Call readiness/status additionally only when diagnosis requires it or the user explicitly asks.
80
- Every required component in the capabilities result must have `available` status. For production
81
- jobs, also check `asset_release_approved`, checksum fields and warnings. `auto` does not prove GPU
82
- use; report GPU use only when the result explicitly returns a GPU backend.
83
-
84
- ## Artifact upload and identity
85
-
86
- Upload an observed pattern:
87
-
88
- ```text
89
- delta-cli science invoke --tool xrd --endpoint xmatcher-artifacts `
90
- --file observed.csv `
91
- --params '{"filename":"observed.csv","kind":"observed_pattern","media_type":"text/csv"}' `
92
- --content-type application/octet-stream
93
- ```
94
-
95
- Allowed `kind` values are `observed_pattern`, `model_input_pattern`, `cif` and
96
- `instrument_parameters`. Save the successful response's `artifact_id` and `sha256` together and
97
- pass them to downstream calls unchanged. Pattern files are normalised by the server, so the
98
- returned digest identifies the normalised artifact and may differ from the digest of the local
99
- upload bytes.
100
-
101
- Use path parameters to query an artifact:
102
-
103
- ```text
104
- delta-cli science invoke --tool xrd --endpoint xmatcher-artifact `
105
- --path-params '{"artifact_id":"art_<returned-id>"}'
106
- ```
107
-
108
- Binary-content responses may return `data._binary=true`, `content_base64`, `media_type` and
109
- `content_length`. Decode only when the user asks to save the content or the workflow requires it,
110
- and verify it against the SHA-256 returned by the service. Do not infer the format from the filename.
111
-
112
- ## Phase identification and matching
113
-
114
- XQueryer's `model_input_pattern` must contain exactly 3,500 samples over 10 to 90 degrees 2theta,
115
- with intensities within the service's capability limits:
116
-
117
- ```text
118
- delta-cli science invoke --tool xrd --endpoint xqueryer-predictions `
119
- --data '{"schema_version":1,"pattern":{"artifact_id":"art_<model>","sha256":"<sha>"},"top_k":10,"radiation_profile":"CuKa"}'
120
- ```
121
-
122
- XMatcher observed pattern:
123
-
124
- ```text
125
- delta-cli science invoke --tool xrd --endpoint xmatcher-match `
126
- --data '{"schema_version":1,"pattern":{"artifact_id":"art_<observed>","sha256":"<sha>"},"top_n":10,"element_filter_mode":"contains"}'
127
- ```
128
-
129
- Multiphase matching:
130
-
131
- ```text
132
- delta-cli science invoke --tool xrd --endpoint xmatcher-multiphase-match `
133
- --data '{"schema_version":1,"pattern":{"artifact_id":"art_<observed>","sha256":"<sha>"},"max_phases":3,"candidate_pool":8}'
134
- ```
135
-
136
- The `score` from `xqueryer-predictions` is a softmax probability; the XMatcher `score` is
137
- `raw_score / 100`. Do not average them directly or treat them as the same calibrated probability.
138
-
139
- ## CIF simulation and peak tables
140
-
141
- Each artifact in `cifs` must provide both `artifact_id` and `sha256`:
142
-
143
- ```text
144
- delta-cli science invoke --tool xrd --endpoint xmatcher-cif-xrd `
145
- --data '{"schema_version":1,"cifs":[{"artifact":{"artifact_id":"art_<cif>","sha256":"<sha>"},"name":"phase"}],"two_theta_range":[5.0,90.0],"wavelength":"CuKa"}'
146
- ```
147
-
148
- `xmatcher-pdf-peaks-xlsx` returns a binary XLSX file; read and save it only when the user asks for an export.
149
-
150
- ## Refinement jobs
151
-
152
- First generate the corrected pattern and provenance manifest:
153
-
154
- ```text
155
- delta-cli science invoke --tool xrd --endpoint xmatcher-refinement-patterns `
156
- --data '{"schema_version":1,"source_pattern":{"artifact_id":"art_<observed>","sha256":"<sha>"}}'
157
- ```
158
-
159
- Then use the endpoint matching `data.backends`. The example below shows the structure; every
160
- artifact identity must come from the current call chain:
161
-
162
- ```text
163
- delta-cli science invoke --tool xrd --endpoint refinement-gsasii `
164
- --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"]}' `
165
- --headers '{"Idempotency-Key":"<stable-unique-key>"}'
166
- ```
167
-
168
- `refinement-fullprof`, `refinement-gsasii` and `refinement-wpem` select the billing/backend
169
- entry point. Do not interchange endpoint names or `backends` merely because they map to the same
170
- path. Submission, cancellation, retry and review are remote mutations and require the user's
171
- explicit authorisation. After a timeout or disconnection, do not retry blindly; first check
172
- whether a job has already been created.
173
-
174
- To query a job:
175
-
176
- ```text
177
- delta-cli science invoke --tool xrd --endpoint refinement-job `
178
- --path-params '{"job_id":"refjob_<returned-id>"}'
179
-
180
- delta-cli science invoke --tool xrd --endpoint refinement-job-events `
181
- --path-params '{"job_id":"refjob_<returned-id>"}'
182
- ```
183
-
184
- ## Results and errors
185
-
186
- - A call succeeds only when the CLI exits with code 0 and the top-level JSON `ok` is `true`.
187
- - Preserve the returned `data`, warnings, error detail and stable error codes exactly as returned.
188
- - `202`, `queued` and `running` describe job acceptance/execution state only; they do not mean the solver converged or the result was scientifically accepted.
189
- - `TIER_CONCURRENCY_EXCEEDED`, `Endpoint is disabled`, `ARTIFACT_MISSING`,
190
- `MP500_IDENTITY_MISMATCH` and similar errors should stop the current call chain; report the
191
- original detail and do not switch endpoints, rename them, guess parameters or substitute a
192
- local algorithm.
193
- - Use the live catalogue as the authority for paid endpoint prices and availability; before execution, confirm that the user actually requested the business call.
194
-
195
- Evidence boundary: business results in the current Delta CLI `data` only.
196
- Call chain: `delta-cli`.
197
- Do not add information absent from the response: yes.
1
+ # XRD Cloud Compute API Reference
2
+
3
+ The OpenAPI contract version is `1.2.0`. Business requests and responses use
4
+ `schema_version: 1`.
5
+
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.
10
+
11
+ ## 1. Tool and endpoints
12
+
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.
18
+
19
+ Catalogue APIs, relative to `http://8.141.101.94:8001`:
20
+
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 |
27
+
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:
32
+
33
+ ```text
34
+ delta-cli science list
35
+ delta-cli science endpoints list xrd
36
+ ```
37
+
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
147
+
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
+ ```
153
+
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}`.
157
+
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.
162
+
163
+ For GSAS report mode, check both:
164
+
165
+ ```text
166
+ components.gsasii.available
167
+ components.gsasii.details.workflow_modes["gsas-report-initial-v1"].available
168
+ ```
169
+
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
176
+
177
+ ### Upload
178
+
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.
204
+
205
+ ```text
206
+ delta-cli science invoke --tool xrd --endpoint xmatcher-artifacts `
207
+ --file observed.csv `
208
+ --params '{"filename":"observed.csv","kind":"observed_pattern","media_type":"text/csv"}' `
209
+ --content-type application/octet-stream
210
+ ```
211
+
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.
221
+
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.
233
+
234
+ ```text
235
+ delta-cli science invoke --tool xrd --endpoint xmatcher-artifact `
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>"}'
240
+ ```
241
+
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.
246
+
247
+ ## 6. Phase identification and matching
248
+
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.
255
+
256
+ ```text
257
+ delta-cli science invoke --tool xrd --endpoint xqueryer-predictions `
258
+ --data '{"schema_version":1,"pattern":{"artifact_id":"art_<model>","sha256":"<sha256>"},"top_k":10,"elements":["Mn","O"],"radiation_profile":"CuKa"}'
259
+ ```
260
+
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.
276
+
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
+
281
+ delta-cli science invoke --tool xrd --endpoint xmatcher-match `
282
+ --data '{"schema_version":1,"pattern":{"artifact_id":"art_<observed>","sha256":"<sha256>"},"top_n":10,"elements":["Mn","O"],"element_filter_mode":"contains","formula":"Mn2O3"}'
283
+ ```
284
+
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`
297
+
298
+ ```text
299
+ delta-cli science invoke --tool xrd --endpoint xmatcher-multiphase-match `
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"}'
345
+ ```
346
+
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.
352
+
353
+ ## 7. CIFs, theoretical patterns, and peak tables
354
+
355
+ ### XMatcher simulation and XLSX export
356
+
357
+ `POST /v1/xmatcher/cif-xrd` and `/v1/xmatcher/pdf-peaks-xlsx` share a request model.
358
+
359
+ ```text
360
+ delta-cli science invoke --tool xrd --endpoint xmatcher-cif-xrd `
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}'
362
+ ```
363
+
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`.
372
+
373
+ ### MP500, RRUFF, and OPXRD CIF export
374
+
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
488
+
489
+ ```text
490
+ delta-cli science invoke --tool xrd --endpoint xmatcher-refinement-patterns `
491
+ --data '{"schema_version":1,"source_pattern":{"artifact_id":"art_<observed>","sha256":"<sha256>"}}'
492
+ ```
493
+
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:
504
+
505
+ ```text
506
+ delta-cli science invoke --tool xrd --endpoint refinement-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"}}}' `
508
+ --headers '{"Idempotency-Key":"<stable-unique-key>"}'
509
+ ```
510
+
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
+ ```
584
+
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.
619
+
620
+ ```text
621
+ delta-cli science invoke --tool xrd --endpoint refinement-job `
622
+ --path-params '{"job_id":"refjob_<returned-id>"}'
623
+
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 `
632
+ --path-params '{"job_id":"refjob_<returned-id>"}'
633
+ ```
634
+
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.
653
+
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
+ ```
672
+
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)