@mailwoman/core 8.6.0 → 9.1.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 +2 -2
- package/api/clock.ts +1 -1
- package/api/disk-storage.ts +7 -4
- package/api/test-clocks.ts +57 -9
- package/api/test-transport.ts +182 -0
- package/coarse-placer/coarse-placer.ts +2 -1
- 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 +3 -2
- package/coarse-placer/tools/build-outlier-oa.ts +3 -2
- package/coarse-placer/tools/eval-latin-offmap.ts +8 -8
- package/coarse-placer/tools/eval-openset.ts +20 -12
- package/coarse-placer/tools/eval-quant-compare.ts +8 -9
- package/coarse-placer/tools/eval.ts +30 -23
- package/coarse-placer/tools/probe-frontier.ts +9 -7
- package/coarse-placer/tools/quantize.ts +4 -2
- package/coarse-placer/tools/train.ts +10 -10
- package/collections.ts +2 -128
- package/crypto/node.ts +68 -0
- package/decoder/build-tree.ts +19 -0
- package/env/schema.ts +58 -2
- package/fs/zip.ts +297 -0
- package/identifiers.ts +48 -0
- package/layers/manifest.ts +2 -1
- package/locale/profiles/en-us.ts +2 -3
- package/locale/profiles/fr-fr.ts +1 -1
- package/locale/profiles/ja-jp.ts +7 -7
- package/objects.ts +40 -8
- package/out/api/clock.d.ts +1 -1
- package/out/api/clock.js +1 -1
- package/out/api/disk-storage.d.ts +1 -1
- package/out/api/disk-storage.d.ts.map +1 -1
- package/out/api/disk-storage.js +5 -5
- package/out/api/disk-storage.js.map +1 -1
- package/out/api/test-clocks.d.ts +2 -2
- package/out/api/test-clocks.d.ts.map +1 -1
- package/out/api/test-clocks.js +51 -9
- package/out/api/test-clocks.js.map +1 -1
- package/out/api/test-transport.d.ts +112 -0
- package/out/api/test-transport.d.ts.map +1 -0
- package/out/api/test-transport.js +84 -0
- package/out/api/test-transport.js.map +1 -0
- package/out/coarse-placer/coarse-placer.d.ts.map +1 -1
- package/out/coarse-placer/coarse-placer.js +2 -1
- package/out/coarse-placer/coarse-placer.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 +2 -2
- 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 +2 -2
- 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 +5 -8
- 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 +12 -11
- 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 +7 -9
- 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 +20 -21
- package/out/coarse-placer/tools/eval.js.map +1 -1
- package/out/coarse-placer/tools/probe-frontier.d.ts.map +1 -1
- package/out/coarse-placer/tools/probe-frontier.js +8 -8
- 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 +3 -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 +7 -10
- package/out/coarse-placer/tools/train.js.map +1 -1
- package/out/collections.d.ts +1 -59
- package/out/collections.d.ts.map +1 -1
- package/out/collections.js +2 -90
- package/out/collections.js.map +1 -1
- package/out/crypto/node.d.ts +43 -0
- package/out/crypto/node.d.ts.map +1 -0
- package/out/crypto/node.js +43 -0
- package/out/crypto/node.js.map +1 -0
- 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/env/index.d.ts +8 -0
- package/out/env/index.d.ts.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 +54 -2
- package/out/env/schema.js.map +1 -1
- 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/identifiers.d.ts +23 -0
- package/out/identifiers.d.ts.map +1 -1
- package/out/identifiers.js +39 -0
- package/out/identifiers.js.map +1 -1
- package/out/layers/manifest.d.ts.map +1 -1
- package/out/layers/manifest.js +2 -1
- package/out/layers/manifest.js.map +1 -1
- package/out/locale/profiles/en-us.d.ts +2 -3
- package/out/locale/profiles/en-us.d.ts.map +1 -1
- package/out/locale/profiles/en-us.js +2 -3
- package/out/locale/profiles/en-us.js.map +1 -1
- package/out/locale/profiles/fr-fr.d.ts +1 -1
- package/out/locale/profiles/fr-fr.js +1 -1
- package/out/locale/profiles/ja-jp.d.ts +7 -7
- package/out/locale/profiles/ja-jp.js +7 -7
- package/out/objects.d.ts +18 -2
- package/out/objects.d.ts.map +1 -1
- package/out/objects.js +29 -3
- package/out/objects.js.map +1 -1
- package/out/pipeline/index.d.ts +2 -2
- package/out/pipeline/index.d.ts.map +1 -1
- package/out/pipeline/index.js +1 -1
- package/out/pipeline/index.js.map +1 -1
- package/out/pipeline/runtime-pipeline.d.ts +1 -1
- package/out/pipeline/runtime-pipeline.d.ts.map +1 -1
- package/out/pipeline/runtime-pipeline.js +74 -18
- package/out/pipeline/runtime-pipeline.js.map +1 -1
- package/out/pipeline/span-proposer.d.ts +24 -0
- package/out/pipeline/span-proposer.d.ts.map +1 -1
- package/out/pipeline/span-proposer.js +36 -1
- package/out/pipeline/span-proposer.js.map +1 -1
- package/out/pipeline/types.d.ts +155 -3
- package/out/pipeline/types.d.ts.map +1 -1
- package/out/pipeline/types.js +41 -1
- package/out/pipeline/types.js.map +1 -1
- package/out/resolver/index.d.ts +3 -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/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 +204 -0
- package/out/resolver/types.d.ts.map +1 -1
- package/out/resolver/types.js.map +1 -1
- package/out/resources/index.d.ts +0 -1
- package/out/resources/index.d.ts.map +1 -1
- package/out/resources/index.js +0 -1
- package/out/resources/index.js.map +1 -1
- package/out/resources/libpostal.d.ts.map +1 -1
- package/out/resources/libpostal.js +3 -4
- package/out/resources/libpostal.js.map +1 -1
- package/out/resources/whosonfirst/index.d.ts +1 -0
- package/out/resources/whosonfirst/index.d.ts.map +1 -1
- package/out/resources/whosonfirst/index.js +1 -0
- package/out/resources/whosonfirst/index.js.map +1 -1
- package/out/resources/whosonfirst/placetypes/Placetype.d.ts.map +1 -1
- package/out/resources/whosonfirst/placetypes/Placetype.js +6 -5
- package/out/resources/whosonfirst/placetypes/Placetype.js.map +1 -1
- package/out/resources/whosonfirst/placetypes/admin.d.ts +12 -3
- 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/sharded-repo.d.ts +28 -0
- package/out/resources/whosonfirst/sharded-repo.d.ts.map +1 -0
- package/out/resources/whosonfirst/sharded-repo.js +58 -0
- package/out/resources/whosonfirst/sharded-repo.js.map +1 -0
- package/out/scripting/utils/index.d.ts.map +1 -1
- package/out/scripting/utils/index.js +2 -2
- 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 +1 -0
- package/out/tools/download-libpostal-resources.js.map +1 -1
- package/out/tools/generate-language-types.d.ts.map +1 -1
- package/out/tools/generate-language-types.js +5 -11
- package/out/tools/generate-language-types.js.map +1 -1
- package/out/utils/data-root.d.ts +20 -6
- package/out/utils/data-root.d.ts.map +1 -1
- package/out/utils/data-root.js +24 -5
- package/out/utils/data-root.js.map +1 -1
- package/out/utils/hash.d.ts +6 -0
- package/out/utils/hash.d.ts.map +1 -1
- package/out/utils/hash.js +8 -0
- 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.d.ts +17 -3
- package/out/utils/jsonl.d.ts.map +1 -1
- package/out/utils/jsonl.js +23 -6
- package/out/utils/jsonl.js.map +1 -1
- package/out/utils/python-json.d.ts +3 -3
- package/out/utils/python-json.js +9 -9
- package/out/utils/python-numeric.d.ts +33 -0
- package/out/utils/python-numeric.d.ts.map +1 -0
- package/out/utils/python-numeric.js +149 -0
- package/out/utils/python-numeric.js.map +1 -0
- package/out/utils/python-random.d.ts +26 -1
- package/out/utils/python-random.d.ts.map +1 -1
- package/out/utils/python-random.js +43 -7
- package/out/utils/python-random.js.map +1 -1
- package/out/utils/repo.d.ts.map +1 -1
- package/out/utils/repo.js +18 -0
- package/out/utils/repo.js.map +1 -1
- package/out/utils/sealed-db.d.ts +12 -0
- package/out/utils/sealed-db.d.ts.map +1 -1
- package/out/utils/sealed-db.js +32 -1
- package/out/utils/sealed-db.js.map +1 -1
- package/package.json +34 -7
- package/pipeline/index.ts +3 -1
- package/pipeline/runtime-pipeline.ts +88 -27
- package/pipeline/span-proposer.ts +64 -1
- package/pipeline/types.ts +160 -2
- package/resolver/index.ts +13 -0
- package/resolver/referential.ts +84 -0
- package/resolver/types.ts +207 -0
- package/resources/index.ts +0 -1
- package/resources/libpostal.ts +8 -7
- package/resources/whosonfirst/index.ts +1 -0
- package/resources/whosonfirst/placetypes/Placetype.ts +13 -8
- package/resources/whosonfirst/placetypes/admin.ts +12 -2
- package/resources/whosonfirst/sharded-repo.ts +69 -0
- package/scripting/utils/index.ts +2 -3
- package/tools/download-libpostal-resources.ts +1 -0
- package/tools/generate-language-types.ts +5 -14
- package/utils/data-root.ts +27 -6
- package/utils/hash.ts +9 -0
- package/utils/index.ts +1 -0
- package/utils/jsonl.ts +26 -7
- package/utils/python-json.ts +10 -10
- package/utils/python-numeric.ts +168 -0
- package/utils/python-random.ts +49 -8
- package/utils/repo.ts +18 -0
- package/utils/sealed-db.ts +38 -1
- package/out/resources/collections.d.ts +0 -22
- package/out/resources/collections.d.ts.map +0 -1
- package/out/resources/collections.js +0 -69
- package/out/resources/collections.js.map +0 -1
- package/resources/collections.ts +0 -96
package/out/pipeline/types.d.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
* query-shape / resolver packages while still composing them at runtime when callers wire them
|
|
11
11
|
* up.
|
|
12
12
|
*
|
|
13
|
-
* See `docs/
|
|
13
|
+
* See `docs/engineering/reference/STAGES.md` for the full contract this implements.
|
|
14
14
|
*/
|
|
15
15
|
import type { AddressTree } from "../decoder/types.ts";
|
|
16
16
|
import type { ResolveOpts, Resolver, ResolverBackend } from "../resolver/types.ts";
|
|
@@ -150,7 +150,100 @@ export interface LocaleHint {
|
|
|
150
150
|
/**
|
|
151
151
|
* Kind classifier output.
|
|
152
152
|
*/
|
|
153
|
-
export type QueryKind = "postcode_only" | "locality_only" | "structured_address" | "intersection" | "po_box" | "landmark" | "poi_query" | "vague"
|
|
153
|
+
export type QueryKind = "postcode_only" | "locality_only" | "structured_address" | "intersection" | "po_box" | "landmark" | "poi_query" | "vague"
|
|
154
|
+
/**
|
|
155
|
+
* ROAD_TO_V9 §4 — the query-INTENT vocabulary. Four kinds that describe what the user is ASKING FOR rather than what
|
|
156
|
+
* their string is shaped like. They are ordinary members of this union (intent is vocabulary of the existing Stage
|
|
157
|
+
* 2.5, never a new stage), and each one, when it fires, attaches a {@link QueryIntentMarker} to the result.
|
|
158
|
+
*
|
|
159
|
+
* Two of the four are deliberately RANKED BELOW their structural incumbent and therefore surface in
|
|
160
|
+
* {@link QueryKindResult.alternatives} rather than as the top kind — see the individual docstrings in
|
|
161
|
+
* `@mailwoman/kind-classifier`'s `intent-rules.ts`. That is the D-rule discharge: the top kind is the only thing the
|
|
162
|
+
* coordinator routes on (`deriveInputMode`, `canShortCircuit`, the POI branch), so leaving it untouched is what makes
|
|
163
|
+
* the addition provably answer-neutral on the populations those incumbents already own.
|
|
164
|
+
*/
|
|
165
|
+
/**
|
|
166
|
+
* A single coherent place-name carrying no address grammar — no house number, no postcode, no street-type word. A
|
|
167
|
+
* strict REFINEMENT of `locality_only` (which also admits an admin tail: `Paris, FR`), scored just below it so the
|
|
168
|
+
* top kind never moves. Feeds the declared-ambiguity path: a bare toponym whose resolved candidates are not DECISIVE
|
|
169
|
+
* gets a `declared_ambiguity` marker at geocode time.
|
|
170
|
+
*/
|
|
171
|
+
| "bare_toponym"
|
|
172
|
+
/**
|
|
173
|
+
* Two coherent toponyms with no address grammar between them — `Paris London`. Classification plus a DECLARED FORK,
|
|
174
|
+
* never a router (ROAD_TO_V9 §4.3): structure alone cannot separate a route pair from a comma-free locality+region
|
|
175
|
+
* fragment (`Moscow Idaho`), so both interpretations are named in the marker and neither wins.
|
|
176
|
+
*/
|
|
177
|
+
| "route_pair"
|
|
178
|
+
/**
|
|
179
|
+
* Preposition/deictic locator with no anchor — `gas station near me`, `restaurants nearby`. The query names a
|
|
180
|
+
* category and a relation to the ASKER, and the asker's position is not in the string. Classification only in v9: the
|
|
181
|
+
* marker states that a focus point is required and absent.
|
|
182
|
+
*/
|
|
183
|
+
| "near_me"
|
|
184
|
+
/**
|
|
185
|
+
* A bare POI category with nowhere to search — `tacos`, `grocery store`. The anchorless subset of `poi_query`,
|
|
186
|
+
* carrying the resolved `@mailwoman/poi-taxonomy` category id on its marker. Routes exactly as `poi_query` does (the
|
|
187
|
+
* coordinator's POI branch accepts both); resolution against `poi.db` is out of scope.
|
|
188
|
+
*/
|
|
189
|
+
| "poi_category";
|
|
190
|
+
/**
|
|
191
|
+
* The advisory codes an intent kind can raise. Named per the suggestion-layer plan's rules
|
|
192
|
+
* (`docs/superpowers/plans/2026-08-05-suggestion-layer.md` § Naming): never `*Coherence` (that vocabulary belongs to
|
|
193
|
+
* the passes that decide what the answer IS), and never `correction`/`validation`. This surface only ever REPORTS.
|
|
194
|
+
*/
|
|
195
|
+
export declare const QueryIntentCode: {
|
|
196
|
+
/**
|
|
197
|
+
* The query named a place, and the gazetteer's answer for that name is not decisive. Raised at RESOLVE time (the
|
|
198
|
+
* margin is a property of the candidate list, not of the string), so the classifier never emits it.
|
|
199
|
+
*/
|
|
200
|
+
readonly DeclaredAmbiguity: "declared_ambiguity";
|
|
201
|
+
/**
|
|
202
|
+
* The query admits two whole readings and the pipeline is not choosing between them. `evidence.interpretations` names
|
|
203
|
+
* both.
|
|
204
|
+
*/
|
|
205
|
+
readonly DeclaredFork: "declared_fork";
|
|
206
|
+
/**
|
|
207
|
+
* The query is relative to the asker and no focus point was supplied. `evidence.parameter` names the seam that would
|
|
208
|
+
* carry one.
|
|
209
|
+
*/
|
|
210
|
+
readonly FocusPointRequired: "focus_point_required";
|
|
211
|
+
/**
|
|
212
|
+
* The query resolved to a POI taxonomy category. `evidence.categoryID` carries it.
|
|
213
|
+
*/
|
|
214
|
+
readonly POICategory: "poi_category";
|
|
215
|
+
};
|
|
216
|
+
export type QueryIntentCode = (typeof QueryIntentCode)[keyof typeof QueryIntentCode];
|
|
217
|
+
/**
|
|
218
|
+
* One advisory the intent vocabulary raised about a query.
|
|
219
|
+
*
|
|
220
|
+
* Shaped after {@link PipelineFault} on purpose, and for the same reason: the caller needs to tell "the pipeline
|
|
221
|
+
* considered this and had something to say" apart from "the pipeline said nothing". A marker NEVER changes which answer
|
|
222
|
+
* wins — it is additive, attributed, and always accompanied by the ordinary result. `mechanism` follows the
|
|
223
|
+
* `family:rule` convention `PhraseProposal.source` established (`core/pipeline/span-proposer.ts`), so every marker
|
|
224
|
+
* names the rule that produced it rather than asserting itself.
|
|
225
|
+
*/
|
|
226
|
+
export interface QueryIntentMarker {
|
|
227
|
+
/**
|
|
228
|
+
* The intent kind that raised this marker. Present in {@link QueryKindResult} as either the top `kind` or an entry in
|
|
229
|
+
* `alternatives` — a marker whose kind appears in neither is a bug in the producer.
|
|
230
|
+
*/
|
|
231
|
+
kind: QueryKind;
|
|
232
|
+
code: QueryIntentCode;
|
|
233
|
+
/**
|
|
234
|
+
* `family:rule` — `kind:bare_toponym`, `kind:route_pair`, `resolver:dominance_margin`. Never `"unknown"`.
|
|
235
|
+
*/
|
|
236
|
+
mechanism: string;
|
|
237
|
+
/**
|
|
238
|
+
* Human-readable, for a surface that shows it. Not machine-stable; branch on `code`.
|
|
239
|
+
*/
|
|
240
|
+
message: string;
|
|
241
|
+
/**
|
|
242
|
+
* The measurement behind the marker, so it is auditable rather than assertive. Absent when the rule that fired had
|
|
243
|
+
* nothing to measure (meaning-of-zero: absent, never an empty object).
|
|
244
|
+
*/
|
|
245
|
+
evidence?: Record<string, unknown>;
|
|
246
|
+
}
|
|
154
247
|
export interface QueryKindResult {
|
|
155
248
|
kind: QueryKind;
|
|
156
249
|
confidence: number;
|
|
@@ -158,6 +251,12 @@ export interface QueryKindResult {
|
|
|
158
251
|
kind: QueryKind;
|
|
159
252
|
confidence: number;
|
|
160
253
|
}>;
|
|
254
|
+
/**
|
|
255
|
+
* Advisories raised by the intent vocabulary (ROAD_TO_V9 §4). Optional on this interface — a pre-intent classifier
|
|
256
|
+
* (including `runtime-pipeline.ts`'s built-in default) simply doesn't set it — but `PipelineResult.intentMarkers` is
|
|
257
|
+
* always an array, so a consumer reading the RESULT never has to distinguish "absent" from "empty".
|
|
258
|
+
*/
|
|
259
|
+
intentMarkers?: ReadonlyArray<QueryIntentMarker>;
|
|
161
260
|
}
|
|
162
261
|
/**
|
|
163
262
|
* The input register (operator Decision A, 2026-07-28 — the Option-A evidence-bundle verdict): `fragmented` is the
|
|
@@ -174,6 +273,10 @@ export type InputMode = "fragmented" | "formatted";
|
|
|
174
273
|
* (`structured_address`/`po_box`/`intersection`) are the formatted register; single-thing lookups (postcode, locality,
|
|
175
274
|
* landmark, POI, vague) are fragments. NEVER keyed on case — lowercase is the primary user register (operator
|
|
176
275
|
* doctrine).
|
|
276
|
+
*
|
|
277
|
+
* The four ROAD_TO_V9 §4 intent kinds are all fragments and all reach the register through the `default` arm, which is
|
|
278
|
+
* why adding them changed no case in this switch: a bare toponym, a route pair, a `near me` and a bare POI category are
|
|
279
|
+
* each a person typing one thing into a search box, never a form submitting a postal record.
|
|
177
280
|
*/
|
|
178
281
|
export declare function deriveInputMode(kind: QueryKind): InputMode;
|
|
179
282
|
/**
|
|
@@ -317,7 +420,7 @@ export interface FSTMatcherLike {
|
|
|
317
420
|
accepting(stateID: number): Array<{
|
|
318
421
|
wofID: number;
|
|
319
422
|
placetype: string;
|
|
320
|
-
|
|
423
|
+
referential: number;
|
|
321
424
|
}>;
|
|
322
425
|
}
|
|
323
426
|
export interface ClassifierOpts {
|
|
@@ -451,6 +554,39 @@ export interface RuntimePipelineStages {
|
|
|
451
554
|
resolverBackend?: ResolverBackend;
|
|
452
555
|
}
|
|
453
556
|
export type PipelineTiming = Record<string, number>;
|
|
557
|
+
/**
|
|
558
|
+
* The stages whose defensive wrapper degrades instead of aborting the pipeline. One id per `safe*` wrapper in
|
|
559
|
+
* `runtime-pipeline.ts`; the ids are the wrapper's, not the timing map's, because a fault is about the injected stage
|
|
560
|
+
* (`classifier`), not the phase that ran it (`token-classify`).
|
|
561
|
+
*/
|
|
562
|
+
export declare const PipelineFaultStage: {
|
|
563
|
+
readonly Classifier: "classifier";
|
|
564
|
+
readonly PhraseGrouper: "phrase-grouper";
|
|
565
|
+
readonly Resolver: "resolver";
|
|
566
|
+
};
|
|
567
|
+
export type PipelineFaultStage = (typeof PipelineFaultStage)[keyof typeof PipelineFaultStage];
|
|
568
|
+
/**
|
|
569
|
+
* One stage crash the coordinator caught and degraded past.
|
|
570
|
+
*
|
|
571
|
+
* A fault is NOT an error return: `runPipeline` still resolves, and `tree` still carries whatever the remaining stages
|
|
572
|
+
* could prove. What the fault buys the caller is the ability to tell "the model faulted and the rule-based stages
|
|
573
|
+
* filled the tree back in" apart from "the model ran and found nothing" — which, before #40, was impossible from the
|
|
574
|
+
* outside. See the `safeClassify` docstring for the measured failure this was written against.
|
|
575
|
+
*/
|
|
576
|
+
export interface PipelineFault {
|
|
577
|
+
stage: PipelineFaultStage;
|
|
578
|
+
/**
|
|
579
|
+
* The thrown value's `name` (`TypeError`, `RangeError`, …), or `"Error"` when something that isn't an `Error` was
|
|
580
|
+
* thrown. Machine-stable enough to branch on; the `cause` carries the rest.
|
|
581
|
+
*/
|
|
582
|
+
name: string;
|
|
583
|
+
message: string;
|
|
584
|
+
/**
|
|
585
|
+
* The value the stage threw, verbatim — kept so a caller can rethrow it or read its stack. Not JSON-serializable in
|
|
586
|
+
* the useful sense; serialize `stage`/`name`/`message` when you need this on a wire.
|
|
587
|
+
*/
|
|
588
|
+
cause: unknown;
|
|
589
|
+
}
|
|
454
590
|
/**
|
|
455
591
|
* Result of one `runPipeline` call.
|
|
456
592
|
*/
|
|
@@ -472,6 +608,22 @@ export interface PipelineResult {
|
|
|
472
608
|
*/
|
|
473
609
|
poiIntent?: POIIntentOutcome;
|
|
474
610
|
timing: PipelineTiming;
|
|
611
|
+
/**
|
|
612
|
+
* Every stage crash the coordinator caught and degraded past, in the order they happened. **Always present** — an
|
|
613
|
+
* empty array is the coordinator stating that no stage faulted, which is a different claim from a missing field.
|
|
614
|
+
* Non-empty means the tree you are holding was produced with at least one stage down; see {@link PipelineFault}.
|
|
615
|
+
*/
|
|
616
|
+
faults: PipelineFault[];
|
|
617
|
+
/**
|
|
618
|
+
* Query-intent advisories (ROAD_TO_V9 §4), lifted from the kind classifier's verdict. **Always present** — an empty
|
|
619
|
+
* array is the coordinator stating that the intent vocabulary examined this query and had nothing to say, which is a
|
|
620
|
+
* different claim from a missing field (the {@link faults} discipline, same reasoning).
|
|
621
|
+
*
|
|
622
|
+
* Nothing here changed which answer won. The markers are advisory by construction: the two intent kinds that could
|
|
623
|
+
* have displaced a structural incumbent are scored below it, and the two that do win the top slot (`near_me`,
|
|
624
|
+
* `poi_category`) route exactly as their incumbents did.
|
|
625
|
+
*/
|
|
626
|
+
intentMarkers: QueryIntentMarker[];
|
|
475
627
|
/**
|
|
476
628
|
* Which path the coordinator took. `"fast-path"` skipped stages 3-5; `"poi"` took the intent branch.
|
|
477
629
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../pipeline/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAA;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAClF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAA;AAErD,MAAM,MAAM,SAAS,GAAG,MAAM,CAAA;AAE9B;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAA;AAEnH;;;;;;GAMG;AACH,MAAM,MAAM,wBAAwB,GAAG,MAA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IACH,eAAe,CAAC,EAAE,eAAe,CAAA;CACjC;AAED,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;AAEnD;;;;GAIG;AACH,eAAO,MAAM,kBAAkB;;;;CAIrB,CAAA;AAEV,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,OAAO,kBAAkB,CAAC,CAAA;AAE7F;;;;;;;GAOG;AACH,MAAM,WAAW,aAAa;IAC7B,KAAK,EAAE,kBAAkB,CAAA;IACzB;;;OAGG;IACH,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf;;;OAGG;IACH,KAAK,EAAE,OAAO,CAAA;CACd;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC9B,KAAK,EAAE,MAAM,CAAA;IACb,UAAU,EAAE,mBAAmB,CAAA;IAC/B,UAAU,EAAE,cAAc,CAAA;IAC1B,MAAM,EAAE,UAAU,CAAA;IAClB,IAAI,EAAE,eAAe,CAAA;IACrB;;;;OAIG;IACH,eAAe,EAAE,cAAc,EAAE,CAAA;IACjC,IAAI,EAAE,WAAW,CAAA;IACjB;;OAEG;IACH,SAAS,CAAC,EAAE,gBAAgB,CAAA;IAC5B,MAAM,EAAE,cAAc,CAAA;IACtB;;;;OAIG;IACH,MAAM,EAAE,aAAa,EAAE,CAAA;IACvB;;;;;;;;OAQG;IACH,aAAa,EAAE,iBAAiB,EAAE,CAAA;IAClC;;OAEG;IACH,IAAI,EAAE,WAAW,GAAG,MAAM,GAAG,KAAK,CAAA;CAClC"}
|
package/out/pipeline/types.js
CHANGED
|
@@ -10,13 +10,43 @@
|
|
|
10
10
|
* query-shape / resolver packages while still composing them at runtime when callers wire them
|
|
11
11
|
* up.
|
|
12
12
|
*
|
|
13
|
-
* See `docs/
|
|
13
|
+
* See `docs/engineering/reference/STAGES.md` for the full contract this implements.
|
|
14
14
|
*/
|
|
15
|
+
/**
|
|
16
|
+
* The advisory codes an intent kind can raise. Named per the suggestion-layer plan's rules
|
|
17
|
+
* (`docs/superpowers/plans/2026-08-05-suggestion-layer.md` § Naming): never `*Coherence` (that vocabulary belongs to
|
|
18
|
+
* the passes that decide what the answer IS), and never `correction`/`validation`. This surface only ever REPORTS.
|
|
19
|
+
*/
|
|
20
|
+
export const QueryIntentCode = {
|
|
21
|
+
/**
|
|
22
|
+
* The query named a place, and the gazetteer's answer for that name is not decisive. Raised at RESOLVE time (the
|
|
23
|
+
* margin is a property of the candidate list, not of the string), so the classifier never emits it.
|
|
24
|
+
*/
|
|
25
|
+
DeclaredAmbiguity: "declared_ambiguity",
|
|
26
|
+
/**
|
|
27
|
+
* The query admits two whole readings and the pipeline is not choosing between them. `evidence.interpretations` names
|
|
28
|
+
* both.
|
|
29
|
+
*/
|
|
30
|
+
DeclaredFork: "declared_fork",
|
|
31
|
+
/**
|
|
32
|
+
* The query is relative to the asker and no focus point was supplied. `evidence.parameter` names the seam that would
|
|
33
|
+
* carry one.
|
|
34
|
+
*/
|
|
35
|
+
FocusPointRequired: "focus_point_required",
|
|
36
|
+
/**
|
|
37
|
+
* The query resolved to a POI taxonomy category. `evidence.categoryID` carries it.
|
|
38
|
+
*/
|
|
39
|
+
POICategory: "poi_category",
|
|
40
|
+
};
|
|
15
41
|
/**
|
|
16
42
|
* Map a {@link QueryKind} to its {@link InputMode} register. Multi-component postal specifications
|
|
17
43
|
* (`structured_address`/`po_box`/`intersection`) are the formatted register; single-thing lookups (postcode, locality,
|
|
18
44
|
* landmark, POI, vague) are fragments. NEVER keyed on case — lowercase is the primary user register (operator
|
|
19
45
|
* doctrine).
|
|
46
|
+
*
|
|
47
|
+
* The four ROAD_TO_V9 §4 intent kinds are all fragments and all reach the register through the `default` arm, which is
|
|
48
|
+
* why adding them changed no case in this switch: a bare toponym, a route pair, a `near me` and a bare POI category are
|
|
49
|
+
* each a person typing one thing into a search box, never a form submitting a postal record.
|
|
20
50
|
*/
|
|
21
51
|
export function deriveInputMode(kind) {
|
|
22
52
|
switch (kind) {
|
|
@@ -38,4 +68,14 @@ export const WORD_CONSISTENCY_SHIP_DEFAULT = {
|
|
|
38
68
|
skipByteFallbackWords: true,
|
|
39
69
|
splitOnPunctuation: true,
|
|
40
70
|
};
|
|
71
|
+
/**
|
|
72
|
+
* The stages whose defensive wrapper degrades instead of aborting the pipeline. One id per `safe*` wrapper in
|
|
73
|
+
* `runtime-pipeline.ts`; the ids are the wrapper's, not the timing map's, because a fault is about the injected stage
|
|
74
|
+
* (`classifier`), not the phase that ran it (`token-classify`).
|
|
75
|
+
*/
|
|
76
|
+
export const PipelineFaultStage = {
|
|
77
|
+
Classifier: "classifier",
|
|
78
|
+
PhraseGrouper: "phrase-grouper",
|
|
79
|
+
Resolver: "resolver",
|
|
80
|
+
};
|
|
41
81
|
//# sourceMappingURL=types.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../pipeline/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../pipeline/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAiLH;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC9B;;;OAGG;IACH,iBAAiB,EAAE,oBAAoB;IACvC;;;OAGG;IACH,YAAY,EAAE,eAAe;IAC7B;;;OAGG;IACH,kBAAkB,EAAE,sBAAsB;IAC1C;;OAEG;IACH,WAAW,EAAE,cAAc;CAClB,CAAA;AA0DV;;;;;;;;;GASG;AACH,MAAM,UAAU,eAAe,CAAC,IAAe;IAC9C,QAAQ,IAAI,EAAE,CAAC;QACd,KAAK,oBAAoB,CAAC;QAC1B,KAAK,QAAQ,CAAC;QACd,KAAK,cAAc;YAClB,OAAO,WAAW,CAAA;QACnB;YACC,OAAO,YAAY,CAAA;IACrB,CAAC;AACF,CAAC;AA8KD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,6BAA6B,GAAG;IAC5C,qBAAqB,EAAE,IAAI;IAC3B,kBAAkB,EAAE,IAAI;CACoC,CAAA;AAqE7D;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IACjC,UAAU,EAAE,YAAY;IACxB,aAAa,EAAE,gBAAgB;IAC/B,QAAQ,EAAE,UAAU;CACX,CAAA"}
|
package/out/resolver/index.d.ts
CHANGED
|
@@ -10,6 +10,8 @@
|
|
|
10
10
|
* `@mailwoman/resolver` (#215), which depends on this + `@mailwoman/spatial` +
|
|
11
11
|
* `@mailwoman/codex`.
|
|
12
12
|
*/
|
|
13
|
+
export { compareReferential, REFERENTIAL_LOG2_SCALE, REFERENTIAL_POPULATION_DIVISOR, REFERENTIAL_SATURATION_POPULATION, referentialFromPopulation, } from "./referential.ts";
|
|
14
|
+
export type { ReferentiallyRankable } from "./referential.ts";
|
|
13
15
|
export { DEFAULT_PLACETYPE_MAP, PLACETYPE_FILTER_GROUPS, expandPlacetypeFilter, hardCountrySafelistFromCoverage, isPlacetypeFallback, } from "./types.ts";
|
|
14
|
-
export type { AddressPointHit, AddressPointLookup, Ancestor, CoincidentLocality, CountryBBoxFact, CountryCoverageFact, GazetteerArtifactCoverage, InterpolatedPointHit, InterpolationLookup, PlacetypeMap, ResolveOpts, ResolvedPlace, Resolver, ResolverBackend, StreetCentroidHit, StreetCentroidLookup, } from "./types.ts";
|
|
16
|
+
export type { AddressPointHit, AddressPointLookup, Ancestor, CoincidentLocality, CountryBBoxFact, CountryCoverageFact, GazetteerArtifactCoverage, InterpolatedPointHit, InterpolationLookup, PlacetypeMap, PostcodePrefixAncestor, PostcodePrefixIndexLike, PostcodePrefixNode, ResolveOpts, ResolvedPlace, Resolver, ResolverBackend, StreetCentroidHit, StreetCentroidLookup, } from "./types.ts";
|
|
15
17
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../resolver/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACN,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACrB,+BAA+B,EAC/B,mBAAmB,GACnB,MAAM,YAAY,CAAA;AAEnB,YAAY,EACX,eAAe,EACf,kBAAkB,EAClB,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,mBAAmB,EACnB,yBAAyB,EACzB,oBAAoB,EACpB,mBAAmB,EACnB,YAAY,EACZ,WAAW,EACX,aAAa,EACb,QAAQ,EACR,eAAe,EACf,iBAAiB,EACjB,oBAAoB,GACpB,MAAM,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../resolver/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACN,kBAAkB,EAClB,sBAAsB,EACtB,8BAA8B,EAC9B,iCAAiC,EACjC,yBAAyB,GACzB,MAAM,kBAAkB,CAAA;AAEzB,YAAY,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAA;AAE7D,OAAO,EACN,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACrB,+BAA+B,EAC/B,mBAAmB,GACnB,MAAM,YAAY,CAAA;AAEnB,YAAY,EACX,eAAe,EACf,kBAAkB,EAClB,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,mBAAmB,EACnB,yBAAyB,EACzB,oBAAoB,EACpB,mBAAmB,EACnB,YAAY,EACZ,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,EAClB,WAAW,EACX,aAAa,EACb,QAAQ,EACR,eAAe,EACf,iBAAiB,EACjB,oBAAoB,GACpB,MAAM,YAAY,CAAA"}
|
package/out/resolver/index.js
CHANGED
|
@@ -10,5 +10,6 @@
|
|
|
10
10
|
* `@mailwoman/resolver` (#215), which depends on this + `@mailwoman/spatial` +
|
|
11
11
|
* `@mailwoman/codex`.
|
|
12
12
|
*/
|
|
13
|
+
export { compareReferential, REFERENTIAL_LOG2_SCALE, REFERENTIAL_POPULATION_DIVISOR, REFERENTIAL_SATURATION_POPULATION, referentialFromPopulation, } from "./referential.js";
|
|
13
14
|
export { DEFAULT_PLACETYPE_MAP, PLACETYPE_FILTER_GROUPS, expandPlacetypeFilter, hardCountrySafelistFromCoverage, isPlacetypeFallback, } from "./types.js";
|
|
14
15
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../resolver/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACN,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACrB,+BAA+B,EAC/B,mBAAmB,GACnB,MAAM,YAAY,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../resolver/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EACN,kBAAkB,EAClB,sBAAsB,EACtB,8BAA8B,EAC9B,iCAAiC,EACjC,yBAAyB,GACzB,MAAM,kBAAkB,CAAA;AAIzB,OAAO,EACN,qBAAqB,EACrB,uBAAuB,EACvB,qBAAqB,EACrB,+BAA+B,EAC/B,mBAAmB,GACnB,MAAM,YAAY,CAAA"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The REFERENTIAL score and its comparator — the ranking half of the two-score split (ROAD_TO_V9 §2
|
|
7
|
+
* R1, ratified 2026-08-06).
|
|
8
|
+
*
|
|
9
|
+
* THE POLICY. "The importance of a knowledge-base article is not the probability that this is the
|
|
10
|
+
* place the user means." A geocoder ranks by REFERENTIAL likelihood; encyclopedic importance is
|
|
11
|
+
* carried as data and is never a ranking key. Saint-Denis is the canonical case: the
|
|
12
|
+
* Seine-Saint-Denis suburb (pop 96,128) carries encyclopedic 0.1173 and the Aude hamlet (pop 418)
|
|
13
|
+
* carries 0.5683, so encyclopedic ranking inverts the answer every user means, by 4.8x.
|
|
14
|
+
*
|
|
15
|
+
* WHY THIS LIVES IN `@mailwoman/core`. Three packages need the same number and must not drift:
|
|
16
|
+
* `@mailwoman/resolver` (backend-agnostic — it cannot import a backend),
|
|
17
|
+
* `@mailwoman/resolver-wof-sqlite` (the gazetteer schema + both lookups), and the FST builder that
|
|
18
|
+
* stamps referential scores into the decode-bias artifact. `core/resolver/types.ts` already owns the
|
|
19
|
+
* `ResolvedPlace` contract these three share, so the score that contract carries belongs beside it.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Population divisor in {@link referentialFromPopulation}. A 1,000-person place scores `log2(2)/14` — the curve starts
|
|
23
|
+
* counting at the scale where WOF actually records population.
|
|
24
|
+
*/
|
|
25
|
+
export declare const REFERENTIAL_POPULATION_DIVISOR = 1000;
|
|
26
|
+
/**
|
|
27
|
+
* Log2 denominator in {@link referentialFromPopulation}. 14 puts the ceiling at `2^14 · 1000` people.
|
|
28
|
+
*/
|
|
29
|
+
export declare const REFERENTIAL_LOG2_SCALE = 14;
|
|
30
|
+
/**
|
|
31
|
+
* The population at which {@link referentialFromPopulation} saturates at exactly 1.0: `(2^14 − 1) · 1000` = 16,383,000.
|
|
32
|
+
*
|
|
33
|
+
* Load-bearing, not trivia. Above this the score CLAMPS, so two megacities that population would order (Tokyo ~37 M vs
|
|
34
|
+
* Delhi ~33 M) tie at 1.0. Any ranking keyed on referential alone must break that tie on raw population to stay
|
|
35
|
+
* ordering-identical to the population-first path — which is exactly what {@link compareReferential} does, and why it
|
|
36
|
+
* exists rather than a bare subtraction at each call site.
|
|
37
|
+
*/
|
|
38
|
+
export declare const REFERENTIAL_SATURATION_POPULATION: number;
|
|
39
|
+
/**
|
|
40
|
+
* Population → referential likelihood in [0, 1].
|
|
41
|
+
*
|
|
42
|
+
* `min(1, log2(1 + pop/1000) / 14)` — the formula the FST builder has used for its population fallback since the FST
|
|
43
|
+
* shipped, and the one `gazetteer importance` used for its fallback rows. It is defined ONCE here so the decode-bias
|
|
44
|
+
* artifact's values, the gazetteer's `referential` column, and the resolver's ranking key are the same number by
|
|
45
|
+
* construction rather than by three matching copies.
|
|
46
|
+
*
|
|
47
|
+
* MEANING OF ZERO: an absent population row and a recorded population of 0 both return 0, and 0 means "no population
|
|
48
|
+
* evidence" — the ranking treats it as no boost, never a penalty. WOF carries population for roughly 15% of localities,
|
|
49
|
+
* so absence is the common case and must stay cheap.
|
|
50
|
+
*/
|
|
51
|
+
export declare function referentialFromPopulation(population: number | null | undefined): number;
|
|
52
|
+
/**
|
|
53
|
+
* A thing that can be ranked referentially. Both fields optional — a candidate with neither sorts last, which is the
|
|
54
|
+
* same place a candidate with no population has always sorted.
|
|
55
|
+
*/
|
|
56
|
+
export interface ReferentiallyRankable {
|
|
57
|
+
referential?: number;
|
|
58
|
+
population?: number;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* The ranking comparator: referential DESC, raw population DESC as the tiebreak. Negative when `a` outranks `b`, so it
|
|
62
|
+
* drops straight into `Array#sort`.
|
|
63
|
+
*
|
|
64
|
+
* The population tiebreak is not a hedge — it is what makes "rank by referential" and "rank by population" the SAME
|
|
65
|
+
* ORDER on every input, because {@link referentialFromPopulation} is strictly increasing below
|
|
66
|
+
* {@link REFERENTIAL_SATURATION_POPULATION} and constant above it. Without the tiebreak this comparator would silently
|
|
67
|
+
* re-order the world's largest cities: a real behavior change, and the one the D-rule would catch.
|
|
68
|
+
*
|
|
69
|
+
* Encyclopedic importance is deliberately not a parameter. Ranking by it is the thing §2 forbids, and a comparator that
|
|
70
|
+
* cannot express it is a stronger guarantee than a comment asking nobody to.
|
|
71
|
+
*/
|
|
72
|
+
export declare function compareReferential(a: ReferentiallyRankable, b: ReferentiallyRankable): number;
|
|
73
|
+
//# sourceMappingURL=referential.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"referential.d.ts","sourceRoot":"","sources":["../../resolver/referential.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;;GAGG;AACH,eAAO,MAAM,8BAA8B,OAAO,CAAA;AAElD;;GAEG;AACH,eAAO,MAAM,sBAAsB,KAAK,CAAA;AAExC;;;;;;;GAOG;AACH,eAAO,MAAM,iCAAiC,QAAqE,CAAA;AAEnH;;;;;;;;;;;GAWG;AACH,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAIvF;AAED;;;GAGG;AACH,MAAM,WAAW,qBAAqB;IACrC,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,EAAE,qBAAqB,EAAE,CAAC,EAAE,qBAAqB,GAAG,MAAM,CAE7F"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @copyright Sister Software
|
|
3
|
+
* @license AGPL-3.0
|
|
4
|
+
* @author Teffen Ellis, et al.
|
|
5
|
+
*
|
|
6
|
+
* The REFERENTIAL score and its comparator — the ranking half of the two-score split (ROAD_TO_V9 §2
|
|
7
|
+
* R1, ratified 2026-08-06).
|
|
8
|
+
*
|
|
9
|
+
* THE POLICY. "The importance of a knowledge-base article is not the probability that this is the
|
|
10
|
+
* place the user means." A geocoder ranks by REFERENTIAL likelihood; encyclopedic importance is
|
|
11
|
+
* carried as data and is never a ranking key. Saint-Denis is the canonical case: the
|
|
12
|
+
* Seine-Saint-Denis suburb (pop 96,128) carries encyclopedic 0.1173 and the Aude hamlet (pop 418)
|
|
13
|
+
* carries 0.5683, so encyclopedic ranking inverts the answer every user means, by 4.8x.
|
|
14
|
+
*
|
|
15
|
+
* WHY THIS LIVES IN `@mailwoman/core`. Three packages need the same number and must not drift:
|
|
16
|
+
* `@mailwoman/resolver` (backend-agnostic — it cannot import a backend),
|
|
17
|
+
* `@mailwoman/resolver-wof-sqlite` (the gazetteer schema + both lookups), and the FST builder that
|
|
18
|
+
* stamps referential scores into the decode-bias artifact. `core/resolver/types.ts` already owns the
|
|
19
|
+
* `ResolvedPlace` contract these three share, so the score that contract carries belongs beside it.
|
|
20
|
+
*/
|
|
21
|
+
/**
|
|
22
|
+
* Population divisor in {@link referentialFromPopulation}. A 1,000-person place scores `log2(2)/14` — the curve starts
|
|
23
|
+
* counting at the scale where WOF actually records population.
|
|
24
|
+
*/
|
|
25
|
+
export const REFERENTIAL_POPULATION_DIVISOR = 1000;
|
|
26
|
+
/**
|
|
27
|
+
* Log2 denominator in {@link referentialFromPopulation}. 14 puts the ceiling at `2^14 · 1000` people.
|
|
28
|
+
*/
|
|
29
|
+
export const REFERENTIAL_LOG2_SCALE = 14;
|
|
30
|
+
/**
|
|
31
|
+
* The population at which {@link referentialFromPopulation} saturates at exactly 1.0: `(2^14 − 1) · 1000` = 16,383,000.
|
|
32
|
+
*
|
|
33
|
+
* Load-bearing, not trivia. Above this the score CLAMPS, so two megacities that population would order (Tokyo ~37 M vs
|
|
34
|
+
* Delhi ~33 M) tie at 1.0. Any ranking keyed on referential alone must break that tie on raw population to stay
|
|
35
|
+
* ordering-identical to the population-first path — which is exactly what {@link compareReferential} does, and why it
|
|
36
|
+
* exists rather than a bare subtraction at each call site.
|
|
37
|
+
*/
|
|
38
|
+
export const REFERENTIAL_SATURATION_POPULATION = (2 ** REFERENTIAL_LOG2_SCALE - 1) * REFERENTIAL_POPULATION_DIVISOR;
|
|
39
|
+
/**
|
|
40
|
+
* Population → referential likelihood in [0, 1].
|
|
41
|
+
*
|
|
42
|
+
* `min(1, log2(1 + pop/1000) / 14)` — the formula the FST builder has used for its population fallback since the FST
|
|
43
|
+
* shipped, and the one `gazetteer importance` used for its fallback rows. It is defined ONCE here so the decode-bias
|
|
44
|
+
* artifact's values, the gazetteer's `referential` column, and the resolver's ranking key are the same number by
|
|
45
|
+
* construction rather than by three matching copies.
|
|
46
|
+
*
|
|
47
|
+
* MEANING OF ZERO: an absent population row and a recorded population of 0 both return 0, and 0 means "no population
|
|
48
|
+
* evidence" — the ranking treats it as no boost, never a penalty. WOF carries population for roughly 15% of localities,
|
|
49
|
+
* so absence is the common case and must stay cheap.
|
|
50
|
+
*/
|
|
51
|
+
export function referentialFromPopulation(population) {
|
|
52
|
+
if (population === null || population === undefined || population <= 0)
|
|
53
|
+
return 0;
|
|
54
|
+
return Math.min(1, Math.log2(1 + population / REFERENTIAL_POPULATION_DIVISOR) / REFERENTIAL_LOG2_SCALE);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The ranking comparator: referential DESC, raw population DESC as the tiebreak. Negative when `a` outranks `b`, so it
|
|
58
|
+
* drops straight into `Array#sort`.
|
|
59
|
+
*
|
|
60
|
+
* The population tiebreak is not a hedge — it is what makes "rank by referential" and "rank by population" the SAME
|
|
61
|
+
* ORDER on every input, because {@link referentialFromPopulation} is strictly increasing below
|
|
62
|
+
* {@link REFERENTIAL_SATURATION_POPULATION} and constant above it. Without the tiebreak this comparator would silently
|
|
63
|
+
* re-order the world's largest cities: a real behavior change, and the one the D-rule would catch.
|
|
64
|
+
*
|
|
65
|
+
* Encyclopedic importance is deliberately not a parameter. Ranking by it is the thing §2 forbids, and a comparator that
|
|
66
|
+
* cannot express it is a stronger guarantee than a comment asking nobody to.
|
|
67
|
+
*/
|
|
68
|
+
export function compareReferential(a, b) {
|
|
69
|
+
return (b.referential ?? 0) - (a.referential ?? 0) || (b.population ?? 0) - (a.population ?? 0);
|
|
70
|
+
}
|
|
71
|
+
//# sourceMappingURL=referential.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"referential.js","sourceRoot":"","sources":["../../resolver/referential.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH;;;GAGG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG,IAAI,CAAA;AAElD;;GAEG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAA;AAExC;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,iCAAiC,GAAG,CAAC,CAAC,IAAI,sBAAsB,GAAG,CAAC,CAAC,GAAG,8BAA8B,CAAA;AAEnH;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,yBAAyB,CAAC,UAAqC;IAC9E,IAAI,UAAU,KAAK,IAAI,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,IAAI,CAAC;QAAE,OAAO,CAAC,CAAA;IAEhF,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,UAAU,GAAG,8BAA8B,CAAC,GAAG,sBAAsB,CAAC,CAAA;AACxG,CAAC;AAWD;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,kBAAkB,CAAC,CAAwB,EAAE,CAAwB;IACpF,OAAO,CAAC,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,IAAI,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,IAAI,CAAC,CAAC,CAAA;AAChG,CAAC"}
|