@mailwoman/core 9.0.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 +2 -2
- package/coarse-placer/tools/build-outlier-exposure.ts +2 -2
- package/coarse-placer/tools/build-outlier-latin.ts +14 -8
- package/coarse-placer/tools/build-outlier-oa.ts +12 -6
- package/coarse-placer/tools/eval-latin-offmap.ts +3 -4
- package/coarse-placer/tools/eval-openset.ts +3 -3
- package/coarse-placer/tools/eval-quant-compare.ts +3 -3
- package/coarse-placer/tools/eval.ts +3 -3
- 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 -4
- package/coarse-placer/tools/quantize.ts +3 -2
- package/coarse-placer/tools/train.ts +2 -2
- 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/build-tree.ts +19 -0
- 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 +35 -3
- package/fs/utils/formatters.ts +107 -0
- package/fs/utils/index.ts +7 -0
- package/fs/zip.ts +297 -0
- 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 -2
- package/out/coarse-placer/tools/build-dataset.js.map +1 -1
- package/out/coarse-placer/tools/build-outlier-exposure.js +1 -2
- 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 -8
- 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 -6
- 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 -4
- package/out/coarse-placer/tools/eval-latin-offmap.js.map +1 -1
- package/out/coarse-placer/tools/eval-openset.js +2 -3
- package/out/coarse-placer/tools/eval-openset.js.map +1 -1
- package/out/coarse-placer/tools/eval-quant-compare.js +2 -3
- package/out/coarse-placer/tools/eval-quant-compare.js.map +1 -1
- package/out/coarse-placer/tools/eval.js +2 -3
- 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 -4
- package/out/coarse-placer/tools/probe-frontier.js.map +1 -1
- package/out/coarse-placer/tools/quantize.d.ts.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.js +1 -2
- 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/build-tree.d.ts.map +1 -1
- package/out/decoder/build-tree.js +17 -0
- package/out/decoder/build-tree.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 +13 -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 +12 -1
- package/out/env/schema.d.ts.map +1 -1
- package/out/env/schema.js +33 -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.d.ts +116 -0
- package/out/fs/zip.d.ts.map +1 -0
- package/out/fs/zip.js +216 -0
- package/out/fs/zip.js.map +1 -0
- 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 +3 -7
- package/out/pipeline/index.d.ts.map +1 -1
- package/out/pipeline/index.js +2 -4
- 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 +46 -133
- 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 +137 -16
- package/out/pipeline/types.d.ts.map +1 -1
- package/out/pipeline/types.js +30 -0
- 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 +4 -1
- package/out/resolver/index.d.ts.map +1 -1
- package/out/resolver/index.js +2 -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/referential.d.ts +73 -0
- package/out/resolver/referential.d.ts.map +1 -0
- package/out/resolver/referential.js +71 -0
- package/out/resolver/referential.js.map +1 -0
- package/out/resolver/types.d.ts +401 -264
- 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 +1 -1
- 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 +488 -8
- package/pipeline/index.ts +14 -15
- package/pipeline/runtime-pipeline.ts +48 -184
- package/pipeline/span-proposer.ts +1 -1
- package/pipeline/types.ts +143 -16
- 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 +18 -0
- package/resolver/lookup-types.ts +174 -0
- package/resolver/placetype-map.ts +122 -0
- package/resolver/postcode-format.ts +89 -0
- package/resolver/referential.ts +84 -0
- package/resolver/types.ts +423 -315
- 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 +2 -1
- 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 +5 -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,47 @@ 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
|
|
108
|
+
/**
|
|
109
|
+
* REFERENTIAL likelihood in [0, 1] — population-anchored, the named form of the key namesake ranking has always used
|
|
110
|
+
* (ROAD_TO_V9 §2, ratified 2026-08-06: "the importance of a knowledge-base article is not the probability that this
|
|
111
|
+
* is the place the user means"). Absent when the backend has no population for the place.
|
|
112
|
+
*/
|
|
113
|
+
referential?: number
|
|
114
|
+
/**
|
|
115
|
+
* STRICT encyclopedia-evidence importance in [0, 1] — CARRIED FOR CONSUMERS, NEVER RANKED ON.
|
|
116
|
+
*
|
|
117
|
+
* RESERVED SLOT: it awaits a strict-channel source. Only a backend reading a post-split `place_importance` table can
|
|
118
|
+
* populate it, and today the FTS backend's clauses emit NULL for everything (no shipped admin DB carries the split
|
|
119
|
+
* columns), so nothing produces it and nothing consumes it. The BLENDED prior the ranking reads is
|
|
120
|
+
* {@link ResolvedPlace.importance} — keep the two apart.
|
|
121
|
+
*
|
|
122
|
+
* Ranking on this channel is forbidden even once populated. The canonical reason is Saint-Denis: the
|
|
123
|
+
* Seine-Saint-Denis suburb (pop 96,128) scores 0.1173 while the Aude hamlet (pop 418) scores 0.5683, so ranking on it
|
|
124
|
+
* inverts the answer every user means.
|
|
125
|
+
*
|
|
126
|
+
* Absent means "no encyclopedia entry" OR "this gazetteer predates the two-score split" — both absence, neither 0.
|
|
127
|
+
*/
|
|
128
|
+
encyclopedic?: number
|
|
129
|
+
/**
|
|
130
|
+
* BLENDED global toponym prior in [0, 1] (#28) — the fame key the bare-toponym class is decided on.
|
|
131
|
+
*
|
|
132
|
+
* The value is the score source's legacy blended importance: the concordance's encyclopedia-derived channel where a
|
|
133
|
+
* concordance matched, a population-derived proxy everywhere else. The blend is deliberate — it is the only scale on
|
|
134
|
+
* which EVERY bearer of a name is scored comparably (the strict channel reaches eleven countries and is blind on
|
|
135
|
+
* CA/AU/RU, exactly the homonym contests the prior exists to settle; see `candidate-schema.ts` →
|
|
136
|
+
* `CandidateTable.importance`). Consumed by `rankByImportance` (`resolver/toponym-prior.ts`), a soft tier-safe
|
|
137
|
+
* re-rank, never a gate.
|
|
138
|
+
*
|
|
139
|
+
* Absent means UNMEASURED — the score source had no row, the join refused it, or the artifact predates the column —
|
|
140
|
+
* and an unmeasured candidate holds the rank population gave it (meaning-of-zero: never fill a 0 in).
|
|
141
|
+
*/
|
|
142
|
+
importance?: number
|
|
68
143
|
/**
|
|
69
144
|
* Set by the backend when this candidate is an EXACT name/alias match for the query (vs a partial token match). The
|
|
70
145
|
* postcode-anchor re-rank (#369) uses it as the PRIMARY key so a country posterior can pin the country WITHOUT
|
|
@@ -88,6 +163,23 @@ export interface ResolvedPlace {
|
|
|
88
163
|
* Absent when the exact placetype matched (the normal case).
|
|
89
164
|
*/
|
|
90
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
|
|
91
183
|
}
|
|
92
184
|
|
|
93
185
|
/**
|
|
@@ -97,104 +189,18 @@ export interface ResolvedPlace {
|
|
|
97
189
|
* Structurally compatible with `PlaceLookup` from `@mailwoman/core/resolver-wof-sqlite` so the latter satisfies this
|
|
98
190
|
* interface without an adapter shim.
|
|
99
191
|
*/
|
|
100
|
-
/**
|
|
101
|
-
* One country's measured hard-filter coverage fact, as recorded at a promote gate. Facts about the gazetteer artifact
|
|
102
|
-
* live IN the artifact (the `country_coverage` table the gazetteer build emits) — code constants are only the fallback
|
|
103
|
-
* for artifacts that predate the manifest.
|
|
104
|
-
*
|
|
105
|
-
* Meaning-of-zero discipline: a country ABSENT from the coverage map was never measured — never "measured and failed".
|
|
106
|
-
* A measured-and-failed country is PRESENT with `hardFilterSafe: false` (e.g. FI at 69.5% hard-resolve), so the
|
|
107
|
-
* negative result is a first-class record, distinguishable from ignorance.
|
|
108
|
-
*/
|
|
109
|
-
export interface CountryCoverageFact {
|
|
110
|
-
/**
|
|
111
|
-
* ISO 3166-1 alpha-2, uppercase.
|
|
112
|
-
*/
|
|
113
|
-
country: string
|
|
114
|
-
/**
|
|
115
|
-
* The promote-gate VERDICT: hard-filtering this country is a pure win (a hard-filter miss is almost always a genuine
|
|
116
|
-
* non-match, not a coverage gap). Stored as a verdict — not re-derived from `hardResolveRate` at read time — because
|
|
117
|
-
* the gate is a judgment over a panel, not a pure rate function (CA cleared at the #928 promote on the
|
|
118
|
-
* postcode-format-prior rationale despite a sub-95% panel resolve rate).
|
|
119
|
-
*/
|
|
120
|
-
hardFilterSafe: boolean
|
|
121
|
-
/**
|
|
122
|
-
* Measured hard-resolve rate (0..1) on the panel named in `source`, when the receipt recorded one.
|
|
123
|
-
*/
|
|
124
|
-
hardResolveRate?: number
|
|
125
|
-
/**
|
|
126
|
-
* Panel size behind `hardResolveRate`, when recorded.
|
|
127
|
-
*/
|
|
128
|
-
sampleSize?: number
|
|
129
|
-
/**
|
|
130
|
-
* ISO-8601 date of the measurement / promote gate.
|
|
131
|
-
*/
|
|
132
|
-
measuredAt: string
|
|
133
|
-
/**
|
|
134
|
-
* The receipt: which panel/gate produced this row (issue + date, human-readable).
|
|
135
|
-
*/
|
|
136
|
-
source: string
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* One country's coarse guard-B bounding box, as carried by the gazetteer artifact's `country_bbox` table.
|
|
141
|
-
*/
|
|
142
|
-
export interface CountryBBoxFact {
|
|
143
|
-
/**
|
|
144
|
-
* ISO 3166-1 alpha-2, uppercase.
|
|
145
|
-
*/
|
|
146
|
-
country: string
|
|
147
|
-
latMin: number
|
|
148
|
-
latMax: number
|
|
149
|
-
lonMin: number
|
|
150
|
-
lonMax: number
|
|
151
|
-
/**
|
|
152
|
-
* Provenance of the box (harness + date).
|
|
153
|
-
*/
|
|
154
|
-
source: string
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Facts a loaded gazetteer artifact declares about itself — read from the artifact's own manifest tables at open time,
|
|
159
|
-
* carried on the {@link ResolverBackend}/{@link Resolver} handle so consumers read the facts from the artifact they are
|
|
160
|
-
* actually resolving against. `undefined` on the handle = the artifact predates the manifest → consumers fall back to
|
|
161
|
-
* the code constants (byte-identical legacy behavior).
|
|
162
|
-
*/
|
|
163
|
-
export interface GazetteerArtifactCoverage {
|
|
164
|
-
/**
|
|
165
|
-
* Country → measured coverage fact. ABSENCE = never measured (meaning-of-zero), never "failed".
|
|
166
|
-
*/
|
|
167
|
-
countryCoverage: ReadonlyMap<string, CountryCoverageFact>
|
|
168
|
-
/**
|
|
169
|
-
* Country → guard-B bbox. ABSENCE = no box → the plausibility guard fails open for that country.
|
|
170
|
-
*/
|
|
171
|
-
countryBBoxes: ReadonlyMap<string, CountryBBoxFact>
|
|
172
|
-
/**
|
|
173
|
-
* Derived at load: the countries whose fact says `hardFilterSafe` — the artifact's hard-country safelist.
|
|
174
|
-
*/
|
|
175
|
-
hardCountrySafelist: ReadonlySet<string>
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Derive the hard-country safelist from coverage facts — the ONE derivation both the reader and the build share.
|
|
180
|
-
*/
|
|
181
|
-
export function hardCountrySafelistFromCoverage(facts: Iterable<CountryCoverageFact>): ReadonlySet<string> {
|
|
182
|
-
const out = new Set<string>()
|
|
183
|
-
|
|
184
|
-
for (const fact of facts) {
|
|
185
|
-
if (fact.hardFilterSafe) {
|
|
186
|
-
out.add(fact.country.toUpperCase())
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
return out
|
|
191
|
-
}
|
|
192
192
|
|
|
193
193
|
export interface ResolverBackend {
|
|
194
194
|
findPlace(query: {
|
|
195
195
|
text: string
|
|
196
196
|
placetype?: string | string[]
|
|
197
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
|
|
198
204
|
parentID?: number | string
|
|
199
205
|
/**
|
|
200
206
|
* Sibling postcode string, when the address carries one. A coordinate-first backend uses it to inject
|
|
@@ -202,10 +208,43 @@ export interface ResolverBackend {
|
|
|
202
208
|
* recovering localities the name-match alone misses. Backends without postcode support ignore it.
|
|
203
209
|
*/
|
|
204
210
|
postcode?: string
|
|
211
|
+
/**
|
|
212
|
+
* Postcode-containment coherence (#31, Mechanism 2) — when set, a coordinate-first backend may re-rank locality
|
|
213
|
+
* candidates by distance to the sibling postcode's own centroid (bounded by a 25 km containment gate) instead of
|
|
214
|
+
* answering blind population-first. Opt-in, strictly beneath the #741 exact `(name_key, postcode)` probe; backends
|
|
215
|
+
* without postcode support ignore it.
|
|
216
|
+
*/
|
|
217
|
+
postcodeContainmentCoherence?: boolean
|
|
205
218
|
/**
|
|
206
219
|
* Proximity-bias points — a SOFT prominence re-rank; backends without support ignore it.
|
|
207
220
|
*/
|
|
208
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
|
|
209
248
|
limit?: number
|
|
210
249
|
}): Promise<ResolvedPlace[]>
|
|
211
250
|
/**
|
|
@@ -229,6 +268,36 @@ export interface ResolverBackend {
|
|
|
229
268
|
artifactCoverage?: GazetteerArtifactCoverage
|
|
230
269
|
}
|
|
231
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
|
+
|
|
232
301
|
/**
|
|
233
302
|
* One link in a resolved place's containment lineage ({@link ResolverBackend.ancestors}, #404).
|
|
234
303
|
*/
|
|
@@ -260,119 +329,6 @@ export interface CoincidentLocality extends ResolvedPlace {
|
|
|
260
329
|
/**
|
|
261
330
|
* Options for `resolveTree`. All optional with sensible defaults.
|
|
262
331
|
*/
|
|
263
|
-
/**
|
|
264
|
-
* One exact address-point hit (#476): a real situs coordinate for `(street, number)` within a postcode/locality scope —
|
|
265
|
-
* the street-level tier in front of admin-centroid resolution.
|
|
266
|
-
*/
|
|
267
|
-
export interface AddressPointHit {
|
|
268
|
-
lat: number
|
|
269
|
-
lon: number
|
|
270
|
-
/**
|
|
271
|
-
* Provenance, e.g. `"overture:NAD"`.
|
|
272
|
-
*/
|
|
273
|
-
source: string
|
|
274
|
-
/**
|
|
275
|
-
* Pinned data release the point came from, e.g. `"2026-05-20.0"`.
|
|
276
|
-
*/
|
|
277
|
-
release: string
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
/**
|
|
281
|
-
* Street-level exact-point lookup (#476). Implementations own their normalization — both the shard build and this
|
|
282
|
-
* lookup must apply the SAME normalizer (see `resolver-wof-sqlite/street-normalize.ts`). Core depends only on this
|
|
283
|
-
* contract.
|
|
284
|
-
*/
|
|
285
|
-
export interface AddressPointLookup {
|
|
286
|
-
find(query: {
|
|
287
|
-
street: string
|
|
288
|
-
number: string
|
|
289
|
-
postcode?: string
|
|
290
|
-
locality?: string
|
|
291
|
-
/**
|
|
292
|
-
* Optional bbox scope (`minLat`/`maxLat`/`minLon`/`maxLon`), tried AFTER postcode/locality. For shards whose points
|
|
293
|
-
* carry no postcode/locality of their own (OSM addr nodes often don't) but DO carry a coordinate — the resolved
|
|
294
|
-
* locality's bounding box scopes the `(street, number)` probe instead. US situs never passes it (byte-stable).
|
|
295
|
-
*/
|
|
296
|
-
bbox?: { minLat: number; maxLat: number; minLon: number; maxLon: number }
|
|
297
|
-
}): AddressPointHit | null
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
/**
|
|
301
|
-
* One interpolated coordinate estimate (#483) — NEVER an exact situs point (`uncertaintyM` prices the estimate
|
|
302
|
-
* honestly). Structural mirror of `InterpolatedHit` in `resolver-wof-sqlite/interpolation.ts`; keep this a SUBSET of
|
|
303
|
-
* that shape so the concrete `StreetInterpolator`/`AddressPointInterpolator` satisfy {@link InterpolationLookup} with no
|
|
304
|
-
* adapter (the {@link AddressPointHit} precedent).
|
|
305
|
-
*/
|
|
306
|
-
export interface InterpolatedPointHit {
|
|
307
|
-
lat: number
|
|
308
|
-
lon: number
|
|
309
|
-
interpolated: true
|
|
310
|
-
/**
|
|
311
|
-
* `address_point` = bracketed between real neighbor points; `tiger_range` = linear within a segment range.
|
|
312
|
-
*/
|
|
313
|
-
method: "address_point" | "tiger_range"
|
|
314
|
-
/**
|
|
315
|
-
* False when only the opposite side's range contained the number (right block, wrong side).
|
|
316
|
-
*/
|
|
317
|
-
parityMatched?: boolean
|
|
318
|
-
/**
|
|
319
|
-
* `both` = neighbors bracketed it; `single` = one-sided extrapolation (larger uncertainty).
|
|
320
|
-
*/
|
|
321
|
-
bracket?: "both" | "single"
|
|
322
|
-
/**
|
|
323
|
-
* Honest uncertainty radius in METERS (half the matched segment length).
|
|
324
|
-
*/
|
|
325
|
-
uncertaintyM: number
|
|
326
|
-
source: string
|
|
327
|
-
release: string
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
/**
|
|
331
|
-
* House-number interpolation lookup (#483). Like {@link AddressPointLookup}, implementations own their normalization
|
|
332
|
-
* (the shared `resolver-wof-sqlite/street-normalize.ts`); core depends only on this contract. Postcode-scoped (no
|
|
333
|
-
* locality field) — the tier abstains statewide without a postcode.
|
|
334
|
-
*/
|
|
335
|
-
export interface InterpolationLookup {
|
|
336
|
-
find(query: { street: string; number: string; postcode?: string }): InterpolatedPointHit | null
|
|
337
|
-
/**
|
|
338
|
-
* The ARTIFACT's own conformal radius multiplier for `uncertaintyM` (#374), read from the shard's
|
|
339
|
-
* `interp_calibration` metadata table at open time (the pair-index δ/transitionBeta header precedent): the multiplier
|
|
340
|
-
* is a property of the calibration set the artifact was built against, so it ships in the artifact, not in caller
|
|
341
|
-
* code. The resolver applies it as the DEFAULT whenever `ResolveOpts.interpolationRadiusCalibration` is absent.
|
|
342
|
-
* `undefined` (or an implementation without the property) = the artifact carries none — shards built before the
|
|
343
|
-
* metadata table existed; behavior is then exactly the pre-artifact ladder (caller-supplied factor or raw).
|
|
344
|
-
* Implementations must read this at OPEN time (constructor/factory), never per-lookup — `find()` is synchronous by
|
|
345
|
-
* design.
|
|
346
|
-
*/
|
|
347
|
-
readonly radiusCalibration?: number
|
|
348
|
-
}
|
|
349
|
-
|
|
350
|
-
/**
|
|
351
|
-
* One street-CENTROID hit (#1042) — the street-level tier BELOW the exact address-point tier and ABOVE admin-centroid
|
|
352
|
-
* resolution. A street's centroid + an honest extent-derived radius, for a street-only query (no house number) that an
|
|
353
|
-
* address-point tier cannot serve by definition. Derived from a national register's rooftop points
|
|
354
|
-
* (`street-centroids-<cc>.db`, a `GROUP BY street` roll-up). `uncertaintyM` prices the coarseness (half the street's
|
|
355
|
-
* bbox diagonal) so a consumer never mistakes it for a rooftop.
|
|
356
|
-
*/
|
|
357
|
-
export interface StreetCentroidHit {
|
|
358
|
-
lat: number
|
|
359
|
-
lon: number
|
|
360
|
-
/**
|
|
361
|
-
* Honest coarse radius in METERS — half the street's bounding-box diagonal.
|
|
362
|
-
*/
|
|
363
|
-
uncertaintyM: number
|
|
364
|
-
source: string
|
|
365
|
-
release: string
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
/**
|
|
369
|
-
* Street-centroid lookup (#1042). Like {@link AddressPointLookup}, implementations own their normalization (the shared
|
|
370
|
-
* `resolver-wof-sqlite/street-normalize.ts`); core depends only on this contract. Scoped by `postcode` (preferred) or
|
|
371
|
-
* `locality` (the base commune) — NO house number: this is the street-only tier.
|
|
372
|
-
*/
|
|
373
|
-
export interface StreetCentroidLookup {
|
|
374
|
-
find(query: { street: string; postcode?: string; locality?: string }): StreetCentroidHit | null
|
|
375
|
-
}
|
|
376
332
|
|
|
377
333
|
export interface ResolveOpts {
|
|
378
334
|
/**
|
|
@@ -398,6 +354,23 @@ export interface ResolveOpts {
|
|
|
398
354
|
* overrides it deeper in the tree.
|
|
399
355
|
*/
|
|
400
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
|
|
401
374
|
/**
|
|
402
375
|
* Ordered proximity-bias points (viewport center first, then user location, …), each optionally weighted (default
|
|
403
376
|
* 1.0). SOFT ranking signal only — candidates near a bias point win prominence ties (the ambiguous-postcode case:
|
|
@@ -440,6 +413,46 @@ export interface ResolveOpts {
|
|
|
440
413
|
* Only consulted when `anchorPosterior` is set.
|
|
441
414
|
*/
|
|
442
415
|
anchorWeight?: number
|
|
416
|
+
/**
|
|
417
|
+
* #27 — the LOCALE's country as a SOFT ranking prior on the admin walk, for the one query shape that has no other
|
|
418
|
+
* country signal: a bare toponym.
|
|
419
|
+
*
|
|
420
|
+
* `--locale en-GB "Whitby"` and `--default-country GB "Whitby"` should not disagree, and they do: the second is gold
|
|
421
|
+
* and the first answers Whitby, Ontario, 5,508 km away. The #912 guard in the CLI is why — it drops the
|
|
422
|
+
* locale-inferred country entirely for a bare-locality tree, because as a HARD filter that country is a disaster
|
|
423
|
+
* (`--locale en-US "Zürich"` hard-scoped to US returns Zurich, Kansas, population 81). Dropping it is the right call
|
|
424
|
+
* for a filter and the wrong call for a prior, and this field is the third option: `rankByCountryPrior`
|
|
425
|
+
* (`resolver/toponym-prior.ts`) adds {@link localeCountryPriorWeight} to an in-country candidate's prominence, within
|
|
426
|
+
* the exact tier, never as a filter.
|
|
427
|
+
*
|
|
428
|
+
* **Undefined by default, and the CLI leaves it undefined** — this is an OPT-IN lever (`--locale-country-prior`), not
|
|
429
|
+
* a shipped default, and the reason is measured rather than cautious. In log10-population units the weight needed to
|
|
430
|
+
* flip the four bare GB panel rows is ≥ 0.99 (Whitby CA 5.11 over GB 4.12), and the weight that leaves the en-US
|
|
431
|
+
* board intact is < 0.07 (Cambridge CA 5.14 over US 5.07). The two intervals are disjoint, and they interleave:
|
|
432
|
+
* `Athens` (GR over US, gap 0.38) and `Cambridge` (0.07) sit BELOW `Warwick` (0.41) and `Epping` (0.41), so no
|
|
433
|
+
* threshold, margin or rank rule separates the class either. Population plus a locale cannot answer this question.
|
|
434
|
+
* The key that can is `importance` — the blended global toponym prior, which ranks all four the right way round and
|
|
435
|
+
* whose consumer (`rankByImportance`) is already wired here; the #28 candidate build produces it. See
|
|
436
|
+
* `scratchpad/resolver-plumbing-receipt-2026-08-10.md`.
|
|
437
|
+
*
|
|
438
|
+
* Ignored whenever a {@link defaultCountry} or an {@link anchorPosterior} is in force: a hard scope makes the prior a
|
|
439
|
+
* no-op by construction, and a posterior derived from the address's own postcode is EVIDENCE, which outranks a guess
|
|
440
|
+
* about where the user is sitting.
|
|
441
|
+
*/
|
|
442
|
+
localeCountryPrior?: string
|
|
443
|
+
/**
|
|
444
|
+
* Weight of {@link localeCountryPrior}, in log10(population + 1) — the candidate backend's own `prominence` scale.
|
|
445
|
+
* Default `DEFAULT_COUNTRY_PRIOR_WEIGHT` (2): "the in-country place may be up to 100x smaller and still win". Only
|
|
446
|
+
* consulted when `localeCountryPrior` is set.
|
|
447
|
+
*/
|
|
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
|
|
443
456
|
/**
|
|
444
457
|
* #743/#194 — a CONFIDENT coarse-placer country applied as a HARD candidate filter (`query.country`), not the soft
|
|
445
458
|
* {@link anchorPosterior} boost. This collapses the off-continent tail for LOW-population places the soft prior can't
|
|
@@ -626,6 +639,69 @@ export interface ResolveOpts {
|
|
|
626
639
|
* returned identical verdicts at 15, 25 and 50, so the pass is not gate-tuned).
|
|
627
640
|
*/
|
|
628
641
|
postcodeCountryCoherenceGateKm?: number
|
|
642
|
+
/**
|
|
643
|
+
* Postcode-shape coherence (#31, Mechanism 1, `resolver/postcode-shape-coherence.ts`) — shape as CONFIDENCE and
|
|
644
|
+
* EXCLUSION, downstream of the siblings. The decoder sometimes tags a HOUSE NUMBER as `postcode` when its digits form
|
|
645
|
+
* a foreign postcode shape ("1200" in a Longmont CO address is accepted only by the AU/NZ 4-digit shape while every
|
|
646
|
+
* sibling placetype says US). This pre-walk pass intersects each postcode span's codex candidate systems with the
|
|
647
|
+
* systems the tree's country / region / `country_hint` siblings assert: a non-empty intersection CONFIRMS the span
|
|
648
|
+
* (additive `postcode_shape_systems` stamp, byte-identical resolution); an empty intersection with confident siblings
|
|
649
|
+
* EXCLUDES it (a digit-only span is demoted to `house_number`, a letter-bearing one keeps its tag with a
|
|
650
|
+
* `postcode_shape_excluded` stamp — either way the span's contribution to the resolve is stripped); no confident
|
|
651
|
+
* siblings ABSTAIN. `defaultCountry` is never evidence (B1-3's confound: "Sydney NSW 2000, Australia" reached with a
|
|
652
|
+
* US default must not have its 2000 excluded — that row is exactly what {@link postcodeCountryCoherence} rescues).
|
|
653
|
+
* Confirmed spans narrow the country-scope pass's candidate list to the intersection (a pure subset, safe).
|
|
654
|
+
*
|
|
655
|
+
* **Default OFF** (D-rule: demotion is the failure mode with teeth — a default-on promotion needs the full B1 gate
|
|
656
|
+
* set from `docs/superpowers/plans/2026-08-05-postcode-structure-arc.md`: B1-1 byte-stability, B1-2 exclusion board
|
|
657
|
+
* ≥90% with the correct sibling tag surviving, B1-3 confound ≤2% false exclusions, kill on any δ).
|
|
658
|
+
*/
|
|
659
|
+
postcodeShapeCoherence?: boolean
|
|
660
|
+
/**
|
|
661
|
+
* Postcode-containment coherence (#31, Mechanism 2) — the reverse arrow, generalized. When a locality-wanting query
|
|
662
|
+
* carries a postcode and the #741 exact `(name_key, postcode)` probe misses, a coordinate-first backend resolves the
|
|
663
|
+
* postcode's centroid once and re-ranks the name candidates by distance to it, bounded by a 25 km containment gate —
|
|
664
|
+
* "Paris TX 75460" and "Paris 75001" differ by which candidate the postcode is near, and the population ranking
|
|
665
|
+
* cannot see that. Strictly beneath the #741 short-circuit (B2-1: byte-identical wherever the fast path fires); no
|
|
666
|
+
* in-gate candidate → unchanged (B2-2's postcode-removed arm). Rides `FindPlaceQuery.postcodeContainmentCoherence` to
|
|
667
|
+
* the backend.
|
|
668
|
+
*
|
|
669
|
+
* **Default OFF.** The promotion decision must measure it JOINTLY with {@link postcodeConsistency} (B2-3: the arms
|
|
670
|
+
* agree on ≥98%), because this rung partially subsumes #370 — the compliant outcome may be that mechanism 2 replaces
|
|
671
|
+
* it rather than joining it. B2-4: one postcode lookup per locality miss, ≤15% p95 latency.
|
|
672
|
+
*/
|
|
673
|
+
postcodeContainmentCoherence?: boolean
|
|
674
|
+
/**
|
|
675
|
+
* Postcode-prefix prior (#31, Mechanism 3) — the partial-code prior for postcodes the full-code gazetteer does not
|
|
676
|
+
* carry (#1480's abstention, e.g. a BT unit with no permissive source behind it). When a `postalcode` lookup misses
|
|
677
|
+
* AND a {@link postcodePrefixIndex} for the query's country is supplied, derive the code's prefix (GB: outward — the
|
|
678
|
+
* compact form minus its trailing 3 unit chars; US: the first 3 digits) and probe the index. A hit resolves the node
|
|
679
|
+
* from the prefix's centroid and/or ancestry: `metadata.postcode_prefix`, `postcode_prefix_ancestors` (+
|
|
680
|
+
* `postcode_prefix_radius_p95_km` when the artifact measured one), and `coordinate_source: "postcode_prefix"` only
|
|
681
|
+
* when the node actually carries a coordinate — an ancestry-only tier (NI's 80 BT districts) contributes its DISTRICT
|
|
682
|
+
* and stays coordinate-free (the meaning-of-zero rule; inventing a BT centroid would reproduce the `BT3 9QQ` →
|
|
683
|
+
* Sheffield defect #1480 just fixed).
|
|
684
|
+
*
|
|
685
|
+
* **Default OFF** (D-rule + the PCN1 posture: data + loader + offline probe, no decode wiring; the header ships
|
|
686
|
+
* without `delta` until a calibration measures one). B3-5: the probe touches zero model inputs — the index is a
|
|
687
|
+
* structural type (`PostcodePrefixIndexLike`), injected, never imported from `@mailwoman/neural`.
|
|
688
|
+
*/
|
|
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[]
|
|
698
|
+
/**
|
|
699
|
+
* The PFX1 postcode-prefix index to probe when {@link postcodePrefixPrior} is on — injected by the pipeline (loaded
|
|
700
|
+
* from `$MAILWOMAN_DATA_ROOT/postcode-prefix/postcode-prefix-<cc>.bin`), never constructed here. Structural
|
|
701
|
+
* (`PostcodePrefixIndexLike`), so the resolver consumes an index built in `@mailwoman/neural` without depending on it
|
|
702
|
+
* (B3-5).
|
|
703
|
+
*/
|
|
704
|
+
postcodePrefixIndex?: PostcodePrefixIndexLike
|
|
629
705
|
/**
|
|
630
706
|
* Admin descendant-consistency (#263). When a region resolved but its child locality did NOT — the greedy region pick
|
|
631
707
|
* (name + population) chose a foreign namesake whose descendants hold no such locality ("Portland, ME" → Messina IT;
|
|
@@ -639,11 +715,28 @@ export interface ResolveOpts {
|
|
|
639
715
|
* or the backend lacks `ancestors`. Pass `false` to opt out.
|
|
640
716
|
*/
|
|
641
717
|
adminCoherence?: boolean
|
|
642
|
-
hierarchyCompletion?: boolean
|
|
643
718
|
/**
|
|
644
|
-
*
|
|
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.
|
|
645
738
|
*/
|
|
646
|
-
|
|
739
|
+
hierarchyCompletion?: boolean
|
|
647
740
|
/**
|
|
648
741
|
* Attach each resolved node's ancestor lineage (#404) — the containment chain (county → region → country) the
|
|
649
742
|
* backend's {@link ResolverBackend.ancestors} returns — onto `metadata.ancestors`. The Pelias/Nominatim
|
|
@@ -652,121 +745,123 @@ export interface ResolveOpts {
|
|
|
652
745
|
* resolver actually resolved.
|
|
653
746
|
*/
|
|
654
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
|
|
655
798
|
}
|
|
656
799
|
|
|
657
800
|
/**
|
|
658
|
-
*
|
|
659
|
-
*
|
|
660
|
-
*
|
|
661
|
-
*
|
|
662
|
-
*
|
|
663
|
-
*
|
|
664
|
-
* - `postcode` lives in a separate WOF shard (Phase 4.3.x follow-up via the postalcode loader).
|
|
665
|
-
* - `street` / `house_number` aren't in WOF admin — would need OSM / OpenAddresses gazetteers and license diligence
|
|
666
|
-
* (Phase 4.4 candidate).
|
|
667
|
-
* - Non-US JP-specific tags wait on a different shard entirely.
|
|
668
|
-
*/
|
|
669
|
-
export type PlacetypeMap = Partial<Record<ComponentTag, string>>
|
|
670
|
-
|
|
671
|
-
/**
|
|
672
|
-
* Placetype equivalences applied when a backend does not supply its own. A `locality` query must also reach `borough`
|
|
673
|
-
* and `localadmin` rows — Brooklyn is a borough, and a strict filter made it unreachable.
|
|
674
|
-
*/
|
|
675
|
-
export const DEFAULT_PLACETYPE_MAP: PlacetypeMap = {
|
|
676
|
-
country: "country",
|
|
677
|
-
region: "region",
|
|
678
|
-
locality: "locality",
|
|
679
|
-
dependent_locality: "locality",
|
|
680
|
-
subregion: "county",
|
|
681
|
-
// `postcode` (mailwoman tag) maps to WOF's `postalcode` placetype. Resolves only when the
|
|
682
|
-
// backend has the postcode shard available — `WOFSqlitePlaceLookup` auto-routes `postalcode`
|
|
683
|
-
// queries to a `postalcode_us` (or similarly-named) shard, falling back to main if absent.
|
|
684
|
-
postcode: "postalcode",
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
/**
|
|
688
|
-
* Placetype-equivalence groups for lookup FILTERING. WOF splits a single addressing tier across several placetypes, but
|
|
689
|
-
* an address's span can name ANY of them. A backend that filters to the one "obvious" placetype makes the equivalents
|
|
690
|
-
* unreachable, so a fuzzy same-name place in the wrong tier wins instead.
|
|
691
|
-
*
|
|
692
|
-
* Three tiers are affected (the value of each entry is the set the SQL filter should accept; the FIRST entry is the
|
|
693
|
-
* canonical/requested type, which shard routing keys off):
|
|
694
|
-
*
|
|
695
|
-
* - **`locality`** — `locality` (most cities), `borough` (Brooklyn, the Paris arrondissements, the London boroughs), and
|
|
696
|
-
* `localadmin` (FR communes, US towns/townships in New England). Without the group, Brooklyn-the-borough (pop 2.5M)
|
|
697
|
-
* was unreachable and the fuzzy "Brooklyn Park, MN" won.
|
|
698
|
-
* - **`region`** — `region` + `macroregion` (#718). WOF does NOT model every country's top-level civil division as
|
|
699
|
-
* `region`: Italian regions (Lombardia, Veneto, Toscana…) are `macroregion` (their PROVINCES are `region`), and the
|
|
700
|
-
* post-2016 French régions (Île-de-France) are `macroregion` too. An address's `region` span names exactly those, so
|
|
701
|
-
* a `region`-only filter resolved them to NOTHING (confirmed against the IT/FR eval rows). US states / DE
|
|
702
|
-
* Bundesländer / ES provincias are genuine `region`, so the EXACT-type match is preferred in ranking (see the
|
|
703
|
-
* resolve.ts fallback-quality annotation) — the macro is the recall safety net, not a demotion.
|
|
704
|
-
* - **`county`** — `county` + `macrocounty` (#718). The `subregion` ComponentTag maps to `county` via
|
|
705
|
-
* {@link DEFAULT_PLACETYPE_MAP}; WOF carries `macrocounty` for FR départements-grouping / DE / GB tiers above the
|
|
706
|
-
* county. Proactive (no eval row exercises `subregion` today) but symmetric with `region` — biasing to inclusion,
|
|
707
|
-
* since a missed resolution costs more than a too-broad candidate (which is QA-visible). Same exact-type preference
|
|
708
|
-
* applies.
|
|
709
|
-
*
|
|
710
|
-
* This table is the single source of truth for that expansion, shared by every lookup backend
|
|
711
|
-
* (`@mailwoman/core/resolver-wof-sqlite`, `@mailwoman/core/resolver-wof-wasm`, and the demo's httpvfs lookup) so the
|
|
712
|
-
* Node and browser resolvers can't drift. Keyed by the REQUESTED placetype. Placetypes without an entry pass through
|
|
713
|
-
* 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.
|
|
714
806
|
*/
|
|
715
|
-
export
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
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>
|
|
719
819
|
}
|
|
720
820
|
|
|
721
821
|
/**
|
|
722
|
-
*
|
|
723
|
-
*
|
|
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.
|
|
724
829
|
*/
|
|
725
|
-
export
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
if (!out.includes(expanded)) {
|
|
736
|
-
out.push(expanded)
|
|
737
|
-
}
|
|
738
|
-
}
|
|
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
|
|
739
840
|
}
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
if (!group) return false
|
|
766
|
-
|
|
767
|
-
if (candidatePlacetype === requestedPlacetype) return false
|
|
768
|
-
|
|
769
|
-
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
|
|
770
865
|
}
|
|
771
866
|
|
|
772
867
|
/**
|
|
@@ -778,10 +873,23 @@ export function isPlacetypeFallback(requestedPlacetype: string, candidatePlacety
|
|
|
778
873
|
*/
|
|
779
874
|
export interface Resolver {
|
|
780
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"]
|
|
781
883
|
/**
|
|
782
884
|
* Facts the loaded gazetteer artifact declares about itself, passed through from the {@link ResolverBackend} so
|
|
783
885
|
* pipeline-level consumers (the hard-country coverage gate, guard-B plausibility) read them from the handle they
|
|
784
886
|
* already hold. Absent = artifact predates the manifest → code-constant fallback.
|
|
785
887
|
*/
|
|
786
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[]
|
|
787
895
|
}
|