@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/pipeline/index.ts
CHANGED
|
@@ -6,24 +6,21 @@
|
|
|
6
6
|
* Runtime pipeline coordinator — see `STAGES.md` for the full contract.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
export {
|
|
9
|
+
export {
|
|
10
|
+
COARSE_PLACER_ANCHOR_WEIGHT,
|
|
11
|
+
HARD_PLACE_COUNTRY_SAFELIST,
|
|
12
|
+
hardCountryFor,
|
|
13
|
+
STREET_CONTEXT_POSITIVE_SCALE,
|
|
14
|
+
streetContextGateFor,
|
|
15
|
+
ZEROED_MORPHOLOGY_OPTS,
|
|
16
|
+
isBareLocalityTree,
|
|
17
|
+
isBarePostcodeTree,
|
|
18
|
+
runPipeline,
|
|
19
|
+
} from "./runtime-pipeline.ts"
|
|
10
20
|
|
|
11
|
-
export type {
|
|
12
|
-
ClassifierCandidate,
|
|
13
|
-
ParentChainLookup,
|
|
14
|
-
ParseTree,
|
|
15
|
-
ReconcileInputs,
|
|
16
|
-
ReconcileOpts,
|
|
17
|
-
ResolverCandidatesLookup,
|
|
18
|
-
ScoreBreakdown,
|
|
19
|
-
} from "./reconcile.ts"
|
|
20
|
-
|
|
21
|
-
export { HARD_PLACE_COUNTRY_SAFELIST, hardCountryFor, isBareLocalityTree, runPipeline } from "./runtime-pipeline.ts"
|
|
22
|
-
export { aggregateSpanLogits } from "./span-logit-aggregation.ts"
|
|
23
|
-
export type { SpanBounds, TokenPiece } from "./span-logit-aggregation.ts"
|
|
24
21
|
export { EMPTY_SPAN_PROPOSER_LEXICON, proposeSpans } from "./span-proposer.ts"
|
|
25
22
|
export type { ProposedSpan, ProposedSpanKind, SpanProposerLexicon } from "./span-proposer.ts"
|
|
26
|
-
export { deriveInputMode, PipelineFaultStage, WORD_CONSISTENCY_SHIP_DEFAULT } from "./types.ts"
|
|
23
|
+
export { deriveInputMode, PipelineFaultStage, QueryIntentCode, WORD_CONSISTENCY_SHIP_DEFAULT } from "./types.ts"
|
|
27
24
|
|
|
28
25
|
export type {
|
|
29
26
|
AddressClassifier,
|
|
@@ -32,6 +29,7 @@ export type {
|
|
|
32
29
|
InputMode,
|
|
33
30
|
LocaleHint,
|
|
34
31
|
LocaleTag,
|
|
32
|
+
MachinePreferences,
|
|
35
33
|
NormalizedInputLite,
|
|
36
34
|
PhraseGrouper,
|
|
37
35
|
PhraseKind,
|
|
@@ -44,6 +42,7 @@ export type {
|
|
|
44
42
|
POIIntent,
|
|
45
43
|
POIIntentOutcome,
|
|
46
44
|
POIResult,
|
|
45
|
+
QueryIntentMarker,
|
|
47
46
|
QueryKind,
|
|
48
47
|
QueryKindResult,
|
|
49
48
|
QueryShapeLite,
|
|
@@ -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,
|
|
@@ -32,6 +28,7 @@ import type {
|
|
|
32
28
|
PipelineOpts,
|
|
33
29
|
PipelineResult,
|
|
34
30
|
PlacetypePairPassthrough,
|
|
31
|
+
QueryIntentMarker,
|
|
35
32
|
QueryKindResult,
|
|
36
33
|
QueryShapeLite,
|
|
37
34
|
RuntimePipelineStages,
|
|
@@ -73,7 +70,7 @@ function isPostcodeFormat(format: string): boolean {
|
|
|
73
70
|
* whole-string country guess is a broader, softer signal than a postcode that pins the country, so it blends more
|
|
74
71
|
* gently with the candidate score.
|
|
75
72
|
*/
|
|
76
|
-
const COARSE_PLACER_ANCHOR_WEIGHT = 1
|
|
73
|
+
export const COARSE_PLACER_ANCHOR_WEIGHT = 1
|
|
77
74
|
|
|
78
75
|
/**
|
|
79
76
|
* #194: minimum placer confidence to promote the soft country prior to a HARD filter (empty→unresolved). The placer
|
|
@@ -126,20 +123,20 @@ export const HARD_PLACE_COUNTRY_SAFELIST: ReadonlySet<string> = new Set([
|
|
|
126
123
|
* runs as before.
|
|
127
124
|
*/
|
|
128
125
|
export function isBareLocalityTree(tree: AddressTree): boolean {
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
while (stack.length) {
|
|
133
|
-
const node = stack.pop()!
|
|
134
|
-
|
|
135
|
-
if (node.tag === "locality") {
|
|
136
|
-
sawLocality = true
|
|
137
|
-
} else if (node.value.trim() !== "") return false
|
|
138
|
-
|
|
139
|
-
stack.push(...node.children)
|
|
140
|
-
}
|
|
126
|
+
return isBareTreeOf(tree, "locality")
|
|
127
|
+
}
|
|
141
128
|
|
|
142
|
-
|
|
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")
|
|
143
140
|
}
|
|
144
141
|
|
|
145
142
|
/**
|
|
@@ -386,12 +383,26 @@ export async function runPipeline(
|
|
|
386
383
|
const kind = await classifyKind(normalized, queryShape, locale)
|
|
387
384
|
timing["kind-classifier"] = performance.now() - tKind
|
|
388
385
|
|
|
386
|
+
// ROAD_TO_V9 §4. The classifier OWNS marker derivation (it is the stage that knows which intent rule fired); the
|
|
387
|
+
// coordinator only lifts the optional field into an always-present array, so an empty array is this coordinator
|
|
388
|
+
// stating that the vocabulary looked. A classifier with no intent vocabulary — including `defaultClassifyKind`
|
|
389
|
+
// above — leaves the field unset and every result carries `[]`, which is the byte-stable pre-§4 behaviour.
|
|
390
|
+
//
|
|
391
|
+
// `declared_ambiguity` is deliberately ABSENT from this list: its trigger is the resolved candidate list's
|
|
392
|
+
// dominance margin, and the measured 0.5-log10 cut behind it lives in `mailwoman`'s eval harness, which core
|
|
393
|
+
// cannot import (the dependency runs the other way). `mailwoman/query-intent.ts` adds it on the geocode path.
|
|
394
|
+
const intentMarkers: QueryIntentMarker[] = kind.intentMarkers ? [...kind.intentMarkers] : []
|
|
395
|
+
|
|
389
396
|
// POI branch (spec §3.1). Only reachable when a poi-aware kind classifier was wired (the
|
|
390
397
|
// default classifier never emits `poi_query`), and only acts when the stage is present —
|
|
391
398
|
// both absent by default, so the flag-off pipeline is byte-identical by construction. A
|
|
392
399
|
// `null` outcome falls through to the full pipeline: a poi_query kind with no extractable
|
|
393
400
|
// subject is a mis-detection, and the address path is the safe interpretation.
|
|
394
|
-
|
|
401
|
+
// `poi_category` (ROAD_TO_V9 §4.4) is the ANCHORLESS subset of `poi_query` — same subject, no place to search
|
|
402
|
+
// near. It routes here identically on purpose: the branch condition is the only place the two would have diverged,
|
|
403
|
+
// and a bare "tacos" reaching the poi-intent stage under a different kind name would have been a routing change
|
|
404
|
+
// dressed up as a vocabulary addition.
|
|
405
|
+
if ((kind.kind === "poi_query" || kind.kind === "poi_category") && stages.poiIntent) {
|
|
395
406
|
throwIfAborted(opts)
|
|
396
407
|
const tPoi = performance.now()
|
|
397
408
|
const poiOutcome = await stages.poiIntent(normalized, locale, effectiveOpts)
|
|
@@ -412,6 +423,7 @@ export async function runPipeline(
|
|
|
412
423
|
poiIntent: poiOutcome,
|
|
413
424
|
timing,
|
|
414
425
|
faults,
|
|
426
|
+
intentMarkers,
|
|
415
427
|
path: "poi",
|
|
416
428
|
}
|
|
417
429
|
}
|
|
@@ -441,6 +453,7 @@ export async function runPipeline(
|
|
|
441
453
|
tree,
|
|
442
454
|
timing,
|
|
443
455
|
faults,
|
|
456
|
+
intentMarkers,
|
|
444
457
|
path: "fast-path",
|
|
445
458
|
}
|
|
446
459
|
}
|
|
@@ -458,104 +471,8 @@ export async function runPipeline(
|
|
|
458
471
|
}
|
|
459
472
|
|
|
460
473
|
let tree: AddressTree = { raw: normalized.normalized, roots: [] }
|
|
461
|
-
// Captured from the joint-reconcile path so the grouper-audit can defer to the classifier's
|
|
462
|
-
// per-span verdict on orphaned spans (see the assignment + grouperAudit below).
|
|
463
|
-
let auditClassifierTopK: ClassifierCandidate[] | undefined
|
|
464
|
-
|
|
465
|
-
// Joint-reconcile path: RETIRED AS DEFAULT 2026-06-14 (#427 promoted it; this de-promotes it).
|
|
466
|
-
// A reconcile-vs-raw-neural audit on two non-circular US holdouts (Travis E-911 + 7-state
|
|
467
|
-
// OpenAddresses) found it BREAKS the street+house_number geocode precondition on 77-84% of clean
|
|
468
|
-
// US addresses and fixes 0% — the phrase grouper bundles the house number into the STREET_PHRASE
|
|
469
|
-
// ("3075 Hill Street") and reconcileSpans then fuses the whole span into one node, leaving no
|
|
470
|
-
// separate `street`. Confirmed on golden v0.1.2 US+FR (n=4507, per-tag recall vs raw argmax):
|
|
471
|
-
// street -25.6pp, house_number -23.1pp, locality -2.3pp, venue -0.6pp, region/postcode/unit flat.
|
|
472
|
-
// It is worse-or-flat on EVERY tag — including venue, the thing #427 promoted it for. The #427
|
|
473
|
-
// re-gate's "DE +25pp / IT-ES +15pp" was loose street-STRING recall on OOD inputs (where raw
|
|
474
|
-
// neural mangles the street); it never measured the geocode precondition our evals grade on raw
|
|
475
|
-
// neural, so the regression was invisible. The destructive piece is the grouper HN-bundling (see
|
|
476
|
-
// the tracked issue); until that's fixed, argmax is the correct default. Set `jointReconcile: true`
|
|
477
|
-
// to opt back into reconcile (the A/B harnesses do). Report:
|
|
478
|
-
// docs/articles/evals/experiments/2026-06-14-reconcile-retirement.md.
|
|
479
|
-
const jointEnabled = opts?.jointReconcile ?? false
|
|
480
|
-
|
|
481
|
-
const useJointReconcile =
|
|
482
|
-
jointEnabled && phraseProposals.length > 0 && stages.classifier && "parseWithLogits" in stages.classifier
|
|
483
|
-
|
|
484
|
-
if (useJointReconcile) {
|
|
485
|
-
const classifierWithLogits = stages.classifier as AddressClassifier & {
|
|
486
|
-
parseWithLogits: (
|
|
487
|
-
text: string,
|
|
488
|
-
opts?: ClassifierOpts
|
|
489
|
-
) => Promise<{ tree: AddressTree; logits: number[][]; pieces: Array<{ start: number; end: number }> }>
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
throwIfAborted(opts)
|
|
493
|
-
const tClassify = performance.now()
|
|
494
|
-
|
|
495
|
-
const {
|
|
496
|
-
tree: argmaxTree,
|
|
497
|
-
logits,
|
|
498
|
-
pieces,
|
|
499
|
-
} = await classifierWithLogits.parseWithLogits(normalized.normalized, {
|
|
500
|
-
queryShape,
|
|
501
|
-
fst: stages.fst,
|
|
502
|
-
...streetContextGateFor(stages),
|
|
503
|
-
})
|
|
504
|
-
|
|
505
|
-
timing["token-classify"] = performance.now() - tClassify
|
|
506
|
-
|
|
507
|
-
throwIfAborted(opts)
|
|
508
|
-
const tReconcile = performance.now()
|
|
509
|
-
|
|
510
|
-
// The classifier must expose its label vocabulary so the aggregation can strip BIO prefixes.
|
|
511
|
-
// NeuralAddressClassifier surfaces this as `cfg.labels` — extracted via structural typing here.
|
|
512
|
-
const labels: readonly string[] =
|
|
513
|
-
"labels" in classifierWithLogits ? (classifierWithLogits as unknown as { labels: readonly string[] }).labels : []
|
|
514
|
-
|
|
515
|
-
const classifierTopK = aggregateSpanLogits(
|
|
516
|
-
logits,
|
|
517
|
-
pieces,
|
|
518
|
-
phraseProposals.map((p) => ({ start: p.span.start, end: p.span.end })),
|
|
519
|
-
{ labels, text: normalized.normalized }
|
|
520
|
-
)
|
|
521
|
-
|
|
522
|
-
if (classifierTopK.length) {
|
|
523
|
-
// Concordance axes (#478): when the caller wires a backend, one bounded pre-fetch
|
|
524
|
-
// activates the resolver-candidate + parent-chain scoring the reconciler already
|
|
525
|
-
// implements. Absent backend = classifier-only reconcile (byte-stable).
|
|
526
|
-
// Country constraint from the locale gate's BCP-47 tag ("en-US" -> "US"); absent or
|
|
527
|
-
// und-like tags pass no constraint (ranking alone decides — matches resolveTree's default).
|
|
528
|
-
const localeCountry = locale.locale.split("-")[1]?.toUpperCase()
|
|
529
|
-
|
|
530
|
-
const lookups = stages.resolverBackend
|
|
531
|
-
? await prefetchReconcileLookups(
|
|
532
|
-
stages.resolverBackend,
|
|
533
|
-
normalized.normalized,
|
|
534
|
-
classifierTopK,
|
|
535
|
-
localeCountry && localeCountry.length === 2 ? { defaultCountry: localeCountry } : {}
|
|
536
|
-
)
|
|
537
|
-
: undefined
|
|
538
|
-
|
|
539
|
-
const result = reconcileSpans({
|
|
540
|
-
raw: normalized.normalized,
|
|
541
|
-
phraseProposals,
|
|
542
|
-
classifierTopK,
|
|
543
|
-
...(lookups ? { resolverCandidates: lookups.resolverCandidates, parentChain: lookups.parentChain } : {}),
|
|
544
|
-
})
|
|
545
|
-
|
|
546
|
-
tree = result.tree
|
|
547
|
-
// The reconciler can leave a span uncovered (e.g. it picked the single-token street
|
|
548
|
-
// `Trento` over `Via Trento`, orphaning `Via`). The grouper-audit below would then promote
|
|
549
|
-
// that orphan's LOCALITY_PHRASE proposal to a `locality` node — even though the classifier
|
|
550
|
-
// confidently typed it `street`. Hand the audit the classifier's per-span verdict so it
|
|
551
|
-
// respects that opinion instead of trusting the structural phrase kind (#425 re-gate).
|
|
552
|
-
auditClassifierTopK = classifierTopK
|
|
553
|
-
} else {
|
|
554
|
-
tree = argmaxTree
|
|
555
|
-
}
|
|
556
474
|
|
|
557
|
-
|
|
558
|
-
} else if (stages.classifier) {
|
|
475
|
+
if (stages.classifier) {
|
|
559
476
|
throwIfAborted(opts)
|
|
560
477
|
const tClassify = performance.now()
|
|
561
478
|
|
|
@@ -573,7 +490,7 @@ export async function runPipeline(
|
|
|
573
490
|
|
|
574
491
|
if (phraseProposals.length && tree.roots.length >= 0) {
|
|
575
492
|
const tAudit = performance.now()
|
|
576
|
-
tree = grouperAudit(tree, phraseProposals, normalized.normalized
|
|
493
|
+
tree = grouperAudit(tree, phraseProposals, normalized.normalized)
|
|
577
494
|
timing["grouper-audit"] = performance.now() - tAudit
|
|
578
495
|
}
|
|
579
496
|
|
|
@@ -583,7 +500,9 @@ export async function runPipeline(
|
|
|
583
500
|
|
|
584
501
|
// #912 lever 1: the placer abstains on a single bare locality — strip ONLY the anchor it
|
|
585
502
|
// added (a caller-supplied posterior was never overwritten and passes through untouched).
|
|
586
|
-
|
|
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))) {
|
|
587
506
|
effectiveOpts = opts
|
|
588
507
|
}
|
|
589
508
|
|
|
@@ -601,6 +520,7 @@ export async function runPipeline(
|
|
|
601
520
|
tree,
|
|
602
521
|
timing,
|
|
603
522
|
faults,
|
|
523
|
+
intentMarkers,
|
|
604
524
|
path: "full",
|
|
605
525
|
}
|
|
606
526
|
}
|
|
@@ -691,7 +611,7 @@ async function safeClassify(
|
|
|
691
611
|
* fragment-positive) without the emission prior (measured US-golden −48). Absent either matcher, the spread is `{}` and
|
|
692
612
|
* the decode is byte-stable.
|
|
693
613
|
*/
|
|
694
|
-
const ZEROED_MORPHOLOGY_OPTS = { biasScale: 0, dependentLocalityPenalty: 0 } as const
|
|
614
|
+
export const ZEROED_MORPHOLOGY_OPTS = { biasScale: 0, dependentLocalityPenalty: 0 } as const
|
|
695
615
|
|
|
696
616
|
/**
|
|
697
617
|
* D2 remediation (#1320, ROAD_TO_MAILWOMAN_V8_1_0 §5.2): the pipeline ships the gate at FULL suppression (0.0), not the
|
|
@@ -700,9 +620,9 @@ const ZEROED_MORPHOLOGY_OPTS = { biasScale: 0, dependentLocalityPenalty: 0 } as
|
|
|
700
620
|
* fragment class byte-identical to 0.25 — the "some admin mass for the semi-markov decoder" rationale for 0.25 carried
|
|
701
621
|
* no measured benefit at the pipeline level. Satisfies the D-rule (iron rule 6) ≥P0 clause for #1318.
|
|
702
622
|
*/
|
|
703
|
-
const STREET_CONTEXT_POSITIVE_SCALE = 0
|
|
623
|
+
export const STREET_CONTEXT_POSITIVE_SCALE = 0
|
|
704
624
|
|
|
705
|
-
function streetContextGateFor(stages: { fst?: FSTMatcherLike; streetMorphology?: FSTMatcherLike }): {
|
|
625
|
+
export function streetContextGateFor(stages: { fst?: FSTMatcherLike; streetMorphology?: FSTMatcherLike }): {
|
|
706
626
|
fstStreetMorphology?: FSTMatcherLike
|
|
707
627
|
fstStreetMorphologyOpts?: { biasScale: number; dependentLocalityPenalty: number }
|
|
708
628
|
fstStreetContextPositiveScale?: number
|
|
@@ -753,19 +673,12 @@ const PHRASE_KIND_TO_TAG: ReadonlyMap<string, ComponentTag> = new Map([
|
|
|
753
673
|
* classifier output, inject a provisional node using the grouper's structural hypothesis. This rescues spans the neural
|
|
754
674
|
* model couldn't type — primarily venue text.
|
|
755
675
|
*
|
|
756
|
-
*
|
|
757
|
-
*
|
|
758
|
-
*
|
|
759
|
-
*
|
|
760
|
-
* LOCALITY_PHRASE to a spurious `locality` node — burying the real trailing city. The classifier said `street:0.73` for
|
|
761
|
-
* `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.
|
|
762
680
|
*/
|
|
763
|
-
export function grouperAudit(
|
|
764
|
-
tree: AddressTree,
|
|
765
|
-
proposals: PhraseProposal[],
|
|
766
|
-
text: string,
|
|
767
|
-
classifierTopK?: ClassifierCandidate[]
|
|
768
|
-
): AddressTree {
|
|
681
|
+
export function grouperAudit(tree: AddressTree, proposals: PhraseProposal[], text: string): AddressTree {
|
|
769
682
|
if (!proposals.length) return tree
|
|
770
683
|
|
|
771
684
|
const roots = [...tree.roots]
|
|
@@ -784,44 +697,6 @@ export function grouperAudit(
|
|
|
784
697
|
|
|
785
698
|
collectNodes(roots)
|
|
786
699
|
|
|
787
|
-
// Index the classifier's single best tag per exact span (start:end) so the audit can defer to it.
|
|
788
|
-
const CLASSIFIER_OVERRIDE_MIN = 0.4
|
|
789
|
-
const bestTagBySpan = new Map<string, { tag: ComponentTag; score: number }>()
|
|
790
|
-
|
|
791
|
-
for (const c of classifierTopK ?? []) {
|
|
792
|
-
const k = `${c.span.start}:${c.span.end}`
|
|
793
|
-
const cur = bestTagBySpan.get(k)
|
|
794
|
-
|
|
795
|
-
if (!cur || c.score > cur.score) {
|
|
796
|
-
bestTagBySpan.set(k, { tag: c.tag, score: c.score })
|
|
797
|
-
}
|
|
798
|
-
}
|
|
799
|
-
|
|
800
|
-
// Tags that may appear AT MOST ONCE per address. On the joint path, the reconciler has already
|
|
801
|
-
// placed the confident locality/region/postcode; a SECOND one injected here is almost always a
|
|
802
|
-
// street-name word the OOD model mistyped ("Via Francesca Nord" → `Francesca`) or an area-line
|
|
803
|
-
// prefix ("LUGAR …" / "URBANIZACION …"). Suppressing the duplicate keeps the real trailing city
|
|
804
|
-
// from being shadowed by an earlier-positioned spurious node in `decodeAsJSON` (#425 residual tail).
|
|
805
|
-
const SINGLETON_TAGS: ReadonlySet<ComponentTag> = new Set<ComponentTag>(["locality", "region", "postcode", "country"])
|
|
806
|
-
const presentSingletons = new Set<ComponentTag>()
|
|
807
|
-
|
|
808
|
-
const collectSingletons = (nodes: typeof roots): void => {
|
|
809
|
-
for (const n of nodes) {
|
|
810
|
-
if (SINGLETON_TAGS.has(n.tag)) {
|
|
811
|
-
presentSingletons.add(n.tag)
|
|
812
|
-
}
|
|
813
|
-
|
|
814
|
-
if (n.children) {
|
|
815
|
-
collectSingletons(n.children as typeof roots)
|
|
816
|
-
}
|
|
817
|
-
}
|
|
818
|
-
}
|
|
819
|
-
|
|
820
|
-
collectSingletons(roots)
|
|
821
|
-
const dedupeSingletons = classifierTopK !== undefined
|
|
822
|
-
|
|
823
|
-
// joint path only — argmax stays byte-stable
|
|
824
|
-
|
|
825
700
|
for (const proposal of proposals) {
|
|
826
701
|
const phraseTag = PHRASE_KIND_TO_TAG.get(proposal.kindHypothesis)
|
|
827
702
|
|
|
@@ -834,14 +709,7 @@ export function grouperAudit(
|
|
|
834
709
|
|
|
835
710
|
if (covered) continue
|
|
836
711
|
|
|
837
|
-
|
|
838
|
-
const classifierVerdict = bestTagBySpan.get(`${proposal.span.start}:${proposal.span.end}`)
|
|
839
|
-
|
|
840
|
-
const tag =
|
|
841
|
-
classifierVerdict && classifierVerdict.score >= CLASSIFIER_OVERRIDE_MIN ? classifierVerdict.tag : phraseTag
|
|
842
|
-
|
|
843
|
-
// Don't inject a second singleton-tag node when the reconciler already produced one.
|
|
844
|
-
if (dedupeSingletons && SINGLETON_TAGS.has(tag) && presentSingletons.has(tag)) continue
|
|
712
|
+
const tag = phraseTag
|
|
845
713
|
|
|
846
714
|
const provisionalNode: AddressNode = {
|
|
847
715
|
tag,
|
|
@@ -855,10 +723,6 @@ export function grouperAudit(
|
|
|
855
723
|
}
|
|
856
724
|
|
|
857
725
|
roots.push(provisionalNode)
|
|
858
|
-
|
|
859
|
-
if (SINGLETON_TAGS.has(tag)) {
|
|
860
|
-
presentSingletons.add(tag)
|
|
861
|
-
}
|
|
862
726
|
}
|
|
863
727
|
|
|
864
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
|
/**
|
|
@@ -151,11 +154,113 @@ export type QueryKind =
|
|
|
151
154
|
| "landmark"
|
|
152
155
|
| "poi_query"
|
|
153
156
|
| "vague"
|
|
157
|
+
/**
|
|
158
|
+
* ROAD_TO_V9 §4 — the query-INTENT vocabulary. Four kinds that describe what the user is ASKING FOR rather than what
|
|
159
|
+
* their string is shaped like. They are ordinary members of this union (intent is vocabulary of the existing Stage
|
|
160
|
+
* 2.5, never a new stage), and each one, when it fires, attaches a {@link QueryIntentMarker} to the result.
|
|
161
|
+
*
|
|
162
|
+
* Two of the four are deliberately RANKED BELOW their structural incumbent and therefore surface in
|
|
163
|
+
* {@link QueryKindResult.alternatives} rather than as the top kind — see the individual docstrings in
|
|
164
|
+
* `@mailwoman/kind-classifier`'s `intent-rules.ts`. That is the D-rule discharge: the top kind is the only thing the
|
|
165
|
+
* coordinator routes on (`deriveInputMode`, `canShortCircuit`, the POI branch), so leaving it untouched is what makes
|
|
166
|
+
* the addition provably answer-neutral on the populations those incumbents already own.
|
|
167
|
+
*/
|
|
168
|
+
/**
|
|
169
|
+
* A single coherent place-name carrying no address grammar — no house number, no postcode, no street-type word. A
|
|
170
|
+
* strict REFINEMENT of `locality_only` (which also admits an admin tail: `Paris, FR`), scored just below it so the
|
|
171
|
+
* top kind never moves. Feeds the declared-ambiguity path: a bare toponym whose resolved candidates are not DECISIVE
|
|
172
|
+
* gets a `declared_ambiguity` marker at geocode time.
|
|
173
|
+
*/
|
|
174
|
+
| "bare_toponym"
|
|
175
|
+
/**
|
|
176
|
+
* Two coherent toponyms with no address grammar between them — `Paris London`. Classification plus a DECLARED FORK,
|
|
177
|
+
* never a router (ROAD_TO_V9 §4.3): structure alone cannot separate a route pair from a comma-free locality+region
|
|
178
|
+
* fragment (`Moscow Idaho`), so both interpretations are named in the marker and neither wins.
|
|
179
|
+
*/
|
|
180
|
+
| "route_pair"
|
|
181
|
+
/**
|
|
182
|
+
* Preposition/deictic locator with no anchor — `gas station near me`, `restaurants nearby`. The query names a
|
|
183
|
+
* category and a relation to the ASKER, and the asker's position is not in the string. Classification only in v9: the
|
|
184
|
+
* marker states that a focus point is required and absent.
|
|
185
|
+
*/
|
|
186
|
+
| "near_me"
|
|
187
|
+
/**
|
|
188
|
+
* A bare POI category with nowhere to search — `tacos`, `grocery store`. The anchorless subset of `poi_query`,
|
|
189
|
+
* carrying the resolved `@mailwoman/poi-taxonomy` category id on its marker. Routes exactly as `poi_query` does (the
|
|
190
|
+
* coordinator's POI branch accepts both); resolution against `poi.db` is out of scope.
|
|
191
|
+
*/
|
|
192
|
+
| "poi_category"
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* The advisory codes an intent kind can raise. Named per the suggestion-layer plan's rules
|
|
196
|
+
* (`docs/superpowers/plans/2026-08-05-suggestion-layer.md` § Naming): never `*Coherence` (that vocabulary belongs to
|
|
197
|
+
* the passes that decide what the answer IS), and never `correction`/`validation`. This surface only ever REPORTS.
|
|
198
|
+
*/
|
|
199
|
+
export const QueryIntentCode = {
|
|
200
|
+
/**
|
|
201
|
+
* The query named a place, and the gazetteer's answer for that name is not decisive. Raised at RESOLVE time (the
|
|
202
|
+
* margin is a property of the candidate list, not of the string), so the classifier never emits it.
|
|
203
|
+
*/
|
|
204
|
+
DeclaredAmbiguity: "declared_ambiguity",
|
|
205
|
+
/**
|
|
206
|
+
* The query admits two whole readings and the pipeline is not choosing between them. `evidence.interpretations` names
|
|
207
|
+
* both.
|
|
208
|
+
*/
|
|
209
|
+
DeclaredFork: "declared_fork",
|
|
210
|
+
/**
|
|
211
|
+
* The query is relative to the asker and no focus point was supplied. `evidence.parameter` names the seam that would
|
|
212
|
+
* carry one.
|
|
213
|
+
*/
|
|
214
|
+
FocusPointRequired: "focus_point_required",
|
|
215
|
+
/**
|
|
216
|
+
* The query resolved to a POI taxonomy category. `evidence.categoryID` carries it.
|
|
217
|
+
*/
|
|
218
|
+
POICategory: "poi_category",
|
|
219
|
+
} as const
|
|
220
|
+
|
|
221
|
+
export type QueryIntentCode = (typeof QueryIntentCode)[keyof typeof QueryIntentCode]
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* One advisory the intent vocabulary raised about a query.
|
|
225
|
+
*
|
|
226
|
+
* Shaped after {@link PipelineFault} on purpose, and for the same reason: the caller needs to tell "the pipeline
|
|
227
|
+
* considered this and had something to say" apart from "the pipeline said nothing". A marker NEVER changes which answer
|
|
228
|
+
* wins — it is additive, attributed, and always accompanied by the ordinary result. `mechanism` follows the
|
|
229
|
+
* `family:rule` convention `PhraseProposal.source` established (`core/pipeline/span-proposer.ts`), so every marker
|
|
230
|
+
* names the rule that produced it rather than asserting itself.
|
|
231
|
+
*/
|
|
232
|
+
export interface QueryIntentMarker {
|
|
233
|
+
/**
|
|
234
|
+
* The intent kind that raised this marker. Present in {@link QueryKindResult} as either the top `kind` or an entry in
|
|
235
|
+
* `alternatives` — a marker whose kind appears in neither is a bug in the producer.
|
|
236
|
+
*/
|
|
237
|
+
kind: QueryKind
|
|
238
|
+
code: QueryIntentCode
|
|
239
|
+
/**
|
|
240
|
+
* `family:rule` — `kind:bare_toponym`, `kind:route_pair`, `resolver:dominance_margin`. Never `"unknown"`.
|
|
241
|
+
*/
|
|
242
|
+
mechanism: string
|
|
243
|
+
/**
|
|
244
|
+
* Human-readable, for a surface that shows it. Not machine-stable; branch on `code`.
|
|
245
|
+
*/
|
|
246
|
+
message: string
|
|
247
|
+
/**
|
|
248
|
+
* The measurement behind the marker, so it is auditable rather than assertive. Absent when the rule that fired had
|
|
249
|
+
* nothing to measure (meaning-of-zero: absent, never an empty object).
|
|
250
|
+
*/
|
|
251
|
+
evidence?: Record<string, unknown>
|
|
252
|
+
}
|
|
154
253
|
|
|
155
254
|
export interface QueryKindResult {
|
|
156
255
|
kind: QueryKind
|
|
157
256
|
confidence: number
|
|
158
257
|
alternatives: ReadonlyArray<{ kind: QueryKind; confidence: number }>
|
|
258
|
+
/**
|
|
259
|
+
* Advisories raised by the intent vocabulary (ROAD_TO_V9 §4). Optional on this interface — a pre-intent classifier
|
|
260
|
+
* (including `runtime-pipeline.ts`'s built-in default) simply doesn't set it — but `PipelineResult.intentMarkers` is
|
|
261
|
+
* always an array, so a consumer reading the RESULT never has to distinguish "absent" from "empty".
|
|
262
|
+
*/
|
|
263
|
+
intentMarkers?: ReadonlyArray<QueryIntentMarker>
|
|
159
264
|
}
|
|
160
265
|
|
|
161
266
|
/**
|
|
@@ -174,6 +279,10 @@ export type InputMode = "fragmented" | "formatted"
|
|
|
174
279
|
* (`structured_address`/`po_box`/`intersection`) are the formatted register; single-thing lookups (postcode, locality,
|
|
175
280
|
* landmark, POI, vague) are fragments. NEVER keyed on case — lowercase is the primary user register (operator
|
|
176
281
|
* doctrine).
|
|
282
|
+
*
|
|
283
|
+
* The four ROAD_TO_V9 §4 intent kinds are all fragments and all reach the register through the `default` arm, which is
|
|
284
|
+
* why adding them changed no case in this switch: a bare toponym, a route pair, a `near me` and a bare POI category are
|
|
285
|
+
* each a person typing one thing into a search box, never a form submitting a postal record.
|
|
177
286
|
*/
|
|
178
287
|
export function deriveInputMode(kind: QueryKind): InputMode {
|
|
179
288
|
switch (kind) {
|
|
@@ -197,6 +306,10 @@ export interface POIIntent {
|
|
|
197
306
|
| { kind: "category"; categoryID: string; matched: string }
|
|
198
307
|
| { kind: "brand"; name: string; wikidata?: string; matched: string }
|
|
199
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"
|
|
200
313
|
/**
|
|
201
314
|
* Spatial anchor: the split-off remainder text and its parse, when the query carried one.
|
|
202
315
|
*/
|
|
@@ -308,7 +421,7 @@ export interface FSTMatcherLike {
|
|
|
308
421
|
prev: { stateID: number; depth: number },
|
|
309
422
|
token: string
|
|
310
423
|
): { stateID: number; accepted: boolean; depth: number } | null
|
|
311
|
-
accepting(stateID: number): Array<{ wofID: number; placetype: string;
|
|
424
|
+
accepting(stateID: number): Array<{ wofID: number; placetype: string; referential: number }>
|
|
312
425
|
}
|
|
313
426
|
|
|
314
427
|
export interface ClassifierOpts {
|
|
@@ -381,7 +494,11 @@ export interface AddressClassifier {
|
|
|
381
494
|
export interface RuntimePipelineStages {
|
|
382
495
|
normalize?: (raw: string, opts?: { locale?: string }) => NormalizedInputLite
|
|
383
496
|
computeQueryShape?: (input: NormalizedInputLite | string, opts?: { locale?: string }) => QueryShapeLite
|
|
384
|
-
detectLocale?: (
|
|
497
|
+
detectLocale?: (
|
|
498
|
+
input: NormalizedInputLite,
|
|
499
|
+
shape: QueryShapeLite,
|
|
500
|
+
opts?: { hint?: LocaleTag; machinePreferences?: MachinePreferences; environmentLocale?: LocaleTag }
|
|
501
|
+
) => Promise<LocaleHint>
|
|
385
502
|
classifyKind?: (input: NormalizedInputLite, shape: QueryShapeLite, locale: LocaleHint) => Promise<QueryKindResult>
|
|
386
503
|
/**
|
|
387
504
|
* Coarse country router (#244). A `(normalizedText) → { country, confidence, posterior? }` predictor (a
|
|
@@ -499,6 +616,16 @@ export interface PipelineResult {
|
|
|
499
616
|
* Non-empty means the tree you are holding was produced with at least one stage down; see {@link PipelineFault}.
|
|
500
617
|
*/
|
|
501
618
|
faults: PipelineFault[]
|
|
619
|
+
/**
|
|
620
|
+
* Query-intent advisories (ROAD_TO_V9 §4), lifted from the kind classifier's verdict. **Always present** — an empty
|
|
621
|
+
* array is the coordinator stating that the intent vocabulary examined this query and had nothing to say, which is a
|
|
622
|
+
* different claim from a missing field (the {@link faults} discipline, same reasoning).
|
|
623
|
+
*
|
|
624
|
+
* Nothing here changed which answer won. The markers are advisory by construction: the two intent kinds that could
|
|
625
|
+
* have displaced a structural incumbent are scored below it, and the two that do win the top slot (`near_me`,
|
|
626
|
+
* `poi_category`) route exactly as their incumbents did.
|
|
627
|
+
*/
|
|
628
|
+
intentMarkers: QueryIntentMarker[]
|
|
502
629
|
/**
|
|
503
630
|
* Which path the coordinator took. `"fast-path"` skipped stages 3-5; `"poi"` took the intent branch.
|
|
504
631
|
*/
|
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.
|