@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
|
@@ -12,16 +12,12 @@
|
|
|
12
12
|
* Implementation contract per `docs/engineering/reference/STAGES.md`.
|
|
13
13
|
*/
|
|
14
14
|
|
|
15
|
+
import { isBareTreeOf } from "../decoder/tree-shape.ts"
|
|
15
16
|
import type { AddressNode, AddressTree } from "../decoder/types.ts"
|
|
16
17
|
import type { ComponentTag } from "../types/component.ts"
|
|
17
|
-
import { prefetchReconcileLookups } from "./reconcile-lookups.ts"
|
|
18
|
-
import type { ClassifierCandidate } from "./reconcile.ts"
|
|
19
|
-
import { reconcileSpans } from "./reconcile.ts"
|
|
20
|
-
import { aggregateSpanLogits } from "./span-logit-aggregation.ts"
|
|
21
18
|
import { PipelineFaultStage, WORD_CONSISTENCY_SHIP_DEFAULT, deriveInputMode } from "./types.ts"
|
|
22
19
|
import type {
|
|
23
20
|
AddressClassifier,
|
|
24
|
-
ClassifierOpts,
|
|
25
21
|
FSTMatcherLike,
|
|
26
22
|
InputMode,
|
|
27
23
|
LocaleHint,
|
|
@@ -74,7 +70,7 @@ function isPostcodeFormat(format: string): boolean {
|
|
|
74
70
|
* whole-string country guess is a broader, softer signal than a postcode that pins the country, so it blends more
|
|
75
71
|
* gently with the candidate score.
|
|
76
72
|
*/
|
|
77
|
-
const COARSE_PLACER_ANCHOR_WEIGHT = 1
|
|
73
|
+
export const COARSE_PLACER_ANCHOR_WEIGHT = 1
|
|
78
74
|
|
|
79
75
|
/**
|
|
80
76
|
* #194: minimum placer confidence to promote the soft country prior to a HARD filter (empty→unresolved). The placer
|
|
@@ -127,20 +123,20 @@ export const HARD_PLACE_COUNTRY_SAFELIST: ReadonlySet<string> = new Set([
|
|
|
127
123
|
* runs as before.
|
|
128
124
|
*/
|
|
129
125
|
export function isBareLocalityTree(tree: AddressTree): boolean {
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
while (stack.length) {
|
|
134
|
-
const node = stack.pop()!
|
|
135
|
-
|
|
136
|
-
if (node.tag === "locality") {
|
|
137
|
-
sawLocality = true
|
|
138
|
-
} else if (node.value.trim() !== "") return false
|
|
139
|
-
|
|
140
|
-
stack.push(...node.children)
|
|
141
|
-
}
|
|
126
|
+
return isBareTreeOf(tree, "locality")
|
|
127
|
+
}
|
|
142
128
|
|
|
143
|
-
|
|
129
|
+
/**
|
|
130
|
+
* #1589's sibling of the #912 guard: true when the tree's ONLY value-bearing node is a `postcode`.
|
|
131
|
+
*
|
|
132
|
+
* A bare postcode under a locale-inferred country scope is the same disaster shape as a bare locality: `SW1A 1AA` under
|
|
133
|
+
* the default en-US locale gets a HARD `defaultCountry: "US"` that filters the GB postalcode row the gazetteer holds,
|
|
134
|
+
* and the query resolves to nothing — while the identical query under `--locale en-GB` answers 38 m from the rooftop.
|
|
135
|
+
* The postcode's own FORMAT is harder evidence than the locale hint (the #928 table's premise), so the caller withholds
|
|
136
|
+
* the inferred scope for this shape when the format implies countries that exclude it.
|
|
137
|
+
*/
|
|
138
|
+
export function isBarePostcodeTree(tree: AddressTree): boolean {
|
|
139
|
+
return isBareTreeOf(tree, "postcode")
|
|
144
140
|
}
|
|
145
141
|
|
|
146
142
|
/**
|
|
@@ -475,104 +471,8 @@ export async function runPipeline(
|
|
|
475
471
|
}
|
|
476
472
|
|
|
477
473
|
let tree: AddressTree = { raw: normalized.normalized, roots: [] }
|
|
478
|
-
// Captured from the joint-reconcile path so the grouper-audit can defer to the classifier's
|
|
479
|
-
// per-span verdict on orphaned spans (see the assignment + grouperAudit below).
|
|
480
|
-
let auditClassifierTopK: ClassifierCandidate[] | undefined
|
|
481
|
-
|
|
482
|
-
// Joint-reconcile path: RETIRED AS DEFAULT 2026-06-14 (#427 promoted it; this de-promotes it).
|
|
483
|
-
// A reconcile-vs-raw-neural audit on two non-circular US holdouts (Travis E-911 + 7-state
|
|
484
|
-
// OpenAddresses) found it BREAKS the street+house_number geocode precondition on 77-84% of clean
|
|
485
|
-
// US addresses and fixes 0% — the phrase grouper bundles the house number into the STREET_PHRASE
|
|
486
|
-
// ("3075 Hill Street") and reconcileSpans then fuses the whole span into one node, leaving no
|
|
487
|
-
// separate `street`. Confirmed on golden v0.1.2 US+FR (n=4507, per-tag recall vs raw argmax):
|
|
488
|
-
// street -25.6pp, house_number -23.1pp, locality -2.3pp, venue -0.6pp, region/postcode/unit flat.
|
|
489
|
-
// It is worse-or-flat on EVERY tag — including venue, the thing #427 promoted it for. The #427
|
|
490
|
-
// re-gate's "DE +25pp / IT-ES +15pp" was loose street-STRING recall on OOD inputs (where raw
|
|
491
|
-
// neural mangles the street); it never measured the geocode precondition our evals grade on raw
|
|
492
|
-
// neural, so the regression was invisible. The destructive piece is the grouper HN-bundling (see
|
|
493
|
-
// the tracked issue); until that's fixed, argmax is the correct default. Set `jointReconcile: true`
|
|
494
|
-
// to opt back into reconcile (the A/B harnesses do). Report:
|
|
495
|
-
// docs/articles/evals/experiments/2026-06-14-reconcile-retirement.md.
|
|
496
|
-
const jointEnabled = opts?.jointReconcile ?? false
|
|
497
|
-
|
|
498
|
-
const useJointReconcile =
|
|
499
|
-
jointEnabled && phraseProposals.length > 0 && stages.classifier && "parseWithLogits" in stages.classifier
|
|
500
|
-
|
|
501
|
-
if (useJointReconcile) {
|
|
502
|
-
const classifierWithLogits = stages.classifier as AddressClassifier & {
|
|
503
|
-
parseWithLogits: (
|
|
504
|
-
text: string,
|
|
505
|
-
opts?: ClassifierOpts
|
|
506
|
-
) => Promise<{ tree: AddressTree; logits: number[][]; pieces: Array<{ start: number; end: number }> }>
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
throwIfAborted(opts)
|
|
510
|
-
const tClassify = performance.now()
|
|
511
|
-
|
|
512
|
-
const {
|
|
513
|
-
tree: argmaxTree,
|
|
514
|
-
logits,
|
|
515
|
-
pieces,
|
|
516
|
-
} = await classifierWithLogits.parseWithLogits(normalized.normalized, {
|
|
517
|
-
queryShape,
|
|
518
|
-
fst: stages.fst,
|
|
519
|
-
...streetContextGateFor(stages),
|
|
520
|
-
})
|
|
521
|
-
|
|
522
|
-
timing["token-classify"] = performance.now() - tClassify
|
|
523
474
|
|
|
524
|
-
|
|
525
|
-
const tReconcile = performance.now()
|
|
526
|
-
|
|
527
|
-
// The classifier must expose its label vocabulary so the aggregation can strip BIO prefixes.
|
|
528
|
-
// NeuralAddressClassifier surfaces this as `cfg.labels` — extracted via structural typing here.
|
|
529
|
-
const labels: readonly string[] =
|
|
530
|
-
"labels" in classifierWithLogits ? (classifierWithLogits as unknown as { labels: readonly string[] }).labels : []
|
|
531
|
-
|
|
532
|
-
const classifierTopK = aggregateSpanLogits(
|
|
533
|
-
logits,
|
|
534
|
-
pieces,
|
|
535
|
-
phraseProposals.map((p) => ({ start: p.span.start, end: p.span.end })),
|
|
536
|
-
{ labels, text: normalized.normalized }
|
|
537
|
-
)
|
|
538
|
-
|
|
539
|
-
if (classifierTopK.length) {
|
|
540
|
-
// Concordance axes (#478): when the caller wires a backend, one bounded pre-fetch
|
|
541
|
-
// activates the resolver-candidate + parent-chain scoring the reconciler already
|
|
542
|
-
// implements. Absent backend = classifier-only reconcile (byte-stable).
|
|
543
|
-
// Country constraint from the locale gate's BCP-47 tag ("en-US" -> "US"); absent or
|
|
544
|
-
// und-like tags pass no constraint (ranking alone decides — matches resolveTree's default).
|
|
545
|
-
const localeCountry = locale.locale.split("-")[1]?.toUpperCase()
|
|
546
|
-
|
|
547
|
-
const lookups = stages.resolverBackend
|
|
548
|
-
? await prefetchReconcileLookups(
|
|
549
|
-
stages.resolverBackend,
|
|
550
|
-
normalized.normalized,
|
|
551
|
-
classifierTopK,
|
|
552
|
-
localeCountry && localeCountry.length === 2 ? { defaultCountry: localeCountry } : {}
|
|
553
|
-
)
|
|
554
|
-
: undefined
|
|
555
|
-
|
|
556
|
-
const result = reconcileSpans({
|
|
557
|
-
raw: normalized.normalized,
|
|
558
|
-
phraseProposals,
|
|
559
|
-
classifierTopK,
|
|
560
|
-
...(lookups ? { resolverCandidates: lookups.resolverCandidates, parentChain: lookups.parentChain } : {}),
|
|
561
|
-
})
|
|
562
|
-
|
|
563
|
-
tree = result.tree
|
|
564
|
-
// The reconciler can leave a span uncovered (e.g. it picked the single-token street
|
|
565
|
-
// `Trento` over `Via Trento`, orphaning `Via`). The grouper-audit below would then promote
|
|
566
|
-
// that orphan's LOCALITY_PHRASE proposal to a `locality` node — even though the classifier
|
|
567
|
-
// confidently typed it `street`. Hand the audit the classifier's per-span verdict so it
|
|
568
|
-
// respects that opinion instead of trusting the structural phrase kind (#425 re-gate).
|
|
569
|
-
auditClassifierTopK = classifierTopK
|
|
570
|
-
} else {
|
|
571
|
-
tree = argmaxTree
|
|
572
|
-
}
|
|
573
|
-
|
|
574
|
-
timing["reconcile"] = performance.now() - tReconcile
|
|
575
|
-
} else if (stages.classifier) {
|
|
475
|
+
if (stages.classifier) {
|
|
576
476
|
throwIfAborted(opts)
|
|
577
477
|
const tClassify = performance.now()
|
|
578
478
|
|
|
@@ -590,7 +490,7 @@ export async function runPipeline(
|
|
|
590
490
|
|
|
591
491
|
if (phraseProposals.length && tree.roots.length >= 0) {
|
|
592
492
|
const tAudit = performance.now()
|
|
593
|
-
tree = grouperAudit(tree, phraseProposals, normalized.normalized
|
|
493
|
+
tree = grouperAudit(tree, phraseProposals, normalized.normalized)
|
|
594
494
|
timing["grouper-audit"] = performance.now() - tAudit
|
|
595
495
|
}
|
|
596
496
|
|
|
@@ -600,7 +500,9 @@ export async function runPipeline(
|
|
|
600
500
|
|
|
601
501
|
// #912 lever 1: the placer abstains on a single bare locality — strip ONLY the anchor it
|
|
602
502
|
// added (a caller-supplied posterior was never overwritten and passes through untouched).
|
|
603
|
-
|
|
503
|
+
// #1589: a bare POSTCODE abstains the same way — the code's format carries the country
|
|
504
|
+
// evidence, and the placer's language read of it is noise (see isBarePostcodeTree).
|
|
505
|
+
if (placerAnchorApplied && (isBareLocalityTree(tree) || isBarePostcodeTree(tree))) {
|
|
604
506
|
effectiveOpts = opts
|
|
605
507
|
}
|
|
606
508
|
|
|
@@ -709,7 +611,7 @@ async function safeClassify(
|
|
|
709
611
|
* fragment-positive) without the emission prior (measured US-golden −48). Absent either matcher, the spread is `{}` and
|
|
710
612
|
* the decode is byte-stable.
|
|
711
613
|
*/
|
|
712
|
-
const ZEROED_MORPHOLOGY_OPTS = { biasScale: 0, dependentLocalityPenalty: 0 } as const
|
|
614
|
+
export const ZEROED_MORPHOLOGY_OPTS = { biasScale: 0, dependentLocalityPenalty: 0 } as const
|
|
713
615
|
|
|
714
616
|
/**
|
|
715
617
|
* D2 remediation (#1320, ROAD_TO_MAILWOMAN_V8_1_0 §5.2): the pipeline ships the gate at FULL suppression (0.0), not the
|
|
@@ -718,9 +620,9 @@ const ZEROED_MORPHOLOGY_OPTS = { biasScale: 0, dependentLocalityPenalty: 0 } as
|
|
|
718
620
|
* fragment class byte-identical to 0.25 — the "some admin mass for the semi-markov decoder" rationale for 0.25 carried
|
|
719
621
|
* no measured benefit at the pipeline level. Satisfies the D-rule (iron rule 6) ≥P0 clause for #1318.
|
|
720
622
|
*/
|
|
721
|
-
const STREET_CONTEXT_POSITIVE_SCALE = 0
|
|
623
|
+
export const STREET_CONTEXT_POSITIVE_SCALE = 0
|
|
722
624
|
|
|
723
|
-
function streetContextGateFor(stages: { fst?: FSTMatcherLike; streetMorphology?: FSTMatcherLike }): {
|
|
625
|
+
export function streetContextGateFor(stages: { fst?: FSTMatcherLike; streetMorphology?: FSTMatcherLike }): {
|
|
724
626
|
fstStreetMorphology?: FSTMatcherLike
|
|
725
627
|
fstStreetMorphologyOpts?: { biasScale: number; dependentLocalityPenalty: number }
|
|
726
628
|
fstStreetContextPositiveScale?: number
|
|
@@ -771,19 +673,12 @@ const PHRASE_KIND_TO_TAG: ReadonlyMap<string, ComponentTag> = new Map([
|
|
|
771
673
|
* classifier output, inject a provisional node using the grouper's structural hypothesis. This rescues spans the neural
|
|
772
674
|
* model couldn't type — primarily venue text.
|
|
773
675
|
*
|
|
774
|
-
*
|
|
775
|
-
*
|
|
776
|
-
*
|
|
777
|
-
*
|
|
778
|
-
* LOCALITY_PHRASE to a spurious `locality` node — burying the real trailing city. The classifier said `street:0.73` for
|
|
779
|
-
* `Via`; trust it (#425).
|
|
676
|
+
* The audit once took a classifier top-k and deferred to it on an orphaned span, and once suppressed a duplicate
|
|
677
|
+
* singleton tag. Both existed for the joint-reconcile path, which fed the only top-k that ever reached here and was
|
|
678
|
+
* removed in #1749; on the surviving argmax path the parameter was always `undefined`, so neither branch could fire.
|
|
679
|
+
* Removed rather than left as unreachable code — the #425 reasoning they encoded is in the retirement report.
|
|
780
680
|
*/
|
|
781
|
-
export function grouperAudit(
|
|
782
|
-
tree: AddressTree,
|
|
783
|
-
proposals: PhraseProposal[],
|
|
784
|
-
text: string,
|
|
785
|
-
classifierTopK?: ClassifierCandidate[]
|
|
786
|
-
): AddressTree {
|
|
681
|
+
export function grouperAudit(tree: AddressTree, proposals: PhraseProposal[], text: string): AddressTree {
|
|
787
682
|
if (!proposals.length) return tree
|
|
788
683
|
|
|
789
684
|
const roots = [...tree.roots]
|
|
@@ -802,44 +697,6 @@ export function grouperAudit(
|
|
|
802
697
|
|
|
803
698
|
collectNodes(roots)
|
|
804
699
|
|
|
805
|
-
// Index the classifier's single best tag per exact span (start:end) so the audit can defer to it.
|
|
806
|
-
const CLASSIFIER_OVERRIDE_MIN = 0.4
|
|
807
|
-
const bestTagBySpan = new Map<string, { tag: ComponentTag; score: number }>()
|
|
808
|
-
|
|
809
|
-
for (const c of classifierTopK ?? []) {
|
|
810
|
-
const k = `${c.span.start}:${c.span.end}`
|
|
811
|
-
const cur = bestTagBySpan.get(k)
|
|
812
|
-
|
|
813
|
-
if (!cur || c.score > cur.score) {
|
|
814
|
-
bestTagBySpan.set(k, { tag: c.tag, score: c.score })
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
|
|
818
|
-
// Tags that may appear AT MOST ONCE per address. On the joint path, the reconciler has already
|
|
819
|
-
// placed the confident locality/region/postcode; a SECOND one injected here is almost always a
|
|
820
|
-
// street-name word the OOD model mistyped ("Via Francesca Nord" → `Francesca`) or an area-line
|
|
821
|
-
// prefix ("LUGAR …" / "URBANIZACION …"). Suppressing the duplicate keeps the real trailing city
|
|
822
|
-
// from being shadowed by an earlier-positioned spurious node in `decodeAsJSON` (#425 residual tail).
|
|
823
|
-
const SINGLETON_TAGS: ReadonlySet<ComponentTag> = new Set<ComponentTag>(["locality", "region", "postcode", "country"])
|
|
824
|
-
const presentSingletons = new Set<ComponentTag>()
|
|
825
|
-
|
|
826
|
-
const collectSingletons = (nodes: typeof roots): void => {
|
|
827
|
-
for (const n of nodes) {
|
|
828
|
-
if (SINGLETON_TAGS.has(n.tag)) {
|
|
829
|
-
presentSingletons.add(n.tag)
|
|
830
|
-
}
|
|
831
|
-
|
|
832
|
-
if (n.children) {
|
|
833
|
-
collectSingletons(n.children as typeof roots)
|
|
834
|
-
}
|
|
835
|
-
}
|
|
836
|
-
}
|
|
837
|
-
|
|
838
|
-
collectSingletons(roots)
|
|
839
|
-
const dedupeSingletons = classifierTopK !== undefined
|
|
840
|
-
|
|
841
|
-
// joint path only — argmax stays byte-stable
|
|
842
|
-
|
|
843
700
|
for (const proposal of proposals) {
|
|
844
701
|
const phraseTag = PHRASE_KIND_TO_TAG.get(proposal.kindHypothesis)
|
|
845
702
|
|
|
@@ -852,14 +709,7 @@ export function grouperAudit(
|
|
|
852
709
|
|
|
853
710
|
if (covered) continue
|
|
854
711
|
|
|
855
|
-
|
|
856
|
-
const classifierVerdict = bestTagBySpan.get(`${proposal.span.start}:${proposal.span.end}`)
|
|
857
|
-
|
|
858
|
-
const tag =
|
|
859
|
-
classifierVerdict && classifierVerdict.score >= CLASSIFIER_OVERRIDE_MIN ? classifierVerdict.tag : phraseTag
|
|
860
|
-
|
|
861
|
-
// Don't inject a second singleton-tag node when the reconciler already produced one.
|
|
862
|
-
if (dedupeSingletons && SINGLETON_TAGS.has(tag) && presentSingletons.has(tag)) continue
|
|
712
|
+
const tag = phraseTag
|
|
863
713
|
|
|
864
714
|
const provisionalNode: AddressNode = {
|
|
865
715
|
tag,
|
|
@@ -873,10 +723,6 @@ export function grouperAudit(
|
|
|
873
723
|
}
|
|
874
724
|
|
|
875
725
|
roots.push(provisionalNode)
|
|
876
|
-
|
|
877
|
-
if (SINGLETON_TAGS.has(tag)) {
|
|
878
|
-
presentSingletons.add(tag)
|
|
879
|
-
}
|
|
880
726
|
}
|
|
881
727
|
|
|
882
728
|
roots.sort((a, b) => a.start - b.start)
|
|
@@ -286,7 +286,7 @@ function findSameCharPairs(text: string, ch: string): Array<{ open: number; clos
|
|
|
286
286
|
* - Everything else (capitalized mid-string: "[Building A]", "(The White House)") → moderate.
|
|
287
287
|
*/
|
|
288
288
|
function annotationConfidence(content: string, atEndOfInput: boolean, lexicon: SpanProposerLexicon): number {
|
|
289
|
-
const tokens = content.split(/\s+/).filter(
|
|
289
|
+
const tokens = content.split(/\s+/).filter((value) => value.length > 0)
|
|
290
290
|
|
|
291
291
|
if (!tokens.length) return 0
|
|
292
292
|
|
package/pipeline/types.ts
CHANGED
|
@@ -19,6 +19,14 @@ import type { Section } from "../types/classifier.ts"
|
|
|
19
19
|
|
|
20
20
|
export type LocaleTag = string
|
|
21
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Independent host/browser preferences. A timezone is evidence, never a locale conversion.
|
|
24
|
+
*/
|
|
25
|
+
export interface MachinePreferences {
|
|
26
|
+
locale?: LocaleTag
|
|
27
|
+
timeZone?: string
|
|
28
|
+
}
|
|
29
|
+
|
|
22
30
|
/**
|
|
23
31
|
* Optional user-location signal for Stage 6 resolver scoring.
|
|
24
32
|
*/
|
|
@@ -51,19 +59,6 @@ export interface PipelineOpts {
|
|
|
51
59
|
* still takes the poi branch regardless of this flag.
|
|
52
60
|
*/
|
|
53
61
|
forceFullPipeline?: boolean
|
|
54
|
-
/**
|
|
55
|
-
* The joint-reconcile path (Stage 5 beam search). Promoted to default by Route A Phase II (#427), then RETIRED AS
|
|
56
|
-
* DEFAULT 2026-06-14: a reconcile-vs-raw-neural audit found it breaks the street+house_number geocode precondition on
|
|
57
|
-
* 77-84% of clean US addresses (golden v0.1.2 US+FR, n=4507: street -25.6pp, house_number -23.1pp; worse-or-flat on
|
|
58
|
-
* every tag, venue included). The phrase grouper bundles the house number into the STREET_PHRASE and reconcileSpans
|
|
59
|
-
* fuses the span. The #427 "DE +25pp" gains were loose street-string recall on OOD inputs, not the geocode
|
|
60
|
-
* precondition. Default (unset) is now `false` (argmax). It still requires a phrase grouper + a classifier exposing
|
|
61
|
-
* `parseWithLogits`; when either is absent the pipeline uses argmax regardless.
|
|
62
|
-
*
|
|
63
|
-
* Set `jointReconcile: true` to opt back into reconcile (the A/B harnesses do). Report:
|
|
64
|
-
* docs/articles/evals/experiments/2026-06-14-reconcile-retirement.md.
|
|
65
|
-
*/
|
|
66
|
-
jointReconcile?: boolean
|
|
67
62
|
/**
|
|
68
63
|
* Hard cap on lookups the resolver may issue; passed through.
|
|
69
64
|
*/
|
|
@@ -136,7 +131,15 @@ export interface LocaleHint {
|
|
|
136
131
|
locale: LocaleTag
|
|
137
132
|
confidence: number
|
|
138
133
|
alternatives: ReadonlyArray<{ locale: LocaleTag; confidence: number }>
|
|
139
|
-
source: "caller" | "detected" | "ensemble"
|
|
134
|
+
source: "caller" | "environment" | "machine" | "detected" | "ensemble"
|
|
135
|
+
/**
|
|
136
|
+
* Diagnostic provenance for inferred preferences. Locale and timezone remain independent signals.
|
|
137
|
+
*/
|
|
138
|
+
evidence?: {
|
|
139
|
+
intlLocale?: string
|
|
140
|
+
timeZone?: string
|
|
141
|
+
environmentLocale?: string
|
|
142
|
+
}
|
|
140
143
|
}
|
|
141
144
|
|
|
142
145
|
/**
|
|
@@ -303,6 +306,10 @@ export interface POIIntent {
|
|
|
303
306
|
| { kind: "category"; categoryID: string; matched: string }
|
|
304
307
|
| { kind: "brand"; name: string; wikidata?: string; matched: string }
|
|
305
308
|
| { kind: "name"; text: string }
|
|
309
|
+
/**
|
|
310
|
+
* The relation crossing from the recognized subject span to the anchor span.
|
|
311
|
+
*/
|
|
312
|
+
relation?: "comma" | "near" | "in" | "at" | "around" | "to"
|
|
306
313
|
/**
|
|
307
314
|
* Spatial anchor: the split-off remainder text and its parse, when the query carried one.
|
|
308
315
|
*/
|
|
@@ -487,7 +494,11 @@ export interface AddressClassifier {
|
|
|
487
494
|
export interface RuntimePipelineStages {
|
|
488
495
|
normalize?: (raw: string, opts?: { locale?: string }) => NormalizedInputLite
|
|
489
496
|
computeQueryShape?: (input: NormalizedInputLite | string, opts?: { locale?: string }) => QueryShapeLite
|
|
490
|
-
detectLocale?: (
|
|
497
|
+
detectLocale?: (
|
|
498
|
+
input: NormalizedInputLite,
|
|
499
|
+
shape: QueryShapeLite,
|
|
500
|
+
opts?: { hint?: LocaleTag; machinePreferences?: MachinePreferences; environmentLocale?: LocaleTag }
|
|
501
|
+
) => Promise<LocaleHint>
|
|
491
502
|
classifyKind?: (input: NormalizedInputLite, shape: QueryShapeLite, locale: LocaleHint) => Promise<QueryKindResult>
|
|
492
503
|
/**
|
|
493
504
|
* Coarse country router (#244). A `(normalizedText) → { country, confidence, posterior? }` predictor (a
|
package/policy/defaults.ts
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* edits one entry here with a commit-message rationale.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import { COMPONENT_TAGS, type ComponentTag } from "
|
|
11
|
+
import { COMPONENT_TAGS, type ComponentTag } from "#types"
|
|
12
12
|
|
|
13
13
|
import type { ClassifierPolicy, PolicyMode } from "./policy.ts"
|
|
14
14
|
|
package/policy/policy.ts
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
* neural-backed modes happen one component at a time, gated on golden-set metrics.
|
|
10
10
|
*/
|
|
11
11
|
|
|
12
|
-
import type { ClassificationProposal, ComponentTag } from "
|
|
12
|
+
import type { ClassificationProposal, ComponentTag } from "#types"
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* How a component is sourced.
|
package/policy/registry.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* per-locale overrides at startup. Look-up and `apply` are pure.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import type { ClassificationProposal, ComponentTag } from "
|
|
13
|
+
import type { ClassificationProposal, ComponentTag } from "#types"
|
|
14
14
|
|
|
15
15
|
import { buildDefaultPolicies, defaultPolicyFor } from "./defaults.ts"
|
|
16
16
|
import type { ClassifierPolicy, PolicyMode, PolicyRegistry } from "./policy.ts"
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* What a loaded gazetteer artifact declares about its own country coverage, and the one derivation the
|
|
7
|
+
* reader and the build share. A country ABSENT from a coverage map was never measured — never measured and
|
|
8
|
+
* failed; the failed case is present with `hardFilterSafe: false`.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* One country's measured hard-filter coverage fact, as recorded at a promote gate. Facts about the gazetteer artifact
|
|
13
|
+
* live IN the artifact (the `country_coverage` table the gazetteer build emits) — code constants are only the fallback
|
|
14
|
+
* for artifacts that predate the manifest.
|
|
15
|
+
*
|
|
16
|
+
* Meaning-of-zero discipline: a country ABSENT from the coverage map was never measured — never "measured and failed".
|
|
17
|
+
* A measured-and-failed country is PRESENT with `hardFilterSafe: false` (e.g. FI at 69.5% hard-resolve), so the
|
|
18
|
+
* negative result is a first-class record, distinguishable from ignorance.
|
|
19
|
+
*/
|
|
20
|
+
export interface CountryCoverageFact {
|
|
21
|
+
/**
|
|
22
|
+
* ISO 3166-1 alpha-2, uppercase.
|
|
23
|
+
*/
|
|
24
|
+
country: string
|
|
25
|
+
/**
|
|
26
|
+
* The promote-gate VERDICT: hard-filtering this country is a pure win (a hard-filter miss is almost always a genuine
|
|
27
|
+
* non-match, not a coverage gap). Stored as a verdict — not re-derived from `hardResolveRate` at read time — because
|
|
28
|
+
* the gate is a judgment over a panel, not a pure rate function (CA cleared at the #928 promote on the
|
|
29
|
+
* postcode-format-prior rationale despite a sub-95% panel resolve rate).
|
|
30
|
+
*/
|
|
31
|
+
hardFilterSafe: boolean
|
|
32
|
+
/**
|
|
33
|
+
* Measured hard-resolve rate (0..1) on the panel named in `source`, when the receipt recorded one.
|
|
34
|
+
*/
|
|
35
|
+
hardResolveRate?: number
|
|
36
|
+
/**
|
|
37
|
+
* Panel size behind `hardResolveRate`, when recorded.
|
|
38
|
+
*/
|
|
39
|
+
sampleSize?: number
|
|
40
|
+
/**
|
|
41
|
+
* ISO-8601 date of the measurement / promote gate.
|
|
42
|
+
*/
|
|
43
|
+
measuredAt: string
|
|
44
|
+
/**
|
|
45
|
+
* The receipt: which panel/gate produced this row (issue + date, human-readable).
|
|
46
|
+
*/
|
|
47
|
+
source: string
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* One country's coarse guard-B bounding box, as carried by the gazetteer artifact's `country_bbox` table.
|
|
52
|
+
*/
|
|
53
|
+
export interface CountryBBoxFact {
|
|
54
|
+
/**
|
|
55
|
+
* ISO 3166-1 alpha-2, uppercase.
|
|
56
|
+
*/
|
|
57
|
+
country: string
|
|
58
|
+
latMin: number
|
|
59
|
+
latMax: number
|
|
60
|
+
lonMin: number
|
|
61
|
+
lonMax: number
|
|
62
|
+
/**
|
|
63
|
+
* Provenance of the box (harness + date).
|
|
64
|
+
*/
|
|
65
|
+
source: string
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Facts a loaded gazetteer artifact declares about itself — read from the artifact's own manifest tables at open time,
|
|
70
|
+
* carried on the {@link ResolverBackend}/{@link Resolver} handle so consumers read the facts from the artifact they are
|
|
71
|
+
* actually resolving against. `undefined` on the handle = the artifact predates the manifest → consumers fall back to
|
|
72
|
+
* the code constants (byte-identical legacy behavior).
|
|
73
|
+
*/
|
|
74
|
+
export interface GazetteerArtifactCoverage {
|
|
75
|
+
/**
|
|
76
|
+
* Country → measured coverage fact. ABSENCE = never measured (meaning-of-zero), never "failed".
|
|
77
|
+
*/
|
|
78
|
+
countryCoverage: ReadonlyMap<string, CountryCoverageFact>
|
|
79
|
+
/**
|
|
80
|
+
* Country → guard-B bbox. ABSENCE = no box → the plausibility guard fails open for that country.
|
|
81
|
+
*/
|
|
82
|
+
countryBBoxes: ReadonlyMap<string, CountryBBoxFact>
|
|
83
|
+
/**
|
|
84
|
+
* Derived at load: the countries whose fact says `hardFilterSafe` — the artifact's hard-country safelist.
|
|
85
|
+
*/
|
|
86
|
+
hardCountrySafelist: ReadonlySet<string>
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Derive the hard-country safelist from coverage facts — the ONE derivation both the reader and the build share.
|
|
91
|
+
*/
|
|
92
|
+
export function hardCountrySafelistFromCoverage(facts: Iterable<CountryCoverageFact>): ReadonlySet<string> {
|
|
93
|
+
const out = new Set<string>()
|
|
94
|
+
|
|
95
|
+
for (const fact of facts) {
|
|
96
|
+
if (fact.hardFilterSafe) {
|
|
97
|
+
out.add(fact.country.toUpperCase())
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return out
|
|
102
|
+
}
|
package/resolver/index.ts
CHANGED
|
@@ -21,6 +21,8 @@ export {
|
|
|
21
21
|
|
|
22
22
|
export type { ReferentiallyRankable } from "./referential.ts"
|
|
23
23
|
|
|
24
|
+
export { countriesFromPostcodeFormat, countryFromPostcodeFormat, POSTCODE_FORMAT_COUNTRY } from "./postcode-format.ts"
|
|
25
|
+
|
|
24
26
|
export {
|
|
25
27
|
DEFAULT_PLACETYPE_MAP,
|
|
26
28
|
PLACETYPE_FILTER_GROUPS,
|
|
@@ -33,6 +35,7 @@ export type {
|
|
|
33
35
|
AddressPointHit,
|
|
34
36
|
AddressPointLookup,
|
|
35
37
|
Ancestor,
|
|
38
|
+
BackendCapabilityGap,
|
|
36
39
|
CoincidentLocality,
|
|
37
40
|
CountryBBoxFact,
|
|
38
41
|
CountryCoverageFact,
|
|
@@ -43,6 +46,8 @@ export type {
|
|
|
43
46
|
PostcodePrefixAncestor,
|
|
44
47
|
PostcodePrefixIndexLike,
|
|
45
48
|
PostcodePrefixNode,
|
|
49
|
+
ResolveCandidateTrace,
|
|
50
|
+
ResolveNodeTrace,
|
|
46
51
|
ResolveOpts,
|
|
47
52
|
ResolvedPlace,
|
|
48
53
|
Resolver,
|