@mailwoman/core 9.1.0 → 9.2.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 +1 -1
- package/api/responses.ts +12 -0
- package/coarse-placer/featurize.ts +0 -2
- package/coarse-placer/tools/build-dataset.ts +1 -1
- package/coarse-placer/tools/build-outlier-exposure.ts +1 -1
- package/coarse-placer/tools/build-outlier-latin.ts +13 -7
- package/coarse-placer/tools/build-outlier-oa.ts +11 -5
- package/coarse-placer/tools/eval-latin-offmap.ts +3 -2
- package/coarse-placer/tools/eval-openset.ts +3 -2
- package/coarse-placer/tools/eval-quant-compare.ts +3 -2
- package/coarse-placer/tools/eval.ts +3 -2
- package/coarse-placer/tools/fnv-hash.ts +1 -6
- package/coarse-placer/tools/index.ts +1 -1
- package/coarse-placer/tools/probe-frontier.ts +3 -2
- package/coarse-placer/tools/quantize.ts +2 -2
- package/coarse-placer/tools/train.ts +2 -1
- package/crypto/node.ts +3 -1
- package/data/internal/dictionaries/languages.csv +184 -184
- package/data/libpostal/README.md +8 -2
- package/db/schema.ts +12 -3
- package/decoder/containment.ts +5 -1
- package/decoder/index.ts +1 -0
- package/decoder/parse-diff.ts +347 -0
- package/decoder/proposals-to-tree.ts +1 -1
- package/decoder/serialize-json.ts +51 -7
- package/decoder/serialize-tuples.ts +7 -1
- package/decoder/serialize-xml.ts +1 -1
- package/decoder/tree-shape.ts +144 -0
- package/decoder/types.ts +8 -0
- package/decoder/validate-tree.ts +15 -3
- package/env/index.ts +3 -1
- package/env/paths.ts +21 -33
- package/env/schema.ts +26 -3
- package/fs/utils/formatters.ts +107 -0
- package/fs/utils/index.ts +7 -0
- package/fs/zip.ts +1 -1
- package/layers/manifest.ts +56 -15
- package/layers/schema.ts +54 -2
- package/locale/locale.ts +1 -1
- package/locale/registry.ts +1 -1
- package/objects.ts +20 -8
- package/out/api/responses.d.ts +9 -0
- package/out/api/responses.d.ts.map +1 -1
- package/out/api/responses.js +11 -0
- package/out/api/responses.js.map +1 -1
- package/out/coarse-placer/featurize.d.ts +0 -1
- package/out/coarse-placer/featurize.d.ts.map +1 -1
- package/out/coarse-placer/featurize.js.map +1 -1
- package/out/coarse-placer/tools/build-dataset.js +1 -1
- package/out/coarse-placer/tools/build-dataset.js.map +1 -1
- package/out/coarse-placer/tools/build-outlier-exposure.js +1 -1
- package/out/coarse-placer/tools/build-outlier-exposure.js.map +1 -1
- package/out/coarse-placer/tools/build-outlier-latin.d.ts.map +1 -1
- package/out/coarse-placer/tools/build-outlier-latin.js +12 -7
- package/out/coarse-placer/tools/build-outlier-latin.js.map +1 -1
- package/out/coarse-placer/tools/build-outlier-oa.d.ts.map +1 -1
- package/out/coarse-placer/tools/build-outlier-oa.js +10 -5
- package/out/coarse-placer/tools/build-outlier-oa.js.map +1 -1
- package/out/coarse-placer/tools/eval-latin-offmap.d.ts.map +1 -1
- package/out/coarse-placer/tools/eval-latin-offmap.js +2 -2
- package/out/coarse-placer/tools/eval-latin-offmap.js.map +1 -1
- package/out/coarse-placer/tools/eval-openset.d.ts.map +1 -1
- package/out/coarse-placer/tools/eval-openset.js +2 -2
- package/out/coarse-placer/tools/eval-openset.js.map +1 -1
- package/out/coarse-placer/tools/eval-quant-compare.d.ts.map +1 -1
- package/out/coarse-placer/tools/eval-quant-compare.js +2 -2
- package/out/coarse-placer/tools/eval-quant-compare.js.map +1 -1
- package/out/coarse-placer/tools/eval.d.ts.map +1 -1
- package/out/coarse-placer/tools/eval.js +2 -2
- package/out/coarse-placer/tools/eval.js.map +1 -1
- package/out/coarse-placer/tools/fnv-hash.d.ts +1 -6
- package/out/coarse-placer/tools/fnv-hash.d.ts.map +1 -1
- package/out/coarse-placer/tools/fnv-hash.js +1 -6
- package/out/coarse-placer/tools/fnv-hash.js.map +1 -1
- package/out/coarse-placer/tools/index.d.ts +1 -1
- package/out/coarse-placer/tools/index.js +1 -1
- package/out/coarse-placer/tools/probe-frontier.d.ts.map +1 -1
- package/out/coarse-placer/tools/probe-frontier.js +2 -2
- package/out/coarse-placer/tools/probe-frontier.js.map +1 -1
- package/out/coarse-placer/tools/quantize.js +2 -2
- package/out/coarse-placer/tools/quantize.js.map +1 -1
- package/out/coarse-placer/tools/train.d.ts.map +1 -1
- package/out/coarse-placer/tools/train.js +1 -1
- package/out/coarse-placer/tools/train.js.map +1 -1
- package/out/crypto/node.d.ts.map +1 -1
- package/out/crypto/node.js +2 -1
- package/out/crypto/node.js.map +1 -1
- package/out/db/schema.d.ts +12 -3
- package/out/db/schema.d.ts.map +1 -1
- package/out/db/schema.js +6 -0
- package/out/db/schema.js.map +1 -1
- package/out/decoder/containment.d.ts.map +1 -1
- package/out/decoder/containment.js +5 -1
- package/out/decoder/containment.js.map +1 -1
- package/out/decoder/index.d.ts +1 -0
- package/out/decoder/index.d.ts.map +1 -1
- package/out/decoder/index.js +1 -0
- package/out/decoder/index.js.map +1 -1
- package/out/decoder/parse-diff.d.ts +125 -0
- package/out/decoder/parse-diff.d.ts.map +1 -0
- package/out/decoder/parse-diff.js +219 -0
- package/out/decoder/parse-diff.js.map +1 -0
- package/out/decoder/proposals-to-tree.js.map +1 -1
- package/out/decoder/serialize-json.d.ts +29 -0
- package/out/decoder/serialize-json.d.ts.map +1 -1
- package/out/decoder/serialize-json.js +20 -4
- package/out/decoder/serialize-json.js.map +1 -1
- package/out/decoder/serialize-tuples.d.ts +8 -1
- package/out/decoder/serialize-tuples.d.ts.map +1 -1
- package/out/decoder/serialize-tuples.js +7 -1
- package/out/decoder/serialize-tuples.js.map +1 -1
- package/out/decoder/serialize-xml.js +1 -1
- package/out/decoder/serialize-xml.js.map +1 -1
- package/out/decoder/tree-shape.d.ts +84 -0
- package/out/decoder/tree-shape.d.ts.map +1 -0
- package/out/decoder/tree-shape.js +98 -0
- package/out/decoder/tree-shape.js.map +1 -0
- package/out/decoder/types.d.ts +11 -0
- package/out/decoder/types.d.ts.map +1 -1
- package/out/decoder/validate-tree.d.ts +8 -0
- package/out/decoder/validate-tree.d.ts.map +1 -1
- package/out/decoder/validate-tree.js +4 -3
- package/out/decoder/validate-tree.js.map +1 -1
- package/out/env/index.d.ts +10 -1
- package/out/env/index.d.ts.map +1 -1
- package/out/env/index.js +2 -1
- package/out/env/index.js.map +1 -1
- package/out/env/paths.d.ts +15 -8
- package/out/env/paths.d.ts.map +1 -1
- package/out/env/paths.js +19 -29
- package/out/env/paths.js.map +1 -1
- package/out/env/schema.d.ts +9 -1
- package/out/env/schema.d.ts.map +1 -1
- package/out/env/schema.js +25 -3
- package/out/env/schema.js.map +1 -1
- package/out/fs/utils/formatters.d.ts +57 -0
- package/out/fs/utils/formatters.d.ts.map +1 -0
- package/out/fs/utils/formatters.js +79 -0
- package/out/fs/utils/formatters.js.map +1 -0
- package/out/fs/utils/index.d.ts +7 -0
- package/out/fs/utils/index.d.ts.map +1 -0
- package/out/fs/utils/index.js +7 -0
- package/out/fs/utils/index.js.map +1 -0
- package/out/fs/zip.js +1 -1
- package/out/fs/zip.js.map +1 -1
- package/out/layers/manifest.d.ts +32 -7
- package/out/layers/manifest.d.ts.map +1 -1
- package/out/layers/manifest.js +31 -6
- package/out/layers/manifest.js.map +1 -1
- package/out/layers/schema.d.ts +48 -2
- package/out/layers/schema.d.ts.map +1 -1
- package/out/layers/schema.js +32 -0
- package/out/layers/schema.js.map +1 -1
- package/out/locale/locale.d.ts +1 -1
- package/out/locale/locale.d.ts.map +1 -1
- package/out/locale/registry.js +1 -1
- package/out/locale/registry.js.map +1 -1
- package/out/objects.d.ts +12 -6
- package/out/objects.d.ts.map +1 -1
- package/out/objects.js +4 -1
- package/out/objects.js.map +1 -1
- package/out/pipeline/index.d.ts +2 -6
- package/out/pipeline/index.d.ts.map +1 -1
- package/out/pipeline/index.js +1 -3
- package/out/pipeline/index.js.map +1 -1
- package/out/pipeline/runtime-pipeline.d.ts +51 -9
- package/out/pipeline/runtime-pipeline.d.ts.map +1 -1
- package/out/pipeline/runtime-pipeline.js +29 -132
- package/out/pipeline/runtime-pipeline.js.map +1 -1
- package/out/pipeline/span-proposer.js +1 -1
- package/out/pipeline/span-proposer.js.map +1 -1
- package/out/pipeline/types.d.ts +22 -14
- package/out/pipeline/types.d.ts.map +1 -1
- package/out/pipeline/types.js.map +1 -1
- package/out/policy/defaults.d.ts +1 -1
- package/out/policy/defaults.d.ts.map +1 -1
- package/out/policy/defaults.js +1 -1
- package/out/policy/defaults.js.map +1 -1
- package/out/policy/policy.d.ts +1 -1
- package/out/policy/policy.d.ts.map +1 -1
- package/out/policy/registry.d.ts +1 -1
- package/out/policy/registry.d.ts.map +1 -1
- package/out/resolver/coverage-facts.d.ts +89 -0
- package/out/resolver/coverage-facts.d.ts.map +1 -0
- package/out/resolver/coverage-facts.js +22 -0
- package/out/resolver/coverage-facts.js.map +1 -0
- package/out/resolver/index.d.ts +2 -1
- package/out/resolver/index.d.ts.map +1 -1
- package/out/resolver/index.js +1 -0
- package/out/resolver/index.js.map +1 -1
- package/out/resolver/lookup-types.d.ts +178 -0
- package/out/resolver/lookup-types.d.ts.map +1 -0
- package/out/resolver/lookup-types.js +11 -0
- package/out/resolver/lookup-types.js.map +1 -0
- package/out/resolver/placetype-map.d.ts +71 -0
- package/out/resolver/placetype-map.d.ts.map +1 -0
- package/out/resolver/placetype-map.js +98 -0
- package/out/resolver/placetype-map.js.map +1 -0
- package/out/resolver/postcode-format.d.ts +38 -0
- package/out/resolver/postcode-format.d.ts.map +1 -0
- package/out/resolver/postcode-format.js +83 -0
- package/out/resolver/postcode-format.js.map +1 -0
- package/out/resolver/types.d.ts +271 -297
- package/out/resolver/types.d.ts.map +1 -1
- package/out/resolver/types.js +4 -97
- package/out/resolver/types.js.map +1 -1
- package/out/resources/git.d.ts +8 -1
- package/out/resources/git.d.ts.map +1 -1
- package/out/resources/git.js +4 -3
- package/out/resources/git.js.map +1 -1
- package/out/resources/languages/types.gen.d.ts +1 -1
- package/out/resources/languages/types.gen.d.ts.map +1 -1
- package/out/resources/languages/types.gen.js +40 -0
- package/out/resources/languages/types.gen.js.map +1 -1
- package/out/resources/libpostal.d.ts +2 -2
- package/out/resources/libpostal.d.ts.map +1 -1
- package/out/resources/libpostal.js +2 -2
- package/out/resources/libpostal.js.map +1 -1
- package/out/resources/whosonfirst/DataSourceCache.d.ts.map +1 -1
- package/out/resources/whosonfirst/DataSourceCache.js.map +1 -1
- package/out/resources/whosonfirst/PlacetypeDataSource.d.ts +2 -2
- package/out/resources/whosonfirst/PlacetypeDataSource.d.ts.map +1 -1
- package/out/resources/whosonfirst/PlacetypeDataSource.js +28 -3
- package/out/resources/whosonfirst/PlacetypeDataSource.js.map +1 -1
- package/out/resources/whosonfirst/loader.d.ts +2 -2
- package/out/resources/whosonfirst/loader.d.ts.map +1 -1
- package/out/resources/whosonfirst/loader.js.map +1 -1
- package/out/resources/whosonfirst/placetypes/Placetype.d.ts.map +1 -1
- package/out/resources/whosonfirst/placetypes/Placetype.js +2 -2
- package/out/resources/whosonfirst/placetypes/Placetype.js.map +1 -1
- package/out/resources/whosonfirst/placetypes/admin.d.ts +9 -1
- package/out/resources/whosonfirst/placetypes/admin.d.ts.map +1 -1
- package/out/resources/whosonfirst/placetypes/admin.js +1 -1
- package/out/resources/whosonfirst/placetypes/admin.js.map +1 -1
- package/out/resources/whosonfirst/placetypes/definition.d.ts.map +1 -1
- package/out/resources/whosonfirst/placetypes/definition.js +1 -1
- package/out/resources/whosonfirst/placetypes/definition.js.map +1 -1
- package/out/resources/whosonfirst/placetypes/index.d.ts +1 -0
- package/out/resources/whosonfirst/placetypes/index.d.ts.map +1 -1
- package/out/resources/whosonfirst/placetypes/index.js +1 -0
- package/out/resources/whosonfirst/placetypes/index.js.map +1 -1
- package/out/resources/whosonfirst/placetypes/specificity.d.ts +65 -0
- package/out/resources/whosonfirst/placetypes/specificity.d.ts.map +1 -0
- package/out/resources/whosonfirst/placetypes/specificity.js +101 -0
- package/out/resources/whosonfirst/placetypes/specificity.js.map +1 -0
- package/out/resources/whosonfirst/sharded-repo.d.ts +28 -0
- package/out/resources/whosonfirst/sharded-repo.d.ts.map +1 -1
- package/out/resources/whosonfirst/sharded-repo.js +46 -2
- package/out/resources/whosonfirst/sharded-repo.js.map +1 -1
- package/out/scripting/arguments.d.ts +27 -0
- package/out/scripting/arguments.d.ts.map +1 -0
- package/out/scripting/arguments.js +32 -0
- package/out/scripting/arguments.js.map +1 -0
- package/out/scripting/command.d.ts +28 -0
- package/out/scripting/command.d.ts.map +1 -0
- package/out/scripting/command.js +47 -0
- package/out/scripting/command.js.map +1 -0
- package/out/scripting/index.js +3 -3
- package/out/scripting/index.js.map +1 -1
- package/out/scripting/utils/index.d.ts +1 -12
- package/out/scripting/utils/index.d.ts.map +1 -1
- package/out/scripting/utils/index.js +4 -21
- package/out/scripting/utils/index.js.map +1 -1
- package/out/tools/download-libpostal-resources.d.ts.map +1 -1
- package/out/tools/download-libpostal-resources.js +4 -7
- package/out/tools/download-libpostal-resources.js.map +1 -1
- package/out/tools/download-ssl-address.d.ts +3 -3
- package/out/tools/download-ssl-address.d.ts.map +1 -1
- package/out/tools/download-ssl-address.js +26 -13
- package/out/tools/download-ssl-address.js.map +1 -1
- package/out/tools/generate-language-types.d.ts +16 -1
- package/out/tools/generate-language-types.d.ts.map +1 -1
- package/out/tools/generate-language-types.js +38 -5
- package/out/tools/generate-language-types.js.map +1 -1
- package/out/tools/index.d.ts +1 -2
- package/out/tools/index.d.ts.map +1 -1
- package/out/tools/index.js +1 -2
- package/out/tools/index.js.map +1 -1
- package/out/utils/data-root.d.ts +27 -7
- package/out/utils/data-root.d.ts.map +1 -1
- package/out/utils/data-root.js +36 -13
- package/out/utils/data-root.js.map +1 -1
- package/out/utils/hash.d.ts +2 -3
- package/out/utils/hash.d.ts.map +1 -1
- package/out/utils/hash.js +3 -3
- package/out/utils/hash.js.map +1 -1
- package/out/utils/index.d.ts +1 -0
- package/out/utils/index.d.ts.map +1 -1
- package/out/utils/index.js +1 -0
- package/out/utils/index.js.map +1 -1
- package/out/utils/jsonl.js +1 -1
- package/out/utils/jsonl.js.map +1 -1
- package/out/utils/repo.d.ts +8 -0
- package/out/utils/repo.d.ts.map +1 -1
- package/out/utils/repo.js +10 -1
- package/out/utils/repo.js.map +1 -1
- package/out/utils/sealed-db.d.ts +11 -0
- package/out/utils/sealed-db.d.ts.map +1 -1
- package/out/utils/sealed-db.js +28 -1
- package/out/utils/sealed-db.js.map +1 -1
- package/out/utils/sqlite-rows.d.ts +34 -0
- package/out/utils/sqlite-rows.d.ts.map +1 -0
- package/out/utils/sqlite-rows.js +37 -0
- package/out/utils/sqlite-rows.js.map +1 -0
- package/out/utils/stats.d.ts +1 -6
- package/out/utils/stats.d.ts.map +1 -1
- package/out/utils/stats.js +1 -6
- package/out/utils/stats.js.map +1 -1
- package/package.json +476 -7
- package/pipeline/index.ts +12 -14
- package/pipeline/runtime-pipeline.ts +29 -183
- package/pipeline/span-proposer.ts +1 -1
- package/pipeline/types.ts +26 -15
- package/policy/defaults.ts +1 -1
- package/policy/policy.ts +1 -1
- package/policy/registry.ts +1 -1
- package/resolver/coverage-facts.ts +102 -0
- package/resolver/index.ts +5 -0
- package/resolver/lookup-types.ts +174 -0
- package/resolver/placetype-map.ts +122 -0
- package/resolver/postcode-format.ts +89 -0
- package/resolver/types.ts +293 -351
- package/resources/git.ts +18 -4
- package/resources/languages/types.gen.ts +60 -0
- package/resources/libpostal.ts +4 -3
- package/resources/whosonfirst/DataSourceCache.ts +2 -1
- package/resources/whosonfirst/PlacetypeDataSource.ts +36 -11
- package/resources/whosonfirst/loader.ts +3 -2
- package/resources/whosonfirst/placetypes/Placetype.ts +3 -2
- package/resources/whosonfirst/placetypes/admin.ts +11 -2
- package/resources/whosonfirst/placetypes/definition.ts +4 -3
- package/resources/whosonfirst/placetypes/index.ts +1 -0
- package/resources/whosonfirst/placetypes/specificity.ts +114 -0
- package/resources/whosonfirst/sharded-repo.ts +55 -2
- package/scripting/arguments.ts +38 -0
- package/scripting/command.ts +55 -0
- package/scripting/index.ts +3 -3
- package/scripting/utils/index.ts +6 -23
- package/tools/download-libpostal-resources.ts +4 -7
- package/tools/download-ssl-address.ts +28 -12
- package/tools/generate-language-types.ts +39 -5
- package/tools/index.ts +1 -2
- package/utils/data-root.ts +40 -14
- package/utils/hash.ts +5 -4
- package/utils/index.ts +1 -0
- package/utils/jsonl.ts +1 -1
- package/utils/repo.ts +12 -1
- package/utils/sealed-db.ts +30 -1
- package/utils/sqlite-rows.ts +40 -0
- package/utils/stats.ts +1 -6
- package/data/libpostal/dictionaries/all/chains.txt +0 -504
- package/kysley/adapter.ts +0 -29
- package/out/kysley/adapter.d.ts +0 -13
- package/out/kysley/adapter.d.ts.map +0 -1
- package/out/kysley/adapter.js +0 -25
- package/out/kysley/adapter.js.map +0 -1
- package/out/pipeline/reconcile-lookups.d.ts +0 -39
- package/out/pipeline/reconcile-lookups.d.ts.map +0 -1
- package/out/pipeline/reconcile-lookups.js +0 -88
- package/out/pipeline/reconcile-lookups.js.map +0 -1
- package/out/pipeline/reconcile.d.ts +0 -153
- package/out/pipeline/reconcile.d.ts.map +0 -1
- package/out/pipeline/reconcile.js +0 -388
- package/out/pipeline/reconcile.js.map +0 -1
- package/out/pipeline/span-logit-aggregation.d.ts +0 -58
- package/out/pipeline/span-logit-aggregation.d.ts.map +0 -1
- package/out/pipeline/span-logit-aggregation.js +0 -117
- package/out/pipeline/span-logit-aggregation.js.map +0 -1
- package/pipeline/reconcile-lookups.ts +0 -111
- package/pipeline/reconcile.ts +0 -583
- package/pipeline/span-logit-aggregation.ts +0 -156
package/resolver/types.ts
CHANGED
|
@@ -11,9 +11,43 @@
|
|
|
11
11
|
* `RemoteResolver` adapter (Phase 4.4 — Pelias / BAN / Nominatim) without a public-API break.
|
|
12
12
|
*
|
|
13
13
|
* See `docs/plan/phases/PHASE_4_3_resolver_integration.md` for the design intent.
|
|
14
|
+
*
|
|
15
|
+
* This module is a published subpath (`@mailwoman/core/resolver/types`) with a wide consumer set, so the
|
|
16
|
+
* groups that moved to siblings are re-exported here rather than requiring every importer to move with them.
|
|
14
17
|
*/
|
|
15
18
|
|
|
16
|
-
import type { AddressTree
|
|
19
|
+
import type { AddressTree } from "../decoder/types.ts"
|
|
20
|
+
import type { GazetteerArtifactCoverage } from "./coverage-facts.ts"
|
|
21
|
+
import type {
|
|
22
|
+
AddressPointLookup,
|
|
23
|
+
InterpolationLookup,
|
|
24
|
+
PostcodePrefixIndexLike,
|
|
25
|
+
StreetCentroidLookup,
|
|
26
|
+
} from "./lookup-types.ts"
|
|
27
|
+
import type { PlacetypeMap } from "./placetype-map.ts"
|
|
28
|
+
|
|
29
|
+
export type { CountryBBoxFact, CountryCoverageFact, GazetteerArtifactCoverage } from "./coverage-facts.ts"
|
|
30
|
+
export { hardCountrySafelistFromCoverage } from "./coverage-facts.ts"
|
|
31
|
+
|
|
32
|
+
export type {
|
|
33
|
+
AddressPointHit,
|
|
34
|
+
AddressPointLookup,
|
|
35
|
+
InterpolatedPointHit,
|
|
36
|
+
InterpolationLookup,
|
|
37
|
+
PostcodePrefixAncestor,
|
|
38
|
+
PostcodePrefixIndexLike,
|
|
39
|
+
PostcodePrefixNode,
|
|
40
|
+
StreetCentroidHit,
|
|
41
|
+
StreetCentroidLookup,
|
|
42
|
+
} from "./lookup-types.ts"
|
|
43
|
+
|
|
44
|
+
export {
|
|
45
|
+
DEFAULT_PLACETYPE_MAP,
|
|
46
|
+
expandPlacetypeFilter,
|
|
47
|
+
isPlacetypeFallback,
|
|
48
|
+
PLACETYPE_FILTER_GROUPS,
|
|
49
|
+
type PlacetypeMap,
|
|
50
|
+
} from "./placetype-map.ts"
|
|
17
51
|
|
|
18
52
|
/**
|
|
19
53
|
* One candidate place returned by a resolver. Mirrors the shape used by `@mailwoman/core/resolver-wof-sqlite`'s
|
|
@@ -65,6 +99,12 @@ export interface ResolvedPlace {
|
|
|
65
99
|
* to score-based ordering.
|
|
66
100
|
*/
|
|
67
101
|
prominence?: number
|
|
102
|
+
/**
|
|
103
|
+
* Raw population from the backend's record, when carried (`PlaceCandidate.population` mirrors it). Absent means
|
|
104
|
+
* UNKNOWN, never zero — the meaning-of-zero rule. The bare-toponym race's region-dominance rule reads this because
|
|
105
|
+
* {@link ResolvedPlace.prominence} saturates at the backend's population cap and erases the margins it needs.
|
|
106
|
+
*/
|
|
107
|
+
population?: number
|
|
68
108
|
/**
|
|
69
109
|
* REFERENTIAL likelihood in [0, 1] — population-anchored, the named form of the key namesake ranking has always used
|
|
70
110
|
* (ROAD_TO_V9 §2, ratified 2026-08-06: "the importance of a knowledge-base article is not the probability that this
|
|
@@ -123,6 +163,23 @@ export interface ResolvedPlace {
|
|
|
123
163
|
* Absent when the exact placetype matched (the normal case).
|
|
124
164
|
*/
|
|
125
165
|
resolutionQuality?: "fallback"
|
|
166
|
+
/**
|
|
167
|
+
* The admin-containment verdict for this candidate (#1717 stage 2) — TRI-STATE, and the absence is load-bearing
|
|
168
|
+
* (meaning-of-zero): `true` = the backend's ancestors sidecar vouches that this candidate sits UNDER the query's
|
|
169
|
+
* parsed region qualifier; `false` = the backend evaluated containment and could not vouch for it; `undefined` = the
|
|
170
|
+
* question was never asked — the lever is off, the query carried no qualifier, or the backend/artifact cannot answer
|
|
171
|
+
* (no sidecar). Set only by backends implementing `FindPlaceQuery.regionQualifier`; consumed by the resolver walk's
|
|
172
|
+
* `adminContainmentRerank` partition, which must never read `undefined` as "not contained".
|
|
173
|
+
*/
|
|
174
|
+
containedByQualifier?: boolean
|
|
175
|
+
/**
|
|
176
|
+
* #1731: `true` when a `parentID` region scope was applied, MISSED across the whole probe cascade, and the backend's
|
|
177
|
+
* unscoped fallback produced this row — the re-admission path where a wrong-instance namesake enters (the Astoria
|
|
178
|
+
* class: no locality-group row exists under the parent, so the fallback answers population-first from anywhere).
|
|
179
|
+
* Absent when the question never arose (no parent scope, or the scoped probe answered). Backend-optional; the
|
|
180
|
+
* resolver-interior trace (#1721) surfaces it as a gate.
|
|
181
|
+
*/
|
|
182
|
+
regionScopeMiss?: boolean
|
|
126
183
|
}
|
|
127
184
|
|
|
128
185
|
/**
|
|
@@ -132,104 +189,18 @@ export interface ResolvedPlace {
|
|
|
132
189
|
* Structurally compatible with `PlaceLookup` from `@mailwoman/core/resolver-wof-sqlite` so the latter satisfies this
|
|
133
190
|
* interface without an adapter shim.
|
|
134
191
|
*/
|
|
135
|
-
/**
|
|
136
|
-
* One country's measured hard-filter coverage fact, as recorded at a promote gate. Facts about the gazetteer artifact
|
|
137
|
-
* live IN the artifact (the `country_coverage` table the gazetteer build emits) — code constants are only the fallback
|
|
138
|
-
* for artifacts that predate the manifest.
|
|
139
|
-
*
|
|
140
|
-
* Meaning-of-zero discipline: a country ABSENT from the coverage map was never measured — never "measured and failed".
|
|
141
|
-
* A measured-and-failed country is PRESENT with `hardFilterSafe: false` (e.g. FI at 69.5% hard-resolve), so the
|
|
142
|
-
* negative result is a first-class record, distinguishable from ignorance.
|
|
143
|
-
*/
|
|
144
|
-
export interface CountryCoverageFact {
|
|
145
|
-
/**
|
|
146
|
-
* ISO 3166-1 alpha-2, uppercase.
|
|
147
|
-
*/
|
|
148
|
-
country: string
|
|
149
|
-
/**
|
|
150
|
-
* The promote-gate VERDICT: hard-filtering this country is a pure win (a hard-filter miss is almost always a genuine
|
|
151
|
-
* non-match, not a coverage gap). Stored as a verdict — not re-derived from `hardResolveRate` at read time — because
|
|
152
|
-
* the gate is a judgment over a panel, not a pure rate function (CA cleared at the #928 promote on the
|
|
153
|
-
* postcode-format-prior rationale despite a sub-95% panel resolve rate).
|
|
154
|
-
*/
|
|
155
|
-
hardFilterSafe: boolean
|
|
156
|
-
/**
|
|
157
|
-
* Measured hard-resolve rate (0..1) on the panel named in `source`, when the receipt recorded one.
|
|
158
|
-
*/
|
|
159
|
-
hardResolveRate?: number
|
|
160
|
-
/**
|
|
161
|
-
* Panel size behind `hardResolveRate`, when recorded.
|
|
162
|
-
*/
|
|
163
|
-
sampleSize?: number
|
|
164
|
-
/**
|
|
165
|
-
* ISO-8601 date of the measurement / promote gate.
|
|
166
|
-
*/
|
|
167
|
-
measuredAt: string
|
|
168
|
-
/**
|
|
169
|
-
* The receipt: which panel/gate produced this row (issue + date, human-readable).
|
|
170
|
-
*/
|
|
171
|
-
source: string
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* One country's coarse guard-B bounding box, as carried by the gazetteer artifact's `country_bbox` table.
|
|
176
|
-
*/
|
|
177
|
-
export interface CountryBBoxFact {
|
|
178
|
-
/**
|
|
179
|
-
* ISO 3166-1 alpha-2, uppercase.
|
|
180
|
-
*/
|
|
181
|
-
country: string
|
|
182
|
-
latMin: number
|
|
183
|
-
latMax: number
|
|
184
|
-
lonMin: number
|
|
185
|
-
lonMax: number
|
|
186
|
-
/**
|
|
187
|
-
* Provenance of the box (harness + date).
|
|
188
|
-
*/
|
|
189
|
-
source: string
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
/**
|
|
193
|
-
* Facts a loaded gazetteer artifact declares about itself — read from the artifact's own manifest tables at open time,
|
|
194
|
-
* carried on the {@link ResolverBackend}/{@link Resolver} handle so consumers read the facts from the artifact they are
|
|
195
|
-
* actually resolving against. `undefined` on the handle = the artifact predates the manifest → consumers fall back to
|
|
196
|
-
* the code constants (byte-identical legacy behavior).
|
|
197
|
-
*/
|
|
198
|
-
export interface GazetteerArtifactCoverage {
|
|
199
|
-
/**
|
|
200
|
-
* Country → measured coverage fact. ABSENCE = never measured (meaning-of-zero), never "failed".
|
|
201
|
-
*/
|
|
202
|
-
countryCoverage: ReadonlyMap<string, CountryCoverageFact>
|
|
203
|
-
/**
|
|
204
|
-
* Country → guard-B bbox. ABSENCE = no box → the plausibility guard fails open for that country.
|
|
205
|
-
*/
|
|
206
|
-
countryBBoxes: ReadonlyMap<string, CountryBBoxFact>
|
|
207
|
-
/**
|
|
208
|
-
* Derived at load: the countries whose fact says `hardFilterSafe` — the artifact's hard-country safelist.
|
|
209
|
-
*/
|
|
210
|
-
hardCountrySafelist: ReadonlySet<string>
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
/**
|
|
214
|
-
* Derive the hard-country safelist from coverage facts — the ONE derivation both the reader and the build share.
|
|
215
|
-
*/
|
|
216
|
-
export function hardCountrySafelistFromCoverage(facts: Iterable<CountryCoverageFact>): ReadonlySet<string> {
|
|
217
|
-
const out = new Set<string>()
|
|
218
|
-
|
|
219
|
-
for (const fact of facts) {
|
|
220
|
-
if (fact.hardFilterSafe) {
|
|
221
|
-
out.add(fact.country.toUpperCase())
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
return out
|
|
226
|
-
}
|
|
227
192
|
|
|
228
193
|
export interface ResolverBackend {
|
|
229
194
|
findPlace(query: {
|
|
230
195
|
text: string
|
|
231
196
|
placetype?: string | string[]
|
|
232
197
|
country?: string
|
|
198
|
+
/**
|
|
199
|
+
* ISO-3166 alpha-2 scoping the TYPO-FUZZY tier only (#1585): exact and qualifier-strip probes stay worldwide, the
|
|
200
|
+
* corrected-key probes honor it, and a scoped-empty fuzzy ABSTAINS instead of falling through to a world-fuzzy
|
|
201
|
+
* candidate. Backends without a fuzzy tier ignore it. Ignored when `country` is set (already narrower).
|
|
202
|
+
*/
|
|
203
|
+
fuzzyCountry?: string
|
|
233
204
|
parentID?: number | string
|
|
234
205
|
/**
|
|
235
206
|
* Sibling postcode string, when the address carries one. A coordinate-first backend uses it to inject
|
|
@@ -248,6 +219,32 @@ export interface ResolverBackend {
|
|
|
248
219
|
* Proximity-bias points — a SOFT prominence re-rank; backends without support ignore it.
|
|
249
220
|
*/
|
|
250
221
|
bias?: Array<{ lat: number; lon: number; weight?: number }>
|
|
222
|
+
/**
|
|
223
|
+
* Restrict name matching to PRIMARY-keyed rows — set by probes whose query surface is a RE-READING (a token cut out
|
|
224
|
+
* of a longer classified span) rather than a naming. The #1626 rationale, generalized: `Savile Row`'s token `Row`
|
|
225
|
+
* never named Rhu's historical alias, so the alias tier must not answer it; a whole-input bare toponym DID name
|
|
226
|
+
* whatever it matches (Москва's exonym rows included) and keeps the alias tier. Backends without a primary flag
|
|
227
|
+
* ignore it.
|
|
228
|
+
*/
|
|
229
|
+
primaryOnly?: boolean
|
|
230
|
+
/**
|
|
231
|
+
* Alias-row NAME ROLES the probe refuses to answer through (#1730) — set by the bare-toponym side races with
|
|
232
|
+
* `abbr`/`gloss`. A lone bare token matching only an abbreviation row ("Tó" folded onto Toledo's "TO") or a
|
|
233
|
+
* translation-gloss row is a weak re-reading, not a naming; role-NULL alias rows (the exonym tier, the country
|
|
234
|
+
* display names) stay fully open, which is what `primaryOnly` could never express. Backends without a role column
|
|
235
|
+
* ignore it — an older artifact degrades to today's behavior.
|
|
236
|
+
*/
|
|
237
|
+
excludeNameRoles?: readonly string[]
|
|
238
|
+
/**
|
|
239
|
+
* The tree's parsed REGION qualifier, verbatim (#1717 stage 2) — set by the resolver on locality lookups when
|
|
240
|
+
* `ResolveOpts.adminContainmentRerank` is on. A capable backend resolves the qualifier to its own region-class rows
|
|
241
|
+
* and (a) stamps every returned candidate's `containedByQualifier`, (b) ranks contained candidates ahead of
|
|
242
|
+
* uncontained ones, and (c) may ADD contained same-name candidates its other filters (a locale-inferred country
|
|
243
|
+
* scope) would have hidden — additive only, never a filter, so a qualifier that matches nothing changes nothing.
|
|
244
|
+
* Backends without a containment source ignore it (candidates then carry no stamp, which the walk reports as
|
|
245
|
+
* `unavailable`).
|
|
246
|
+
*/
|
|
247
|
+
regionQualifier?: string
|
|
251
248
|
limit?: number
|
|
252
249
|
}): Promise<ResolvedPlace[]>
|
|
253
250
|
/**
|
|
@@ -271,6 +268,36 @@ export interface ResolverBackend {
|
|
|
271
268
|
artifactCoverage?: GazetteerArtifactCoverage
|
|
272
269
|
}
|
|
273
270
|
|
|
271
|
+
/**
|
|
272
|
+
* An optional {@link ResolverBackend} method the loaded backend does not implement, and what that costs.
|
|
273
|
+
*
|
|
274
|
+
* Optional methods let a backend be valid while omitting a capability — but the options they serve can still default to
|
|
275
|
+
* ON, in which case the feature reports success and does nothing. This type carries the absence as data so a caller can
|
|
276
|
+
* read it instead of inferring it from a result that looks complete.
|
|
277
|
+
*/
|
|
278
|
+
export interface BackendCapabilityGap {
|
|
279
|
+
/**
|
|
280
|
+
* The absent method, named as it appears on {@link ResolverBackend}.
|
|
281
|
+
*/
|
|
282
|
+
capability: "ancestors" | "coincidentLocalitiesFor"
|
|
283
|
+
/**
|
|
284
|
+
* The {@link ResolveOpts} field whose behavior the absence removes.
|
|
285
|
+
*/
|
|
286
|
+
gates: keyof ResolveOpts
|
|
287
|
+
/**
|
|
288
|
+
* Whether `gates` is on unless a caller turns it off — the difference between a silent loss and a chosen one.
|
|
289
|
+
*/
|
|
290
|
+
defaultOn: boolean
|
|
291
|
+
/**
|
|
292
|
+
* What stops working, in terms of the answer rather than the call.
|
|
293
|
+
*/
|
|
294
|
+
degrades: string
|
|
295
|
+
/**
|
|
296
|
+
* The backend's class name, so a log line identifies which artifact is loaded.
|
|
297
|
+
*/
|
|
298
|
+
backend: string
|
|
299
|
+
}
|
|
300
|
+
|
|
274
301
|
/**
|
|
275
302
|
* One link in a resolved place's containment lineage ({@link ResolverBackend.ancestors}, #404).
|
|
276
303
|
*/
|
|
@@ -302,155 +329,6 @@ export interface CoincidentLocality extends ResolvedPlace {
|
|
|
302
329
|
/**
|
|
303
330
|
* Options for `resolveTree`. All optional with sensible defaults.
|
|
304
331
|
*/
|
|
305
|
-
/**
|
|
306
|
-
* One exact address-point hit (#476): a real situs coordinate for `(street, number)` within a postcode/locality scope —
|
|
307
|
-
* the street-level tier in front of admin-centroid resolution.
|
|
308
|
-
*/
|
|
309
|
-
export interface AddressPointHit {
|
|
310
|
-
lat: number
|
|
311
|
-
lon: number
|
|
312
|
-
/**
|
|
313
|
-
* Provenance, e.g. `"overture:NAD"`.
|
|
314
|
-
*/
|
|
315
|
-
source: string
|
|
316
|
-
/**
|
|
317
|
-
* Pinned data release the point came from, e.g. `"2026-05-20.0"`.
|
|
318
|
-
*/
|
|
319
|
-
release: string
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
/**
|
|
323
|
-
* Street-level exact-point lookup (#476). Implementations own their normalization — both the shard build and this
|
|
324
|
-
* lookup must apply the SAME normalizer (see `resolver-wof-sqlite/street-normalize.ts`). Core depends only on this
|
|
325
|
-
* contract.
|
|
326
|
-
*/
|
|
327
|
-
export interface AddressPointLookup {
|
|
328
|
-
find(query: {
|
|
329
|
-
street: string
|
|
330
|
-
number: string
|
|
331
|
-
postcode?: string
|
|
332
|
-
locality?: string
|
|
333
|
-
/**
|
|
334
|
-
* Optional bbox scope (`minLat`/`maxLat`/`minLon`/`maxLon`), tried AFTER postcode/locality. For shards whose points
|
|
335
|
-
* carry no postcode/locality of their own (OSM addr nodes often don't) but DO carry a coordinate — the resolved
|
|
336
|
-
* locality's bounding box scopes the `(street, number)` probe instead. US situs never passes it (byte-stable).
|
|
337
|
-
*/
|
|
338
|
-
bbox?: { minLat: number; maxLat: number; minLon: number; maxLon: number }
|
|
339
|
-
}): AddressPointHit | null
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
/**
|
|
343
|
-
* One interpolated coordinate estimate (#483) — NEVER an exact situs point (`uncertaintyM` prices the estimate
|
|
344
|
-
* honestly). Structural mirror of `InterpolatedHit` in `resolver-wof-sqlite/interpolation.ts`; keep this a SUBSET of
|
|
345
|
-
* that shape so the concrete `StreetInterpolator`/`AddressPointInterpolator` satisfy {@link InterpolationLookup} with no
|
|
346
|
-
* adapter (the {@link AddressPointHit} precedent).
|
|
347
|
-
*/
|
|
348
|
-
export interface InterpolatedPointHit {
|
|
349
|
-
lat: number
|
|
350
|
-
lon: number
|
|
351
|
-
interpolated: true
|
|
352
|
-
/**
|
|
353
|
-
* `address_point` = bracketed between real neighbor points; `tiger_range` = linear within a segment range.
|
|
354
|
-
*/
|
|
355
|
-
method: "address_point" | "tiger_range"
|
|
356
|
-
/**
|
|
357
|
-
* False when only the opposite side's range contained the number (right block, wrong side).
|
|
358
|
-
*/
|
|
359
|
-
parityMatched?: boolean
|
|
360
|
-
/**
|
|
361
|
-
* `both` = neighbors bracketed it; `single` = one-sided extrapolation (larger uncertainty).
|
|
362
|
-
*/
|
|
363
|
-
bracket?: "both" | "single"
|
|
364
|
-
/**
|
|
365
|
-
* Honest uncertainty radius in METERS (half the matched segment length).
|
|
366
|
-
*/
|
|
367
|
-
uncertaintyM: number
|
|
368
|
-
source: string
|
|
369
|
-
release: string
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
/**
|
|
373
|
-
* House-number interpolation lookup (#483). Like {@link AddressPointLookup}, implementations own their normalization
|
|
374
|
-
* (the shared `resolver-wof-sqlite/street-normalize.ts`); core depends only on this contract. Postcode-scoped (no
|
|
375
|
-
* locality field) — the tier abstains statewide without a postcode.
|
|
376
|
-
*/
|
|
377
|
-
export interface InterpolationLookup {
|
|
378
|
-
find(query: { street: string; number: string; postcode?: string }): InterpolatedPointHit | null
|
|
379
|
-
/**
|
|
380
|
-
* The ARTIFACT's own conformal radius multiplier for `uncertaintyM` (#374), read from the shard's
|
|
381
|
-
* `interp_calibration` metadata table at open time (the pair-index δ/transitionBeta header precedent): the multiplier
|
|
382
|
-
* is a property of the calibration set the artifact was built against, so it ships in the artifact, not in caller
|
|
383
|
-
* code. The resolver applies it as the DEFAULT whenever `ResolveOpts.interpolationRadiusCalibration` is absent.
|
|
384
|
-
* `undefined` (or an implementation without the property) = the artifact carries none — shards built before the
|
|
385
|
-
* metadata table existed; behavior is then exactly the pre-artifact ladder (caller-supplied factor or raw).
|
|
386
|
-
* Implementations must read this at OPEN time (constructor/factory), never per-lookup — `find()` is synchronous by
|
|
387
|
-
* design.
|
|
388
|
-
*/
|
|
389
|
-
readonly radiusCalibration?: number
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
/**
|
|
393
|
-
* One street-CENTROID hit (#1042) — the street-level tier BELOW the exact address-point tier and ABOVE admin-centroid
|
|
394
|
-
* resolution. A street's centroid + an honest extent-derived radius, for a street-only query (no house number) that an
|
|
395
|
-
* address-point tier cannot serve by definition. Derived from a national register's rooftop points
|
|
396
|
-
* (`street-centroids-<cc>.db`, a `GROUP BY street` roll-up). `uncertaintyM` prices the coarseness (half the street's
|
|
397
|
-
* bbox diagonal) so a consumer never mistakes it for a rooftop.
|
|
398
|
-
*/
|
|
399
|
-
export interface StreetCentroidHit {
|
|
400
|
-
lat: number
|
|
401
|
-
lon: number
|
|
402
|
-
/**
|
|
403
|
-
* Honest coarse radius in METERS — half the street's bounding-box diagonal.
|
|
404
|
-
*/
|
|
405
|
-
uncertaintyM: number
|
|
406
|
-
source: string
|
|
407
|
-
release: string
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
/**
|
|
411
|
-
* Street-centroid lookup (#1042). Like {@link AddressPointLookup}, implementations own their normalization (the shared
|
|
412
|
-
* `resolver-wof-sqlite/street-normalize.ts`); core depends only on this contract. Scoped by `postcode` (preferred) or
|
|
413
|
-
* `locality` (the base commune) — NO house number: this is the street-only tier.
|
|
414
|
-
*/
|
|
415
|
-
export interface StreetCentroidLookup {
|
|
416
|
-
find(query: { street: string; postcode?: string; locality?: string }): StreetCentroidHit | null
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
/**
|
|
420
|
-
* One admin-ancestry entry a PFX1 node asserts (coarsest-first: country → constituent country → district).
|
|
421
|
-
*/
|
|
422
|
-
export interface PostcodePrefixAncestor {
|
|
423
|
-
placetype: string
|
|
424
|
-
wofID: number
|
|
425
|
-
name: string
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
/**
|
|
429
|
-
* A PFX1 postcode-prefix node — the partial-code prior's payload ({@link ResolveOpts.postcodePrefixPrior}, #31
|
|
430
|
-
* Mechanism 3). The coordinate is OPTIONAL and its absence is meaningful: an ancestry-only tier (NI's 80 BT districts)
|
|
431
|
-
* carries `ancestors` and no `lat`/`lon` — representable as absence, never as `0,0` (the meaning-of-zero rule).
|
|
432
|
-
* `radiusP95Km` is mandatory whenever a coordinate is present (M-3's receipt: a 1-digit US band and a GB outward code
|
|
433
|
-
* are both "a prefix with a centroid" and differ by 200×).
|
|
434
|
-
*/
|
|
435
|
-
export interface PostcodePrefixNode {
|
|
436
|
-
prefix: string
|
|
437
|
-
ancestors: readonly PostcodePrefixAncestor[]
|
|
438
|
-
lat?: number
|
|
439
|
-
lon?: number
|
|
440
|
-
radiusP95Km?: number
|
|
441
|
-
unitCount: number
|
|
442
|
-
}
|
|
443
|
-
|
|
444
|
-
/**
|
|
445
|
-
* The PFX1 index the resolver probes — minimal, structural (`probe` + optional `country`), so `@mailwoman/resolver`
|
|
446
|
-
* consumes an index built in `@mailwoman/neural` without depending on it (B3-5: the partial-code prior touches zero
|
|
447
|
-
* model inputs). `country` is the ISO-3166 alpha-2 the index was built for (upper-case); the resolver only probes an
|
|
448
|
-
* index whose country matches the query's country scope.
|
|
449
|
-
*/
|
|
450
|
-
export interface PostcodePrefixIndexLike {
|
|
451
|
-
probe(prefix: string): PostcodePrefixNode | null
|
|
452
|
-
readonly country?: string
|
|
453
|
-
}
|
|
454
332
|
|
|
455
333
|
export interface ResolveOpts {
|
|
456
334
|
/**
|
|
@@ -476,6 +354,23 @@ export interface ResolveOpts {
|
|
|
476
354
|
* overrides it deeper in the tree.
|
|
477
355
|
*/
|
|
478
356
|
defaultCountry?: string
|
|
357
|
+
/**
|
|
358
|
+
* True when {@link defaultCountry} was INFERRED from the locale rather than user-declared. A `country`-placetype
|
|
359
|
+
* lookup under an inferred scope is a self-contradiction — the query names a country outright, and the filter can
|
|
360
|
+
* only admit the scope country itself (bare `Germany` under the default en-US locale filtered out the DE row and fell
|
|
361
|
+
* through to a US locality whose historical alias is "Germany, Ohio"). The resolver therefore withholds an inferred
|
|
362
|
+
* {@link defaultCountry} from `country`-placetype lookups only; an EXPLICIT scope stays supreme (the #912 posture), as
|
|
363
|
+
* do parent evidence and the confident placer.
|
|
364
|
+
*/
|
|
365
|
+
defaultCountryIsInferred?: boolean
|
|
366
|
+
/**
|
|
367
|
+
* #1585 — the locale hint's country, scoping the backend's TYPO-FUZZY tier only. Unlike {@link defaultCountry} this
|
|
368
|
+
* is threaded even where the bare-toponym guard withholds the hard scope: an exact foreign match still resolves
|
|
369
|
+
* (`Paris` under en-US), but a typo CORRECTION stays inside the hinted country, and a scoped-empty correction
|
|
370
|
+
* abstains rather than falling through to a world-fuzzy candidate (`Stanmore Bay` under en-NZ must not answer Banmore
|
|
371
|
+
* IN). Never a country filter on exact matches — the fuzzy tier is the only consumer.
|
|
372
|
+
*/
|
|
373
|
+
fuzzyCountryScope?: string
|
|
479
374
|
/**
|
|
480
375
|
* Ordered proximity-bias points (viewport center first, then user location, …), each optionally weighted (default
|
|
481
376
|
* 1.0). SOFT ranking signal only — candidates near a bias point win prominence ties (the ambiguous-postcode case:
|
|
@@ -551,6 +446,13 @@ export interface ResolveOpts {
|
|
|
551
446
|
* consulted when `localeCountryPrior` is set.
|
|
552
447
|
*/
|
|
553
448
|
localeCountryPriorWeight?: number
|
|
449
|
+
/**
|
|
450
|
+
* #1880 — capital status of a candidate (2 national capital, 1 admin-1 seat, 0 neither), answered by the caller's
|
|
451
|
+
* reference against the candidate's own name + country + coordinates. Consumed by the resolver's bounded capital
|
|
452
|
+
* promotion (`resolver/toponym-prior.ts` — the bare-toponym class only, after the fame key). Structural rather than a
|
|
453
|
+
* named import because this package must not depend on the reference's home. Undefined → no promotion, byte-stable.
|
|
454
|
+
*/
|
|
455
|
+
capitalLevel?: (place: { name: string; country?: string; lat: number; lon: number }) => number
|
|
554
456
|
/**
|
|
555
457
|
* #743/#194 — a CONFIDENT coarse-placer country applied as a HARD candidate filter (`query.country`), not the soft
|
|
556
458
|
* {@link anchorPosterior} boost. This collapses the off-continent tail for LOW-population places the soft prior can't
|
|
@@ -785,6 +687,14 @@ export interface ResolveOpts {
|
|
|
785
687
|
* structural type (`PostcodePrefixIndexLike`), injected, never imported from `@mailwoman/neural`.
|
|
786
688
|
*/
|
|
787
689
|
postcodePrefixPrior?: boolean
|
|
690
|
+
/**
|
|
691
|
+
* #1589 — countries the parsed postcode's FORMAT implies (the #928 unforgeable singles plus the shared `NNN NN`
|
|
692
|
+
* CZ/SK/SE/GR family). Applied by the `postalcode` lookup ONLY when no country constraint survives (an explicit
|
|
693
|
+
* `defaultCountry` outranks format evidence, which outranks a locale hint): the lookup probes exactly the implied
|
|
694
|
+
* countries, keeps the most populous hit, and abstains when all miss rather than falling through to a fold-colliding
|
|
695
|
+
* unconstrained probe.
|
|
696
|
+
*/
|
|
697
|
+
postcodeFormatCountries?: readonly string[]
|
|
788
698
|
/**
|
|
789
699
|
* The PFX1 postcode-prefix index to probe when {@link postcodePrefixPrior} is on — injected by the pipeline (loaded
|
|
790
700
|
* from `$MAILWOMAN_DATA_ROOT/postcode-prefix/postcode-prefix-<cc>.bin`), never constructed here. Structural
|
|
@@ -805,11 +715,28 @@ export interface ResolveOpts {
|
|
|
805
715
|
* or the backend lacks `ancestors`. Pass `false` to opt out.
|
|
806
716
|
*/
|
|
807
717
|
adminCoherence?: boolean
|
|
808
|
-
hierarchyCompletion?: boolean
|
|
809
718
|
/**
|
|
810
|
-
*
|
|
719
|
+
* Dual-role completion (#387, generalized by #405). Some places are two things at once — Singapore is a country AND a
|
|
720
|
+
* city, Washington DC a region AND a locality — but the address writes one span, so the tree resolves a region and
|
|
721
|
+
* carries no locality node even though the place genuinely is one.
|
|
722
|
+
*
|
|
723
|
+
* When a region resolved and no locality span is present, this asks the gazetteer's `coincident_roles` relation
|
|
724
|
+
* (#403, via {@link ResolverBackend.coincidentLocalitiesFor}) whether that region also functions as a locality, and
|
|
725
|
+
* ATTACHES a second reading to the same node. The region answer is untouched; the locality reading rides alongside it
|
|
726
|
+
* in `interpretations`, stamped `resolver_completed` so a consumer can tell it was inferred rather than parsed.
|
|
727
|
+
*
|
|
728
|
+
* **Default-ON, and on the shipped default backend it currently does nothing.** `WOFCandidateTableLookup` implements
|
|
729
|
+
* neither `coincidentLocalitiesFor` nor `ancestors` — `candidate.db` carries no such table — so the guard returns and
|
|
730
|
+
* no interpretation is attached. `Resolver.capabilityGaps` reports that at construction rather than leaving it
|
|
731
|
+
* silent.
|
|
732
|
+
*
|
|
733
|
+
* Measured 2026-08-15 on the FTS backend, which DOES implement both: toggling this flag changed **0 of 837** board
|
|
734
|
+
* inputs. The capability is real and its measured value on everything we currently test is zero, which is why
|
|
735
|
+
* `candidate.db` was not grown to support it (#1667, closed not-planned). Reopen on a consumer that needs it.
|
|
736
|
+
*
|
|
737
|
+
* `false` opts out; byte-stable either way on any backend lacking the relation.
|
|
811
738
|
*/
|
|
812
|
-
|
|
739
|
+
hierarchyCompletion?: boolean
|
|
813
740
|
/**
|
|
814
741
|
* Attach each resolved node's ancestor lineage (#404) — the containment chain (county → region → country) the
|
|
815
742
|
* backend's {@link ResolverBackend.ancestors} returns — onto `metadata.ancestors`. The Pelias/Nominatim
|
|
@@ -818,121 +745,123 @@ export interface ResolveOpts {
|
|
|
818
745
|
* resolver actually resolved.
|
|
819
746
|
*/
|
|
820
747
|
includeAncestors?: boolean
|
|
748
|
+
/**
|
|
749
|
+
* Admin-containment re-rank (#1717 stage 2) — make a parsed REGION qualifier participate in locality-candidate
|
|
750
|
+
* selection. `Weimar, Thüringen` under the en-US locale resolves to Weimar, Texas: the locale-inferred
|
|
751
|
+
* `defaultCountry` becomes a hard `country` filter on the locality lookup, so the candidate pool is all-US before any
|
|
752
|
+
* comparator runs — the qualifier the parse got RIGHT never reaches the deciding site (the #1729 lesson, measured
|
|
753
|
+
* again here: the DE row is simply not in the list). The coherence passes cannot reach this class either:
|
|
754
|
+
* `applyAdminCoherence` needs the locality to have FAILED, `applyRegionCountryCoherence` expands only the codex US+CA
|
|
755
|
+
* subdivision table, and there is no postcode for #42 to re-scope by.
|
|
756
|
+
*
|
|
757
|
+
* When on, the walk threads the tree's first region-tagged span onto every locality lookup
|
|
758
|
+
* (`FindPlaceQuery.regionQualifier`); a capable backend answers containment from its ancestors sidecar — stamping
|
|
759
|
+
* `ResolvedPlace.containedByQualifier` and ADDING contained same-name candidates a locale-inferred country scope hid
|
|
760
|
+
* — and the walk finishes with a TIER-SAFE stable partition: contained candidates ahead of uncontained ones, within
|
|
761
|
+
* the exact-match tier, preserving each group's relative order. The partition runs AFTER the fame/anchor re-ranks
|
|
762
|
+
* because the qualifier is the address's OWN text — evidence, which outranks a prior (the same precedence
|
|
763
|
+
* `anchorPosterior` holds over `rankByImportance`).
|
|
764
|
+
*
|
|
765
|
+
* Soft by construction: candidates are only ever added or reordered, never dropped, so a qualifier that matches
|
|
766
|
+
* nothing (or contains no same-name candidate) leaves the answer byte-identical. Stands down under an EXPLICIT caller
|
|
767
|
+
* `defaultCountry` (the #912 posture: only a locale-INFERRED scope is bypassable by the address's own evidence). Each
|
|
768
|
+
* locality pick records `metadata.admin_containment`: `"contained"` (the sidecar vouched for at least one candidate),
|
|
769
|
+
* `"no_contained_candidate"` (evaluated, none contained), or `"unavailable"` (the backend or artifact cannot answer —
|
|
770
|
+
* a pre-sidecar candidate.db, the FTS/browser backends) — so an inert lever is visible in the trace rather than
|
|
771
|
+
* silently dead (#1719's rule; the parse-side census cannot see resolver levers, so the stamp is the census surface
|
|
772
|
+
* here).
|
|
773
|
+
*
|
|
774
|
+
* **Default OFF** (D-rule): opt in and measure; the promotion battery is the full board + gauntlet + parity ON/OFF
|
|
775
|
+
* with one declared variable.
|
|
776
|
+
*/
|
|
777
|
+
adminContainmentRerank?: boolean
|
|
778
|
+
/**
|
|
779
|
+
* Resolver-interior trace sink (#1721): when set, the walk emits one {@link ResolveNodeTrace} per candidate lookup —
|
|
780
|
+
* the query as sent, the candidate table with per-stage ranks, every gate that fired, and the pick's provenance — so
|
|
781
|
+
* "the right row was present at rank 3 and lost to the fame term" is a recorded fact instead of a spelunking result.
|
|
782
|
+
* Absent (the default) the walk does ZERO trace bookkeeping and stays byte-identical; the sink is a hot-path opt-in
|
|
783
|
+
* for debug surfaces, never a production default.
|
|
784
|
+
*/
|
|
785
|
+
traceSink?: (record: ResolveNodeTrace) => void
|
|
786
|
+
/**
|
|
787
|
+
* When a lookup resolves NOTHING, re-probe the same value across the other admin bands and record which ones hold it
|
|
788
|
+
* ({@link ResolveNodeTrace.reachableIn}) — a DIAGNOSTIC that never changes the answer.
|
|
789
|
+
*
|
|
790
|
+
* The distinction it buys is the one a `null` cannot carry: a key we hold under a different placetype is a
|
|
791
|
+
* REACHABILITY failure — the model's tag chose the band, and a wrong tag makes a row we own unreachable — while a key
|
|
792
|
+
* that exists nowhere is a coverage fact. Those call for opposite work and today reach a caller identically.
|
|
793
|
+
*
|
|
794
|
+
* Costs one extra backend call per band per miss, so it is off by default and belongs to debug surfaces. Requires
|
|
795
|
+
* `traceSink`: with no sink there is nowhere to record the answer, and the probes would be pure cost.
|
|
796
|
+
*/
|
|
797
|
+
diagnoseUnreachable?: boolean
|
|
821
798
|
}
|
|
822
799
|
|
|
823
800
|
/**
|
|
824
|
-
*
|
|
825
|
-
*
|
|
826
|
-
*
|
|
827
|
-
*
|
|
828
|
-
*
|
|
829
|
-
*
|
|
830
|
-
* - `postcode` lives in a separate WOF shard (Phase 4.3.x follow-up via the postalcode loader).
|
|
831
|
-
* - `street` / `house_number` aren't in WOF admin — would need OSM / OpenAddresses gazetteers and license diligence
|
|
832
|
-
* (Phase 4.4 candidate).
|
|
833
|
-
* - Non-US JP-specific tags wait on a different shard entirely.
|
|
834
|
-
*/
|
|
835
|
-
export type PlacetypeMap = Partial<Record<ComponentTag, string>>
|
|
836
|
-
|
|
837
|
-
/**
|
|
838
|
-
* Placetype equivalences applied when a backend does not supply its own. A `locality` query must also reach `borough`
|
|
839
|
-
* and `localadmin` rows — Brooklyn is a borough, and a strict filter made it unreachable.
|
|
840
|
-
*/
|
|
841
|
-
export const DEFAULT_PLACETYPE_MAP: PlacetypeMap = {
|
|
842
|
-
country: "country",
|
|
843
|
-
region: "region",
|
|
844
|
-
locality: "locality",
|
|
845
|
-
dependent_locality: "locality",
|
|
846
|
-
subregion: "county",
|
|
847
|
-
// `postcode` (mailwoman tag) maps to WOF's `postalcode` placetype. Resolves only when the
|
|
848
|
-
// backend has the postcode shard available — `WOFSqlitePlaceLookup` auto-routes `postalcode`
|
|
849
|
-
// queries to a `postalcode_us` (or similarly-named) shard, falling back to main if absent.
|
|
850
|
-
postcode: "postalcode",
|
|
851
|
-
}
|
|
852
|
-
|
|
853
|
-
/**
|
|
854
|
-
* Placetype-equivalence groups for lookup FILTERING. WOF splits a single addressing tier across several placetypes, but
|
|
855
|
-
* an address's span can name ANY of them. A backend that filters to the one "obvious" placetype makes the equivalents
|
|
856
|
-
* unreachable, so a fuzzy same-name place in the wrong tier wins instead.
|
|
857
|
-
*
|
|
858
|
-
* Three tiers are affected (the value of each entry is the set the SQL filter should accept; the FIRST entry is the
|
|
859
|
-
* canonical/requested type, which shard routing keys off):
|
|
860
|
-
*
|
|
861
|
-
* - **`locality`** — `locality` (most cities), `borough` (Brooklyn, the Paris arrondissements, the London boroughs), and
|
|
862
|
-
* `localadmin` (FR communes, US towns/townships in New England). Without the group, Brooklyn-the-borough (pop 2.5M)
|
|
863
|
-
* was unreachable and the fuzzy "Brooklyn Park, MN" won.
|
|
864
|
-
* - **`region`** — `region` + `macroregion` (#718). WOF does NOT model every country's top-level civil division as
|
|
865
|
-
* `region`: Italian regions (Lombardia, Veneto, Toscana…) are `macroregion` (their PROVINCES are `region`), and the
|
|
866
|
-
* post-2016 French régions (Île-de-France) are `macroregion` too. An address's `region` span names exactly those, so
|
|
867
|
-
* a `region`-only filter resolved them to NOTHING (confirmed against the IT/FR eval rows). US states / DE
|
|
868
|
-
* Bundesländer / ES provincias are genuine `region`, so the EXACT-type match is preferred in ranking (see the
|
|
869
|
-
* resolve.ts fallback-quality annotation) — the macro is the recall safety net, not a demotion.
|
|
870
|
-
* - **`county`** — `county` + `macrocounty` (#718). The `subregion` ComponentTag maps to `county` via
|
|
871
|
-
* {@link DEFAULT_PLACETYPE_MAP}; WOF carries `macrocounty` for FR départements-grouping / DE / GB tiers above the
|
|
872
|
-
* county. Proactive (no eval row exercises `subregion` today) but symmetric with `region` — biasing to inclusion,
|
|
873
|
-
* since a missed resolution costs more than a too-broad candidate (which is QA-visible). Same exact-type preference
|
|
874
|
-
* applies.
|
|
875
|
-
*
|
|
876
|
-
* This table is the single source of truth for that expansion, shared by every lookup backend
|
|
877
|
-
* (`@mailwoman/core/resolver-wof-sqlite`, `@mailwoman/core/resolver-wof-wasm`, and the demo's httpvfs lookup) so the
|
|
878
|
-
* Node and browser resolvers can't drift. Keyed by the REQUESTED placetype. Placetypes without an entry pass through
|
|
879
|
-
* unchanged — an explicit `placetype: "borough"` query stays narrow.
|
|
801
|
+
* One candidate as the resolver's deciding site saw it — the fields the ranking stages actually read, plus a per-stage
|
|
802
|
+
* rank vector. `ranks` carries one entry per stage that RAN, in execution order (`initial` = the backend's own order;
|
|
803
|
+
* then whichever of `anchor`, `locale_prior`, `importance`, `containment`, `exact_type` were active); a stage a
|
|
804
|
+
* candidate set never went through is absent, never defaulted. The vector is what makes loss attributable: the stage
|
|
805
|
+
* whose entry moved a row down is the term it lost to.
|
|
880
806
|
*/
|
|
881
|
-
export
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
807
|
+
export interface ResolveCandidateTrace {
|
|
808
|
+
id: string | number
|
|
809
|
+
name: string
|
|
810
|
+
country: string
|
|
811
|
+
placetype: string
|
|
812
|
+
score: number
|
|
813
|
+
prominence?: number
|
|
814
|
+
importance?: number
|
|
815
|
+
population?: number
|
|
816
|
+
exactMatch?: boolean
|
|
817
|
+
containedByQualifier?: boolean
|
|
818
|
+
ranks: Record<string, number>
|
|
885
819
|
}
|
|
886
820
|
|
|
887
821
|
/**
|
|
888
|
-
*
|
|
889
|
-
*
|
|
822
|
+
* One `ResolveNodeTrace` per backend lookup the walk performed (#1721) — and one per POST-WALK recovery that answers
|
|
823
|
+
* off the walk (`span_rescore`, `postal_compound_recovery`), so no resolved coordinate is off the record. `gates`
|
|
824
|
+
* records mechanism events in execution order, in the resolver's own vocabulary (`parent_fallback_retry`,
|
|
825
|
+
* `region_scope_miss`, `backend_error`, `postcode_format_probe`, `postcode_prefix_prior`, `bare_race`,
|
|
826
|
+
* `empty_admin_pick`, `min_score_reject`, `bare_country_repick`, `bare_region_repick`, `placetype_fallback`). `picked:
|
|
827
|
+
* null` states the lookup resolved nothing — a claim, not an omission. The candidate table is capped
|
|
828
|
+
* ({@link ResolveNodeTrace.candidatesTruncated} counts the tail) so a trace stays a record, not a dump.
|
|
890
829
|
*/
|
|
891
|
-
export
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
if (!out.includes(expanded)) {
|
|
902
|
-
out.push(expanded)
|
|
903
|
-
}
|
|
904
|
-
}
|
|
830
|
+
export interface ResolveNodeTrace {
|
|
831
|
+
tag: string
|
|
832
|
+
value: string
|
|
833
|
+
placetype: string
|
|
834
|
+
query: {
|
|
835
|
+
country?: string
|
|
836
|
+
parentID?: string | number
|
|
837
|
+
postcode?: string
|
|
838
|
+
regionQualifier?: string
|
|
839
|
+
limit: number
|
|
905
840
|
}
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
if (!group) return false
|
|
932
|
-
|
|
933
|
-
if (candidatePlacetype === requestedPlacetype) return false
|
|
934
|
-
|
|
935
|
-
return MACRO_FALLBACK_PLACETYPES.has(candidatePlacetype) && group.includes(candidatePlacetype)
|
|
841
|
+
gates: string[]
|
|
842
|
+
/**
|
|
843
|
+
* Which OTHER admin bands hold this value, probed only when the lookup resolved nothing and
|
|
844
|
+
* {@link ResolveOpts.diagnoseUnreachable} is on.
|
|
845
|
+
*
|
|
846
|
+
* `[]` is a measured absence — every band was asked and none held it, so the miss is coverage. `undefined` means
|
|
847
|
+
* nobody asked, which is a different fact and must not be read as an empty answer.
|
|
848
|
+
*/
|
|
849
|
+
reachableIn?: Array<{ placetype: string; n: number }>
|
|
850
|
+
candidates: ResolveCandidateTrace[]
|
|
851
|
+
candidatesTruncated: number
|
|
852
|
+
picked: {
|
|
853
|
+
id: string | number
|
|
854
|
+
name: string
|
|
855
|
+
source:
|
|
856
|
+
| "ranked"
|
|
857
|
+
| "bare_country"
|
|
858
|
+
| "bare_region"
|
|
859
|
+
| "postcode_prefix"
|
|
860
|
+
| "postcode_format_probe"
|
|
861
|
+
| "empty_admin"
|
|
862
|
+
| "span_rescore"
|
|
863
|
+
| "postal_compound_recovery"
|
|
864
|
+
} | null
|
|
936
865
|
}
|
|
937
866
|
|
|
938
867
|
/**
|
|
@@ -944,10 +873,23 @@ export function isPlacetypeFallback(requestedPlacetype: string, candidatePlacety
|
|
|
944
873
|
*/
|
|
945
874
|
export interface Resolver {
|
|
946
875
|
resolveTree(tree: AddressTree, opts?: ResolveOpts): Promise<AddressTree>
|
|
876
|
+
/**
|
|
877
|
+
* Direct gazetteer probe, passed through from the {@link ResolverBackend} — for pipeline-level consumers that need one
|
|
878
|
+
* lookup outside a tree walk (the #1738 dominant-bearer guard on the coarse placer's hard-country promotion is the
|
|
879
|
+
* first). Optional like the members below: a resolver without it degrades its consumers to their without-the-probe
|
|
880
|
+
* behavior, never to a crash.
|
|
881
|
+
*/
|
|
882
|
+
findPlace?: ResolverBackend["findPlace"]
|
|
947
883
|
/**
|
|
948
884
|
* Facts the loaded gazetteer artifact declares about itself, passed through from the {@link ResolverBackend} so
|
|
949
885
|
* pipeline-level consumers (the hard-country coverage gate, guard-B plausibility) read them from the handle they
|
|
950
886
|
* already hold. Absent = artifact predates the manifest → code-constant fallback.
|
|
951
887
|
*/
|
|
952
888
|
artifactCoverage?: GazetteerArtifactCoverage
|
|
889
|
+
/**
|
|
890
|
+
* Optional backend methods this resolver's backend does not implement, each naming the default-ON option it silently
|
|
891
|
+
* disables. Empty means every default-ON option has the support it needs; absent means the resolver predates the
|
|
892
|
+
* check. See {@link BackendCapabilityGap}.
|
|
893
|
+
*/
|
|
894
|
+
capabilityGaps?: readonly BackendCapabilityGap[]
|
|
953
895
|
}
|