renkin 0.25.0 → 0.27.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
@@ -27,6 +27,8 @@ RENKIN is an open-source **retrosynthesis engine** for **computer-aided synthesi
27
27
 
28
28
  Built entirely in Rust with the [`chematic`](https://docs.rs/chematic/) cheminformatics crate — zero C/C++ dependencies, `#![forbid(unsafe_code)]` throughout. One codebase compiles to a native CLI, a Rust library, Python wheels (PyO3), and a WebAssembly module that runs entirely client-side in the browser.
29
29
 
30
+ Use RENKIN as an independent audit layer for retrosynthesis routes generated by RENKIN or AiZynthFinder — see [RENKIN Bridge / `audit-route`](#key-features) below.
31
+
30
32
  ---
31
33
 
32
34
  ## Installation
@@ -344,7 +346,7 @@ for the full acceptance criteria and licensing split.
344
346
  | **Ring-context safety guard** | `--ring-context-policy conservative --ring-context-sidecar <path>` — opt-in match-level filter that rejects an extracted template's ring-opening/closing disconnection when its historical training data never observed that bond as ring-forming/-breaking; default `disabled` (unchanged legacy behavior) — see [Issue #72](https://github.com/kent-tokyo/renkin/issues/72) |
345
347
  | **LightGBM candidate reranker** | `--reranker-model`/`--reranker-freq-table` (CLI) or `reranker_model_path`/`reranker_freq_table_path` (Python) — opt-in, ordering-only re-ranking via a frozen LightGBM model; never changes which candidates are generated, only their order, and reproduces legacy ordering byte-for-byte when off. Paired 100-target route-search gate: `route_to_configured_stock` 16→20 (+4/-0). `python3 scripts/fetch_reranker_model.py` fetches the frozen model (SHA-256-verified, not bundled in any package — see [Roadmap](#roadmap)) |
346
348
  | **Coverage mode** (opt-in) | `--search-mode coverage --coverage-templates <path>` (CLI) or `search_mode="coverage"`, `coverage_templates_path=...` (Python) — if the default template set finds no route, automatically escalates to a larger, separately loaded template set, cooperatively cancellable via `--coverage-timeout-secs`. Standard-mode output is byte-for-byte unchanged when not used. `python3 scripts/fetch_coverage_templates.py` fetches the frozen 2,000-template Stage-2 set (SHA-256-verified, not bundled in any package, same reasoning as the reranker model — see [Roadmap](#roadmap)) |
347
- | **RENKIN Bridge / `audit-route`** | `renkin audit-route route.json [--stock stock.smi] [--output human\|json]` — tool-neutral route audit: structural integrity, stock, and declared-reaction forward-replay validation, each reported independently as `pass`/`fail`/`not_evaluable`, rolled up into a route-level `pass`/`fail`/`partial` verdict. RENKIN-native route JSON only in v0.25.0; the audit model itself is tool-neutral, built to take further source adapters later |
349
+ | **RENKIN Bridge / `audit-route`** | `renkin audit-route route.json [--format auto\|renkin\|aizynthfinder] [--stock stock.smi] [--output human\|json]` — tool-neutral route audit: structural integrity, stock, and declared-reaction forward-replay validation, each reported independently as `pass`/`fail`/`not_evaluable`, rolled up into a route-level `pass`/`fail`/`partial` verdict. Reads RENKIN-native route JSON (v0.25.0) and real AiZynthFinder route JSON — single-target and gzip-compressed batch output, verified against AiZynthFinder v4.4.1 specifically, not claimed for every version (v0.26.0); `--format auto` detects the input shape and hard-errors rather than guessing on anything ambiguous. [5-minute walkthrough with real output →](https://kent-tokyo.github.io/renkin/guides/aizynthfinder-audit-demo/) |
348
350
  | **Route scoring** | `confidence`, `step_confidence`, `success_probability` (Retro-prob style), `convergency`, `atom_economy`, `route_cost` (`Σ BB cost + steps×0.5`, or actual prices via `--bb-prices`/`--stock`) per step/route — see caveat below the table |
349
351
  | **Step metadata provenance** | Each step reports `metadata_source`/`metadata_scope` so it's machine-readable whether `conditions`/`reaction_family` came from a rule-author default vs. something more grounded; absent (not fabricated) for extracted templates |
350
352
  | **Pareto multi-objective search** | `--format pareto` returns a Pareto front across `route_cost`/`success_probability`/`steps`; objectives configurable via `--objectives` |
@@ -381,6 +383,18 @@ renkin -t "CC(=O)Oc1ccccc1C(=O)O" --format json | renkin-forward validate
381
383
 
382
384
  # Faster template retrieval with bond-center index (~24% speedup)
383
385
  renkin -t "c1ccc(NC(=O)c2ccccc2)cc1" --templates data/templates_extracted_5000.smi --bond-index
386
+
387
+ # Audit a real AiZynthFinder route export with RENKIN (see the full walkthrough:
388
+ # https://kent-tokyo.github.io/renkin/guides/aizynthfinder-audit-demo/)
389
+ renkin audit-route tests/fixtures/aizynthfinder/v4.4.1/single_trees.json \
390
+ --format aizynthfinder \
391
+ --stock data/building_blocks.smi \
392
+ --output human
393
+
394
+ # Same audit pipeline, either source — --format auto also detects both correctly
395
+ renkin -t "CC(=O)Oc1ccccc1C(=O)O" --format json > /tmp/renkin-route.json
396
+ renkin audit-route /tmp/renkin-route.json --format renkin
397
+ renkin audit-route tests/fixtures/aizynthfinder/v4.4.1/single_trees.json --format aizynthfinder
384
398
  ```
385
399
 
386
400
  ---
@@ -608,7 +622,8 @@ see "Earlier milestones" below for older shipped work.
608
622
 
609
623
  ### Recently shipped
610
624
 
611
- - [x] **RENKIN Bridge Preview** (`renkin audit-route`, shipped v0.25.0) — *Keep your current workflow. Add an auditable second opinion.* A tool-neutral route audit model: structural-integrity, stock, and declared-reaction forward-replay validation, each reported independently as `pass`/`fail`/`not_evaluable`, rolled up into a route-level `pass`/`fail`/`partial` verdict never a silently force-passed boolean. The audit model is tool-neutral; v0.25.0 ships the first adapter for RENKIN-native route JSON. `renkin audit-route route.json --stock stock.smi --output json` audits every route in a file and aggregates the results into one machine-readable report.
625
+ - [x] **Reproducible Route Audit** (`audit_manifest` on `renkin audit-route --output json`, shipped v0.27.0) — *Reproduce what was audited, from which input, with which stock and policy.* Every audit report now records RENKIN version, report schema version, source format/version, input/stock content SHA-256 hashes, and audit policy — tested for byte-identical determinism (auditing the same input twice), not just claimed. Adds a shared adapter conformance suite across RENKIN-native and AiZynthFinder route inputs, plus a written [reproducibility/compatibility contract](https://kent-tokyo.github.io/renkin/guides/audit-reproducibility-contract/) (verified-vs-supported versions, unknown-field tolerance, report-schema rules, adapter-fixture runbook). The [browser playground](https://kent-tokyo.github.io/renkin/playground/) also got a safety/UX pass this release: search runs off the main thread with cancel/time-budget support, structure rendering stays local by default (no third-party SMILES transmission), and search settings round-trip exactly through Copy CLI/Python.
626
+ - [x] **RENKIN Bridge — Cross-Tool Route Audit** (`renkin audit-route`, RENKIN-native adapter shipped v0.25.0, AiZynthFinder adapter shipped v0.26.0) — *Keep AiZynthFinder. Audit its routes with RENKIN.* A tool-neutral route audit model: structural-integrity, stock, and declared-reaction forward-replay validation, each reported independently as `pass`/`fail`/`not_evaluable`, rolled up into a route-level `pass`/`fail`/`partial` verdict — never a silently force-passed boolean. v0.26.0 adds a real AiZynthFinder adapter (single-target and gzip batch JSON, verified against captured v4.4.1 output — see [`PROVENANCE.md`](tests/fixtures/aizynthfinder/v4.4.1/PROVENANCE.md)) plus `--format auto` detection, so both tools' routes run through the exact same audit pipeline; auditing the real fixtures also surfaced and fixed a shared forward-replay bug where precursor ordering, not just chemistry, affected the verdict. `renkin audit-route route.json --stock stock.smi --output json` audits every route in a file and aggregates the results into one machine-readable report, regardless of which tool produced it.
612
627
  - [x] Coverage mode (`--search-mode coverage`, [#101](https://github.com/kent-tokyo/renkin/issues/101), shipped v0.24.0) — opt-in Stage-1/Stage-2 template-count escalation, addressing the candidate-generation coverage gap below. Confirmed by a one-shot 500-target formal-TEST (`data/coverage_mode_formal_test/protocol_v2.md`): coverage +6.0pp, net gain +30, zero regressions, zero reranker failures, Stage-2 timeout rate 0.25% — all against pre-registered thresholds. See the Key Features table above for the shipped surface
613
628
  - [x] Reranker made actually usable: Python exposure (`find_routes()`'s `reranker_model_path`/`reranker_freq_table_path`) and batteries-included model distribution (`scripts/fetch_reranker_model.py`, SHA-256-verified fetch from the v0.22.0 GitHub Release's canonical assets) ([#101](https://github.com/kent-tokyo/renkin/issues/101), shipped v0.23.0) — v0.22.0 proved the reranker works; v0.23.0 is the usability/distribution unlock, not a new accuracy claim
614
629
  - [x] LightGBM candidate reranker, trained/gated offline and wired into route search ([#101](https://github.com/kent-tokyo/renkin/issues/101) Task 35, CLI shipped v0.22.0) — LambdaMART model trained on real USPTO-50k labels, passed its VAL screening gate (top1 +11.7pp, MRR +11.3pp, top10 +9.3pp, bootstrap-CI-confirmed) and a formal 4,903-target TEST evaluation against the frozen model exactly once (top1 +12.7pp, MRR +11.9pp, top10 +9.1pp — consistent magnitude with VAL, no overfitting signal), then wired into `find_routes` as an ordering-only rank bonus and confirmed with a paired 100-target route-search gate: `route_to_configured_stock` 16→20/100 (+4/-0). See the Key Features table above
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "kent-tokyo <kent-tokyo@users.noreply.github.com>"
6
6
  ],
7
7
  "description": "Ultra-fast retrosynthesis engine for computer-aided synthesis planning (CASP) — pure Rust, WASM-ready, Python bindings via PyO3",
8
- "version": "0.25.0",
8
+ "version": "0.27.0",
9
9
  "license": "MIT",
10
10
  "repository": {
11
11
  "type": "git",
package/renkin.d.ts CHANGED
@@ -1,6 +1,14 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
 
4
+ /**
5
+ * Static capabilities of this WASM build (browser edition), as a JSON
6
+ * string -- real counts read from the same compiled-in data `find_routes`
7
+ * itself searches against, not a hardcoded UI string that can drift from
8
+ * what the engine actually has loaded.
9
+ */
10
+ export function capabilities(): string;
11
+
4
12
  /**
5
13
  * Find retrosynthetic routes for a target molecule (WASM entry point).
6
14
  *
@@ -22,6 +30,23 @@
22
30
  */
23
31
  export function find_routes(target: string, depth: number, max_routes: number, beam_width: number): string;
24
32
 
33
+ /**
34
+ * Find retrosynthetic routes with element filtering (WASM entry point).
35
+ *
36
+ * Same as [`find_routes`] plus `avoid_elements`/`require_elements`: comma-
37
+ * separated element symbols, identical format and conversion
38
+ * (`chem_env::elem_symbols_to_mask`) as the CLI's own `--avoid-elements`/
39
+ * `--require-elements` flags, so browser filtering behaves exactly like
40
+ * the CLI's, not a separately-maintained copy. A distinct function name
41
+ * rather than optional/extra parameters on `find_routes`, so a caller on
42
+ * an old build gets a real "no such export" `TypeError` instead of a
43
+ * silently-ignored argument -- this playground's own JS previously relied
44
+ * on `try { 6-arg call } catch { 4-arg call }` to bridge this gap, which
45
+ * meant `avoid_elements`/`require_elements` silently never took effect
46
+ * against any WASM build that predates this function.
47
+ */
48
+ export function find_routes_v2(target: string, depth: number, max_routes: number, beam_width: number, avoid_elements: string, require_elements: string): string;
49
+
25
50
  /**
26
51
  * Return the crate version string.
27
52
  */
@@ -31,12 +56,14 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
31
56
 
32
57
  export interface InitOutput {
33
58
  readonly memory: WebAssembly.Memory;
59
+ readonly capabilities: () => [number, number];
34
60
  readonly find_routes: (a: number, b: number, c: number, d: number, e: number) => [number, number];
61
+ readonly find_routes_v2: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number) => [number, number];
35
62
  readonly version: () => [number, number];
36
63
  readonly __wbindgen_externrefs: WebAssembly.Table;
64
+ readonly __wbindgen_free: (a: number, b: number, c: number) => void;
37
65
  readonly __wbindgen_malloc: (a: number, b: number) => number;
38
66
  readonly __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
39
- readonly __wbindgen_free: (a: number, b: number, c: number) => void;
40
67
  readonly __wbindgen_start: () => void;
41
68
  }
42
69
 
package/renkin.js CHANGED
@@ -1,5 +1,25 @@
1
1
  /* @ts-self-types="./renkin.d.ts" */
2
2
 
3
+ /**
4
+ * Static capabilities of this WASM build (browser edition), as a JSON
5
+ * string -- real counts read from the same compiled-in data `find_routes`
6
+ * itself searches against, not a hardcoded UI string that can drift from
7
+ * what the engine actually has loaded.
8
+ * @returns {string}
9
+ */
10
+ export function capabilities() {
11
+ let deferred1_0;
12
+ let deferred1_1;
13
+ try {
14
+ const ret = wasm.capabilities();
15
+ deferred1_0 = ret[0];
16
+ deferred1_1 = ret[1];
17
+ return getStringFromWasm0(ret[0], ret[1]);
18
+ } finally {
19
+ wasm.__wbindgen_free(deferred1_0, deferred1_1, 1);
20
+ }
21
+ }
22
+
3
23
  /**
4
24
  * Find retrosynthetic routes for a target molecule (WASM entry point).
5
25
  *
@@ -39,6 +59,47 @@ export function find_routes(target, depth, max_routes, beam_width) {
39
59
  }
40
60
  }
41
61
 
62
+ /**
63
+ * Find retrosynthetic routes with element filtering (WASM entry point).
64
+ *
65
+ * Same as [`find_routes`] plus `avoid_elements`/`require_elements`: comma-
66
+ * separated element symbols, identical format and conversion
67
+ * (`chem_env::elem_symbols_to_mask`) as the CLI's own `--avoid-elements`/
68
+ * `--require-elements` flags, so browser filtering behaves exactly like
69
+ * the CLI's, not a separately-maintained copy. A distinct function name
70
+ * rather than optional/extra parameters on `find_routes`, so a caller on
71
+ * an old build gets a real "no such export" `TypeError` instead of a
72
+ * silently-ignored argument -- this playground's own JS previously relied
73
+ * on `try { 6-arg call } catch { 4-arg call }` to bridge this gap, which
74
+ * meant `avoid_elements`/`require_elements` silently never took effect
75
+ * against any WASM build that predates this function.
76
+ * @param {string} target
77
+ * @param {number} depth
78
+ * @param {number} max_routes
79
+ * @param {number} beam_width
80
+ * @param {string} avoid_elements
81
+ * @param {string} require_elements
82
+ * @returns {string}
83
+ */
84
+ export function find_routes_v2(target, depth, max_routes, beam_width, avoid_elements, require_elements) {
85
+ let deferred4_0;
86
+ let deferred4_1;
87
+ try {
88
+ const ptr0 = passStringToWasm0(target, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
89
+ const len0 = WASM_VECTOR_LEN;
90
+ const ptr1 = passStringToWasm0(avoid_elements, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
91
+ const len1 = WASM_VECTOR_LEN;
92
+ const ptr2 = passStringToWasm0(require_elements, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
93
+ const len2 = WASM_VECTOR_LEN;
94
+ const ret = wasm.find_routes_v2(ptr0, len0, depth, max_routes, beam_width, ptr1, len1, ptr2, len2);
95
+ deferred4_0 = ret[0];
96
+ deferred4_1 = ret[1];
97
+ return getStringFromWasm0(ret[0], ret[1]);
98
+ } finally {
99
+ wasm.__wbindgen_free(deferred4_0, deferred4_1, 1);
100
+ }
101
+ }
102
+
42
103
  /**
43
104
  * Return the crate version string.
44
105
  * @returns {string}
package/renkin_bg.wasm CHANGED
Binary file