goldenmatch 0.1.0 → 0.4.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/CHANGELOG.md +31 -0
- package/LICENSE +21 -0
- package/README.md +54 -2
- package/dist/cli.cjs +1776 -46
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +1774 -44
- package/dist/cli.js.map +1 -1
- package/dist/core/index.cjs +2321 -1046
- package/dist/core/index.cjs.map +1 -1
- package/dist/core/index.d.cts +243 -195
- package/dist/core/index.d.ts +243 -195
- package/dist/core/index.js +2306 -1045
- package/dist/core/index.js.map +1 -1
- package/dist/index.cjs +2321 -1046
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2306 -1045
- package/dist/index.js.map +1 -1
- package/dist/node/backends/score-worker.cjs.map +1 -1
- package/dist/node/backends/score-worker.d.cts +1 -1
- package/dist/node/backends/score-worker.d.ts +1 -1
- package/dist/node/backends/score-worker.js.map +1 -1
- package/dist/node/index.cjs +2441 -624
- package/dist/node/index.cjs.map +1 -1
- package/dist/node/index.d.cts +110 -27
- package/dist/node/index.d.ts +110 -27
- package/dist/node/index.js +2421 -620
- package/dist/node/index.js.map +1 -1
- package/dist/types-DlzBTOit.d.cts +684 -0
- package/dist/types-DlzBTOit.d.ts +684 -0
- package/examples/README.md +2 -0
- package/examples/strictModeParity.ts +78 -0
- package/examples/verificationInspection.ts +99 -0
- package/package.json +79 -29
- package/src/cli.ts +314 -4
- package/src/core/api.ts +85 -7
- package/src/core/autoconfig.ts +133 -10
- package/src/core/autoconfigVerify.ts +974 -0
- package/src/core/cluster.ts +58 -4
- package/src/core/config/loader.ts +22 -2
- package/src/core/domain.ts +9 -0
- package/src/core/index.ts +28 -7
- package/src/core/llm/explain.ts +181 -0
- package/src/core/llm/scorer.ts +73 -2
- package/src/core/memory/corrections.ts +258 -129
- package/src/core/memory/hash.ts +81 -0
- package/src/core/memory/index.ts +14 -0
- package/src/core/memory/learner.ts +108 -190
- package/src/core/memory/store.ts +0 -0
- package/src/core/memory/types.ts +215 -0
- package/src/core/pipeline.ts +233 -8
- package/src/core/profiler.ts +122 -12
- package/src/core/review-queue.ts +86 -3
- package/src/core/sensitivity.ts +5 -5
- package/src/core/types.ts +28 -2
- package/src/node/a2a/server.ts +2 -2
- package/src/node/api/server.ts +49 -3
- package/src/node/db/sync.ts +1 -1
- package/src/node/dedupe-file.ts +9 -5
- package/src/node/index.ts +3 -0
- package/src/node/mcp/memory-tools.ts +402 -0
- package/src/node/mcp/server.ts +28 -8
- package/src/node/memory/api.ts +134 -0
- package/src/node/memory/index.ts +18 -0
- package/src/node/memory/sqlite-store.ts +294 -0
- package/src/node/tui/app.ts +1 -1
- package/tests/parity/autoconfig-verify-fixtures.json +1147 -0
- package/tests/parity/autoconfigVerify-parity.test.ts +114 -0
- package/tests/parity/fixtures/memory.db +0 -0
- package/tests/parity/fixtures/memory_apply_inputs.json +116 -0
- package/tests/parity/fixtures/memory_corrections.json +182 -0
- package/tests/parity/memory_apply.parity.test.ts +117 -0
- package/tests/parity/memory_json.parity.test.ts +125 -0
- package/tests/parity/memory_sqlite.parity.test.ts +96 -0
- package/tests/smoke.test.ts +11 -4
- package/tests/unit/api.test.ts +12 -12
- package/tests/unit/autoconfig-classifier.test.ts +59 -0
- package/tests/unit/autoconfig-multi-name.test.ts +33 -0
- package/tests/unit/autoconfig-preflight-integration.test.ts +37 -0
- package/tests/unit/autoconfig-weight-cap.test.ts +18 -0
- package/tests/unit/autoconfig-year.test.ts +49 -0
- package/tests/unit/autoconfig.test.ts +29 -8
- package/tests/unit/autoconfigVerify-invariants.test.ts +202 -0
- package/tests/unit/autoconfigVerify-postflight.test.ts +238 -0
- package/tests/unit/autoconfigVerify-preflight.test.ts +410 -0
- package/tests/unit/autoconfigVerify-types.test.ts +117 -0
- package/tests/unit/cli-memory.test.ts +169 -0
- package/tests/unit/cluster.test.ts +19 -19
- package/tests/unit/explain-why.test.ts +114 -0
- package/tests/unit/lineage.test.ts +19 -19
- package/tests/unit/mcp-memory-tools.test.ts +184 -0
- package/tests/unit/memory-api.test.ts +155 -0
- package/tests/unit/memory-collection.test.ts +257 -0
- package/tests/unit/memory-e2e.test.ts +246 -0
- package/tests/unit/memory-hash.test.ts +93 -0
- package/tests/unit/memory-learner.test.ts +185 -0
- package/tests/unit/memory-pipeline.test.ts +177 -0
- package/tests/unit/memory-postflight.test.ts +112 -0
- package/tests/unit/memory-reanchor.test.ts +325 -0
- package/tests/unit/memory-sqlite.test.ts +348 -0
- package/tests/unit/memory.test.ts +146 -95
- package/tests/unit/pipeline.test.ts +14 -14
- package/tests/unit/pprl-protocol.test.ts +8 -2
- package/tests/unit/profiler-confidence.test.ts +28 -0
- package/tests/unit/sensitivity.test.ts +10 -10
- package/tsconfig.json +1 -1
- package/dist/types-DhUdX5Rc.d.cts +0 -304
- package/dist/types-DhUdX5Rc.d.ts +0 -304
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to goldenmatch-js are documented in this file.
|
|
4
|
+
|
|
5
|
+
Format follows [Keep a Changelog](https://keepachangelog.com/). Versioning follows [Semantic Versioning](https://semver.org/) (strict after v1.0.0).
|
|
6
|
+
|
|
7
|
+
## [0.4.0] - 2026-05-05
|
|
8
|
+
|
|
9
|
+
### BREAKING
|
|
10
|
+
|
|
11
|
+
- `Correction.verdict` renamed to `Correction.decision` (`"approve" | "reject"`)
|
|
12
|
+
- `Correction.feature` renamed to `Correction.matchkeyName`
|
|
13
|
+
- `MemoryStore` interface methods are now async (return `Promise<...>`)
|
|
14
|
+
- `runDedupePipeline` and `runMatchPipeline` are now async
|
|
15
|
+
- `dedupe`, `match`, `dedupeFile`, `matchFile` API functions are now async
|
|
16
|
+
- Hash algorithm changed from FNV-1a to SHA-256 (cross-language storage parity with Python goldenmatch v1.6.0)
|
|
17
|
+
- `MemoryConfig.backend` enum: `"sqlite" | "postgres"` -> `"memory" | "sqlite"`
|
|
18
|
+
- `MemoryConfig.trust`: `number` -> `{ human: number; agent: number }` (matches Python)
|
|
19
|
+
|
|
20
|
+
### Added
|
|
21
|
+
|
|
22
|
+
- Pipeline integration for Learning Memory (`config.memory.enabled = true`)
|
|
23
|
+
- Five MCP tools: `list_corrections`, `add_correction`, `learn_thresholds`, `memory_stats`, `memory_export`
|
|
24
|
+
- CLI subgroup: `goldenmatch-js memory <stats|learn|export|import|show>`
|
|
25
|
+
- Python API mirror: `getMemory`, `addCorrection`, `learn`, `memoryStats`
|
|
26
|
+
- `SqliteMemoryStore` (Node only; requires `better-sqlite3` peer dep)
|
|
27
|
+
- Cross-language parity tests (JSON, SQLite, apply-outcome) -- Python and TS both run against the same fixtures
|
|
28
|
+
- Postflight rendering: `Memory: N applied, M stale, K stale-ambiguous, J unanchorable`
|
|
29
|
+
- Re-anchoring: corrections survive row reordering across runs (collision-safe; `record_hash` excludes `__row_id__`)
|
|
30
|
+
- `CorrectionStats.staleAmbiguous` and `staleUnanchorable` counters
|
|
31
|
+
- Explainer integration: `ReviewItem` carries a one-sentence `why`, deterministic by default with LLM upgrade when API key is set
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2026 Ben Severn
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@ npm install goldenmatch
|
|
|
9
9
|
[](https://www.npmjs.com/package/goldenmatch)
|
|
10
10
|
[](https://nodejs.org/)
|
|
11
11
|
[](https://github.com/benzsevern/goldenmatch/blob/main/LICENSE)
|
|
12
|
-
[](https://github.com/benzsevern/goldenmatch/tree/main/packages/goldenmatch-js/tests)
|
|
13
13
|
|
|
14
14
|
---
|
|
15
15
|
|
|
@@ -18,7 +18,7 @@ npm install goldenmatch
|
|
|
18
18
|
- **Edge-safe core** — the matching engine runs in browsers, Workers, Vercel Edge Runtime, Deno
|
|
19
19
|
- **Pure TypeScript** — no native dependencies required; peer deps unlock performance (hnswlib, ONNX, piscina)
|
|
20
20
|
- **Feature parity with Python goldenmatch** — same scorers, same clustering, same YAML configs
|
|
21
|
-
- **
|
|
21
|
+
- **590 tests, strict TypeScript** — `noUncheckedIndexedAccess`, `exactOptionalPropertyTypes`
|
|
22
22
|
|
|
23
23
|
## Quick Start
|
|
24
24
|
|
|
@@ -45,6 +45,58 @@ for (const record of result.goldenRecords) {
|
|
|
45
45
|
}
|
|
46
46
|
```
|
|
47
47
|
|
|
48
|
+
## Auto-Config Verification (v0.3)
|
|
49
|
+
|
|
50
|
+
Auto-generated configs are now checked both before the pipeline runs and after
|
|
51
|
+
scoring finishes, so you get actionable diagnostics instead of silent failures
|
|
52
|
+
on edge-case data.
|
|
53
|
+
|
|
54
|
+
### Preflight — six static checks
|
|
55
|
+
|
|
56
|
+
When you call `autoConfigureRows(rows)`, the returned config ships with a
|
|
57
|
+
`_preflightReport` summarising six config-time checks:
|
|
58
|
+
|
|
59
|
+
1. **missing_column** — matchkey/blocking references a column not in the data
|
|
60
|
+
2. **cardinality_high** — a column is near-unique (poor blocking signal)
|
|
61
|
+
3. **cardinality_low** — a column has too few distinct values to discriminate
|
|
62
|
+
4. **block_size** — a blocking key would produce oversized blocks
|
|
63
|
+
5. **remote_asset** — a scorer requires a model download (gated offline)
|
|
64
|
+
6. **weight_confidence** — a weighted matchkey's weights look unbalanced
|
|
65
|
+
|
|
66
|
+
Many findings trigger **auto-repairs** (field dropped, scorer swapped,
|
|
67
|
+
weight clamped). `hasErrors === true` on unrepairable errors raises
|
|
68
|
+
`ConfigValidationError` with the full report attached.
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
import { autoConfigureRows, ConfigValidationError } from "goldenmatch";
|
|
72
|
+
|
|
73
|
+
const cfg = autoConfigureRows(rows);
|
|
74
|
+
for (const f of cfg._preflightReport!.findings) {
|
|
75
|
+
console.log(`[${f.severity}] ${f.check}/${f.subject}: ${f.message}`);
|
|
76
|
+
}
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
Defaults are **offline-safe**: remote-asset scorers (cross-encoder, remote
|
|
80
|
+
embeddings) are dropped unless you opt in with `allowRemoteAssets: true`.
|
|
81
|
+
|
|
82
|
+
### Postflight — four runtime signals
|
|
83
|
+
|
|
84
|
+
Inside `dedupe()` / `match()`, after scoring but before clustering, the
|
|
85
|
+
pipeline computes four signals attached as `result.postflightReport`:
|
|
86
|
+
|
|
87
|
+
1. **scoreHistogram** — 100-bin pair-score distribution
|
|
88
|
+
2. **blockSizePercentiles** + **preliminaryClusterSizes** — p50/p95/p99/max
|
|
89
|
+
3. **thresholdOverlapPct** — fraction of pairs near the current threshold
|
|
90
|
+
4. **oversizedClusters** — components above size limit, with bottleneck pair
|
|
91
|
+
|
|
92
|
+
If the score distribution is clearly bimodal, postflight proposes a
|
|
93
|
+
threshold adjustment. In **strict mode** (`autoConfigureRows(rows, { strict: true })`
|
|
94
|
+
or manual `_strictAutoconfig: true`) the signals are still emitted but the
|
|
95
|
+
threshold is never touched — use this for reproducible CI pipelines.
|
|
96
|
+
|
|
97
|
+
See `examples/verificationInspection.ts` and `examples/strictModeParity.ts`
|
|
98
|
+
for runnable demos.
|
|
99
|
+
|
|
48
100
|
## Three entrypoints
|
|
49
101
|
|
|
50
102
|
```typescript
|