renkin 0.17.0 → 0.19.0

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.
package/README.md CHANGED
@@ -265,6 +265,55 @@ Yield/success prediction and automatic literature search are explicitly out
265
265
  of scope for this phase — tracked as future work in
266
266
  [#41](https://github.com/kent-tokyo/renkin/issues/41).
267
267
 
268
+ ### Substrate-specific examples (`schema_version: 2`)
269
+
270
+ Everything above is *template-level*: it applies to every step using that
271
+ template, regardless of the actual molecule. `schema_version: 2` adds
272
+ `examples` — a per-template array where each entry is one curated record of
273
+ *this exact reaction*, keyed by `target_smiles`/`precursor_smiles`:
274
+
275
+ ```json
276
+ {
277
+ "schema_version": 2,
278
+ "templates": {
279
+ "smirks-sha256:...": {
280
+ "references": [{ "id": "ref-1", "kind": "doi", "identifier": "10.xxxx/example" }],
281
+ "examples": [{
282
+ "id": "ex-1",
283
+ "target_smiles": "c1ccc(-c2ccccc2)cc1",
284
+ "precursor_smiles": ["Brc1ccccc1", "c1ccccc1"],
285
+ "conditions": { "catalysts": ["Pd(PPh3)4"], "solvents": ["EtOH"], "source": "literature", "scope": "substrate_specific", "reference_ids": ["ref-1"] },
286
+ "reported_yield": { "percentage": 78.0, "basis": "isolated", "source": "literature", "scope": "substrate_specific", "reference_ids": ["ref-1"] },
287
+ "reference_ids": ["ref-1"]
288
+ }]
289
+ }
290
+ }
291
+ }
292
+ ```
293
+
294
+ `examples` requires `schema_version: 2` (a hard error under `1`); under
295
+ `schema_version: 2`, reported yields must live under `examples[].reported_yield`
296
+ too — a non-empty template-level `reported_yields` is a hard error there (it
297
+ stays allowed under `schema_version: 1`), so a substrate-specific number can't
298
+ leak onto every step using that template. Every condition/yield/warning
299
+ nested inside an example must be scoped `substrate_specific`.
300
+
301
+ A route step's `evidence.examples` are **resolved**, not just copied from the
302
+ sidecar: matched against that step by canonical target SMILES plus the
303
+ canonical, order-independent precursor set (reordering `precursor_smiles` in
304
+ the sidecar changes nothing), with every exact-substrate match kept and
305
+ same-template-different-substrate precedents capped at 3. Each resolved entry
306
+ carries a `match_kind` (`exact_substrate`/`template_only`) in the JSON itself,
307
+ plus a `template_examples_total` count — so JSON/Python consumers, not just
308
+ `--format explain`, can tell "evidence for this exact reaction" apart from
309
+ "literature precedent for a different substrate." `--format explain` shows
310
+ exact-substrate matches first, each labeled either `Exact substrate example:`
311
+ or *"different substrate; not a prediction"*, with `conditions`/
312
+ `reported_yield`/`warnings` each showing their own cited references directly
313
+ underneath (deduplicated when the same reference backs more than one part of
314
+ an example). See [Reaction Evidence guide](docs/guides/reaction-evidence.md#substrate-specific-examples-schema_version-2)
315
+ for full matching/validation semantics.
316
+
268
317
  ---
269
318
 
270
319
  ## Key Features
@@ -276,12 +325,13 @@ of scope for this phase — tracked as future work in
276
325
  | **Up to 50k reaction templates** | Auto-extracted from USPTO-50k/MIT via rdchiral; frequency-weighted priority; `--templates` for custom sets |
277
326
  | **Route scoring** | `confidence`, `step_confidence`, `success_probability` (Retro-prob style), `convergency`, `atom_economy` per step — see caveat below the table |
278
327
  | **Step metadata provenance** | Each step reports `metadata_source`/`metadata_scope` (e.g. `handcrafted_default`/`reaction_family`) so it's machine-readable whether `conditions`/`reaction_family` came from a rule-author default vs. something more grounded; absent for extracted templates, since nothing is fabricated for them. |
279
- | **Stable template IDs + evidence sidecar** | Every template gets a stable `template_id` — `rule:<name>` for hand-crafted rules, `smirks-sha256:<hex>` for extracted templates (independent of file order/position/count). Attach curated DOIs/patents, reported conditions, reported yields, and known side-reaction warnings via a `--template-metadata sidecar.json` file keyed by `template_id`; matching steps get an `evidence` field, everything else stays untouched — see [Template evidence metadata](#template-evidence-metadata) below. Run `renkin template ids <file.smi>` to list stable IDs for authoring a sidecar. Automatic yield/success prediction and literature search remain out of scope ([#41](https://github.com/kent-tokyo/renkin/issues/41)). |
328
+ | **Stable template IDs + evidence sidecar** | Every template gets a stable `template_id` — `rule:<name>` for hand-crafted rules, `smirks-sha256:<hex>` for extracted templates (independent of file order/position/count). Attach curated DOIs/patents, reported conditions, reported yields, and known side-reaction warnings via a `--template-metadata sidecar.json` file keyed by `template_id`; matching steps get an `evidence` field, everything else stays untouched — see [Template evidence metadata](#template-evidence-metadata) below. `schema_version: 2` sidecars can additionally attach `examples` — curated records tied to one exact target/precursor set, matched by canonical SMILES and surfaced first in `--format explain`. Run `renkin template ids <file.smi>` to list stable IDs for authoring a sidecar. Automatic yield/success prediction and literature search remain out of scope ([#41](https://github.com/kent-tokyo/renkin/issues/41)). |
280
329
  | **Route cost scoring** | `route_cost = Σ(BB cost) + steps×0.5`; actual prices via `--bb-prices CSV` or `--stock stock.csv` |
281
330
  | **Pareto multi-objective search** | `--format pareto` returns a Pareto front across `route_cost`, `success_probability`, `steps`, etc.; objectives configurable via `--objectives cost:min,success_probability:max,steps:min` |
282
331
  | **Constraint DSL** | `--constraints constraints.json` — JSON-driven synthesis planning: element filters, step limits, confidence thresholds, preferred reaction families; enables LLM → RENKIN pipeline |
283
332
  | **Output formats** | `--format json` · `tree` · `mermaid` · `explain` (human-readable per-route analysis) · `compare` (side-by-side table) · `compare-json` · `pareto` |
284
333
  | **Failure diagnostics** | Zero-route JSON output includes `diagnostics` block with `likely_causes` and `suggestions` |
334
+ | **Standalone forward prediction** | `renkin-forward predict --reactants <SMILES>...` enumerates and ranks forward reaction product candidates from reversed SMIRKS templates, independent of route search — see the [Forward Prediction guide](docs/guides/forward-prediction.md) |
285
335
  | **Forward validation** | `renkin-forward validate` verifies each step by applying templates forward; accepts `--route-json` or stdin |
286
336
  | **Plausibility report** | `renkin-bench --plausibility` — forward-validates best routes and reports composite plausibility score |
287
337
  | **PaRoutes benchmark** | `renkin-bench --input-format paroutes` for multi-step ground-truth evaluation with `depth_delta` and `route_diversity` |
@@ -314,6 +364,9 @@ of scope for this phase — tracked as future work in
314
364
  # Route cost scoring with commercial prices
315
365
  renkin -t "Cc1ccc(-c2ccccc2)cc1" --bb-prices data/prices.csv --format json
316
366
 
367
+ # Standalone forward prediction — no route search involved
368
+ renkin-forward predict --reactants "Oc1ccccc1C(=O)O" "CCO" --report --max-results 5
369
+
317
370
  # Forward validation — pipe find_routes output directly
318
371
  renkin -t "CC(=O)Oc1ccccc1C(=O)O" --format json | renkin-forward validate
319
372
 
@@ -515,6 +568,8 @@ renkin/ ← Cargo workspace root
515
568
  │ ├── score.rs # SA Score heuristic + step cost
516
569
  │ ├── search.rs # A* / AND-OR tree engine + beam pruning
517
570
  │ ├── scorer.rs # Phase B: tract-onnx NN template scorer
571
+ │ ├── candidate.rs # one-step candidate proposal (offline reranking foundation, not wired into search)
572
+ │ ├── pool_export.rs # candidate-pool JSONL + reproducibility-manifest export
518
573
  │ ├── python.rs # PyO3 bindings (--features python)
519
574
  │ └── wasm.rs # wasm-bindgen bindings (cfg = wasm32)
520
575
  ├── crates/ ← sibling crates
@@ -527,7 +582,9 @@ renkin/ ← Cargo workspace root
527
582
  │ └── bench_chunks/ # USPTO-50k per-chunk results
528
583
  ├── scripts/
529
584
  │ ├── extract_templates.py # rdchiral template extraction pipeline
530
- └── run_benchmark_chunks.sh # resumable chunked benchmark runner
585
+ ├── run_benchmark_chunks.sh # resumable chunked benchmark runner
586
+ │ ├── train_reranker.py # candidate reranker training/evaluation (dev tool, offline only — see docs/guides/reranker-candidate-pools.md)
587
+ │ └── tests/ # unittest suite for train_reranker.py
531
588
  ├── docs/ # MkDocs source → kent-tokyo.github.io/renkin/
532
589
  └── mkdocs.yml
533
590
  ```
@@ -538,7 +595,10 @@ renkin/ ← Cargo workspace root
538
595
 
539
596
  ### Recently shipped
540
597
 
598
+ - [x] `renkin-forward` CLI hardening — versioned `ForwardPredictionReport`, deterministic candidate IDs/merge/provenance, reactant-order-independent matching (up to 3 reactants), strict CLI/route-JSON validation
599
+ - [x] RETROSPECT-inspired offline candidate-reranking foundation — candidate proposal/selection separation, feature schema v1, manifest v2, leakage-safe train/val/test splitting, 7 deterministic baseline arms + trained-ranker arm, paired bootstrap + offline gate tooling ([#59](https://github.com/kent-tokyo/renkin/pull/59); **foundation only — no trained model or accuracy result yet, not wired into route search**)
541
600
  - [x] Stable `template_id` (`rule:<name>` / `smirks-sha256:<hex>`) + `--template-metadata` evidence sidecar + `renkin template ids` ([#41](https://github.com/kent-tokyo/renkin/issues/41) phase 1)
601
+ - [x] Substrate-specific `examples` (`schema_version: 2`) — per-step exact-substrate vs. same-template-different-substrate resolution, surfaced in `--format explain` and as `match_kind` in JSON ([#41](https://github.com/kent-tokyo/renkin/issues/41) phase 2)
542
602
  - [x] `renkin-bench cascade` — multi-stage search (fast defaults → hard cases re-run deeper); only unsolved targets propagate to later stages. **78.0% → 95.9%** on USPTO-50k
543
603
  - [x] `renkin-bench --failure-taxonomy` — classify unsolved targets by cause (beam limit / depth limit / template gap / stock near-miss)
544
604
  - [x] Graph-based ester cleavage — BFS-leakage-free `R-C(=O)-O-R' → RCOOH + R'OH`
@@ -600,18 +660,10 @@ renkin/ ← Cargo workspace root
600
660
 
601
661
  ## Citation
602
662
 
603
- If you use RENKIN in academic work, please cite:
604
-
605
- ```bibtex
606
- @software{renkin2026,
607
- author = {kent-tokyo},
608
- title = {{RENKIN}: Retrosynthesis Engine for Knowledge-Informed Navigation},
609
- year = {2026},
610
- url = {https://github.com/kent-tokyo/renkin/releases/tag/v0.17.0},
611
- version = {0.17.0},
612
- license = {MIT}
613
- }
614
- ```
663
+ If you use RENKIN in academic work, please cite it — see [`CITATION.cff`](CITATION.cff)
664
+ for the canonical, version-tracked citation record. GitHub's "Cite this
665
+ repository" button (top of the repo page) reads it directly and can export
666
+ APA or BibTeX on demand.
615
667
 
616
668
  ---
617
669
 
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "renkin",
3
3
  "type": "module",
4
+ "collaborators": [
5
+ "kent-tokyo <kent-tokyo@users.noreply.github.com>"
6
+ ],
4
7
  "description": "Ultra-fast retrosynthesis engine for computer-aided synthesis planning (CASP) — pure Rust, WASM-ready, Python bindings via PyO3",
5
- "version": "0.17.0",
8
+ "version": "0.19.0",
6
9
  "license": "MIT",
7
10
  "repository": {
8
11
  "type": "git",
package/renkin_bg.wasm CHANGED
Binary file