@rebilder/agent-readability 0.1.0 → 0.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 +15 -14
- package/dist/index.cjs +266 -53
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +209 -48
- package/dist/index.d.ts +209 -48
- package/dist/index.js +259 -54
- package/dist/index.js.map +1 -1
- package/dist/probe/index.cjs +106 -67
- package/dist/probe/index.cjs.map +1 -1
- package/dist/probe/index.d.cts +14 -9
- package/dist/probe/index.d.ts +14 -9
- package/dist/probe/index.js +106 -67
- package/dist/probe/index.js.map +1 -1
- package/dist/probe/local.cjs +106 -67
- package/dist/probe/local.cjs.map +1 -1
- package/dist/probe/local.d.cts +1 -1
- package/dist/probe/local.d.ts +1 -1
- package/dist/probe/local.js +106 -67
- package/dist/probe/local.js.map +1 -1
- package/dist/{types-B2FhQ1YC.d.cts → robots-policy-DE8jix-e.d.cts} +62 -9
- package/dist/{types-B2FhQ1YC.d.ts → robots-policy-DE8jix-e.d.ts} +62 -9
- package/package.json +4 -8
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { A as ArsDimensionId, a as ArsBasis, b as ArsFactProfile, c as ArsRuleset, d as ArsBand, e as ArsEvidence, f as ArsResult, g as ArsRecommendation, h as ArsPageKind } from './
|
|
2
|
-
export { i as
|
|
1
|
+
import { A as ArsDimensionId, a as ArsBasis, b as ArsFactProfile, c as ArsRuleset, d as ArsBand, e as ArsEvidence, f as ArsResult, g as ArsRecommendation, h as ArsPageKind } from './robots-policy-DE8jix-e.js';
|
|
2
|
+
export { i as AGENT_ACCEPT, j as ARS_ROBOTS_TOKEN, k as ARS_SPEC_VERSION, l as ASSET_ACCEPT, m as ArsAudience, n as ArsAudienceDecision, o as ArsCheck, p as ArsCheckEvidence, q as ArsCheckId, r as ArsCostReport, s as ArsDimension, t as ArsFactKind, u as ArsFactObservation, v as ArsFlag, w as ArsFlagId, x as ArsGrade, y as ArsHttpCapture, z as ArsOutcome, B as ArsPolicyReport, C as ArsProbeError, D as ArsProbeRecord, E as ArsUnscoredReason, F as ArsVantage, G as BROWSER_ACCEPT, H as robotsDisallowsScanner } from './robots-policy-DE8jix-e.js';
|
|
3
3
|
|
|
4
4
|
/** Descriptive metadata per check: which dimension it belongs to, its published label, its basis. */
|
|
5
5
|
interface ArsCheckMeta {
|
|
@@ -113,6 +113,21 @@ declare const CHECK_META: {
|
|
|
113
113
|
readonly label: "Declared machine endpoint";
|
|
114
114
|
readonly basis: "measured";
|
|
115
115
|
};
|
|
116
|
+
readonly 'evidence-density.quantities': {
|
|
117
|
+
readonly dimension: "evidence-density";
|
|
118
|
+
readonly label: "Quantities an answer can quote";
|
|
119
|
+
readonly basis: "measured";
|
|
120
|
+
};
|
|
121
|
+
readonly 'evidence-density.definitions': {
|
|
122
|
+
readonly dimension: "evidence-density";
|
|
123
|
+
readonly label: "Labelled term and value pairs";
|
|
124
|
+
readonly basis: "heuristic";
|
|
125
|
+
};
|
|
126
|
+
readonly 'evidence-density.comparisons': {
|
|
127
|
+
readonly dimension: "evidence-density";
|
|
128
|
+
readonly label: "Comparable rows";
|
|
129
|
+
readonly basis: "measured";
|
|
130
|
+
};
|
|
116
131
|
};
|
|
117
132
|
/**
|
|
118
133
|
* The six dimensions and their frozen weights (§3.4): 20 · 20 · 20 · 10 · 15 ·
|
|
@@ -123,11 +138,11 @@ declare const CHECK_META: {
|
|
|
123
138
|
declare const DIMENSION_META: {
|
|
124
139
|
readonly retrievability: {
|
|
125
140
|
readonly label: "Retrievability";
|
|
126
|
-
readonly weight:
|
|
141
|
+
readonly weight: 28;
|
|
127
142
|
};
|
|
128
143
|
readonly 'machine-representation': {
|
|
129
144
|
readonly label: "Machine representation";
|
|
130
|
-
readonly weight:
|
|
145
|
+
readonly weight: 18;
|
|
131
146
|
};
|
|
132
147
|
readonly 'fact-coverage': {
|
|
133
148
|
readonly label: "Fact coverage";
|
|
@@ -139,50 +154,65 @@ declare const DIMENSION_META: {
|
|
|
139
154
|
};
|
|
140
155
|
readonly 'structured-data': {
|
|
141
156
|
readonly label: "Structured data";
|
|
142
|
-
readonly weight:
|
|
157
|
+
readonly weight: 6;
|
|
143
158
|
};
|
|
144
159
|
readonly 'contract-discovery': {
|
|
145
160
|
readonly label: "Contract & discovery";
|
|
146
|
-
readonly weight:
|
|
161
|
+
readonly weight: 10;
|
|
162
|
+
};
|
|
163
|
+
readonly 'evidence-density': {
|
|
164
|
+
readonly label: "Evidence density";
|
|
165
|
+
readonly weight: 8;
|
|
147
166
|
};
|
|
148
167
|
};
|
|
149
|
-
/**
|
|
150
|
-
|
|
151
|
-
|
|
168
|
+
/**
|
|
169
|
+
* Published totals (§3.4). Heuristic weight has a spec ceiling of 40; fixture
|
|
170
|
+
* `053` enforces it, and the ceiling is what shaped D7's basis split rather
|
|
171
|
+
* than the other way round. Labelling `definitions` measured would have bought
|
|
172
|
+
* three points of headroom and made "measured 63" a presentational number
|
|
173
|
+
* instead of an honest one, which is the exact failure the ceiling exists to
|
|
174
|
+
* prevent.
|
|
175
|
+
*/
|
|
176
|
+
declare const ARS_MEASURED_WEIGHT = 63;
|
|
177
|
+
declare const ARS_HEURISTIC_WEIGHT = 37;
|
|
152
178
|
declare const ARS_HEURISTIC_WEIGHT_CEILING = 40;
|
|
153
179
|
/**
|
|
154
|
-
* ARS 0.
|
|
155
|
-
*
|
|
156
|
-
* DESIGNED CEILINGS, printed in the spec as intentional rather than
|
|
157
|
-
*
|
|
158
|
-
*
|
|
159
|
-
* (
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
180
|
+
* ARS 0.2's frozen ruleset.
|
|
181
|
+
*
|
|
182
|
+
* DESIGNED CEILINGS, printed in the spec (§8) as intentional rather than
|
|
183
|
+
* discovered, and stated here in 0.2's numbers: no content negotiation loses
|
|
184
|
+
* D2.1 (9) + D2.3 (3, gated on D2.1) + D2.4 (3, nothing comparable) → max 85,
|
|
185
|
+
* capped at B. No valid structured data loses all of D5 (6) → max 94, so an A is
|
|
186
|
+
* still reachable. Reaching an A therefore requires a machine representation and
|
|
187
|
+
* NO LONGER requires structured data — 0.1 required both, and 0.2 does not.
|
|
188
|
+
* Provable from these numbers alone, which is why the whole ruleset is published
|
|
189
|
+
* rather than described.
|
|
163
190
|
*/
|
|
164
191
|
declare const DEFAULT_RULESET: {
|
|
165
|
-
readonly version: "0.
|
|
192
|
+
readonly version: "0.2.0";
|
|
166
193
|
readonly weights: {
|
|
167
|
-
readonly 'retrievability.reachable':
|
|
168
|
-
readonly 'retrievability.robots-policy':
|
|
169
|
-
readonly 'retrievability.render-independence':
|
|
170
|
-
readonly 'machine-representation.negotiated-response':
|
|
171
|
-
readonly 'machine-representation.declared-alternates':
|
|
194
|
+
readonly 'retrievability.reachable': 11;
|
|
195
|
+
readonly 'retrievability.robots-policy': 10;
|
|
196
|
+
readonly 'retrievability.render-independence': 7;
|
|
197
|
+
readonly 'machine-representation.negotiated-response': 9;
|
|
198
|
+
readonly 'machine-representation.declared-alternates': 3;
|
|
172
199
|
readonly 'machine-representation.vary-accept': 3;
|
|
173
200
|
readonly 'machine-representation.substance-parity': 3;
|
|
174
201
|
readonly 'fact-coverage.core-facts': 14;
|
|
175
202
|
readonly 'fact-coverage.context-cost': 6;
|
|
176
203
|
readonly 'fact-position.first-core-fact-offset': 5;
|
|
177
204
|
readonly 'fact-position.front-window': 5;
|
|
178
|
-
readonly 'structured-data.present':
|
|
179
|
-
readonly 'structured-data.required-properties':
|
|
180
|
-
readonly 'structured-data.text-agreement':
|
|
205
|
+
readonly 'structured-data.present': 2;
|
|
206
|
+
readonly 'structured-data.required-properties': 3;
|
|
207
|
+
readonly 'structured-data.text-agreement': 1;
|
|
181
208
|
readonly 'contract-discovery.canonical': 4;
|
|
182
|
-
readonly 'contract-discovery.cache-validators':
|
|
183
|
-
readonly 'contract-discovery.llms-txt':
|
|
184
|
-
readonly 'contract-discovery.sitemap':
|
|
185
|
-
readonly 'contract-discovery.machine-endpoint':
|
|
209
|
+
readonly 'contract-discovery.cache-validators': 2;
|
|
210
|
+
readonly 'contract-discovery.llms-txt': 1;
|
|
211
|
+
readonly 'contract-discovery.sitemap': 1;
|
|
212
|
+
readonly 'contract-discovery.machine-endpoint': 2;
|
|
213
|
+
readonly 'evidence-density.quantities': 4;
|
|
214
|
+
readonly 'evidence-density.definitions': 2;
|
|
215
|
+
readonly 'evidence-density.comparisons': 2;
|
|
186
216
|
};
|
|
187
217
|
readonly thresholds: {
|
|
188
218
|
/**
|
|
@@ -214,6 +244,31 @@ declare const DEFAULT_RULESET: {
|
|
|
214
244
|
* `ratio = 100 × bytes / byteReference[pageKind]`; above the last threshold, 0.
|
|
215
245
|
*/
|
|
216
246
|
readonly 'fact-coverage.context-cost': readonly [100, 6, 200, 5, 500, 3, 1500, 1];
|
|
247
|
+
/**
|
|
248
|
+
* D7.1 quantities, 4 pts. AT-LEAST over the count of DISTINCT quantity tokens
|
|
249
|
+
* in the agent's counted text: a currency amount, a percentage, a number
|
|
250
|
+
* carrying a unit, or an ISO date. Distinct, because a price repeated in a
|
|
251
|
+
* header, a buy box and a footer is one fact stated three times, and counting
|
|
252
|
+
* it three times would reward the repetition this score exists to discourage.
|
|
253
|
+
* Saturates at 12 so a specification table cannot outscore a page that simply
|
|
254
|
+
* states its facts.
|
|
255
|
+
*/
|
|
256
|
+
readonly 'evidence-density.quantities': readonly [12, 4, 6, 3, 3, 2, 1, 1];
|
|
257
|
+
/**
|
|
258
|
+
* D7.2 definitions, 2 pts. AT-LEAST over the count of `term: value` pairs the
|
|
259
|
+
* agent can read as a labelled fact, counting markdown bold-label lines,
|
|
260
|
+
* list items with a leading label, and HTML definition lists.
|
|
261
|
+
*/
|
|
262
|
+
readonly 'evidence-density.definitions': readonly [6, 2, 2, 1];
|
|
263
|
+
/**
|
|
264
|
+
* D7.3 comparisons, 2 pts. AT-LEAST over the number of comparable ROWS: a
|
|
265
|
+
* table with at least two data columns contributes its data-row count, minus
|
|
266
|
+
* the header. One row is not a comparison, so the band starts at two; three
|
|
267
|
+
* options laid side by side is a full comparison and pays out. Calibrated
|
|
268
|
+
* against fixture `060`, where a three-row size table is exactly the shape
|
|
269
|
+
* this check exists to reward, and `063`, where one row is not.
|
|
270
|
+
*/
|
|
271
|
+
readonly 'evidence-density.comparisons': readonly [3, 2, 2, 1];
|
|
217
272
|
/** D4.1 first-core-fact byte offset, 5 pts. AT-MOST over the offset in bytes; else 0. */
|
|
218
273
|
readonly 'fact-position.first-core-fact-offset': readonly [512, 5, 2048, 4, 8192, 2, 32768, 1];
|
|
219
274
|
/**
|
|
@@ -295,7 +350,7 @@ declare const DEFAULT_RULESET: {
|
|
|
295
350
|
};
|
|
296
351
|
|
|
297
352
|
/**
|
|
298
|
-
* score.ts — the ARS 0.
|
|
353
|
+
* score.ts — the ARS 0.2 scoring engine. The whole pure half comes together here.
|
|
299
354
|
*
|
|
300
355
|
* THE CONTRACT. `score(evidence, ruleset)` is a pure function: same evidence,
|
|
301
356
|
* same ruleset, same `ArsResult`, byte for byte, in any conformant
|
|
@@ -364,14 +419,25 @@ declare const DEFAULT_RULESET: {
|
|
|
364
419
|
* `./classify`. Editing one moves conformance `expected.json` files and is
|
|
365
420
|
* therefore a MINOR, and the corpus is what actually pins them.
|
|
366
421
|
*/
|
|
422
|
+
/**
|
|
423
|
+
* The per-check point splits.
|
|
424
|
+
*
|
|
425
|
+
* THESE MUST SUM TO `WEIGHTS`, and until ARS 0.2 nothing said so. The ruleset
|
|
426
|
+
* carried the same numbers twice, here and in `WEIGHTS`, with fixture `052`
|
|
427
|
+
* checking only that `DIMENSION_META` agreed with `WEIGHTS`. Rebalancing for
|
|
428
|
+
* 0.2 changed `WEIGHTS` alone and every check kept emitting 0.1's points, so
|
|
429
|
+
* the corpus re-scored with dimensions claiming 28 while their checks could
|
|
430
|
+
* only pay 20. `subpointTotals()` below closes that, and `score.test.ts`
|
|
431
|
+
* asserts the two tables agree check by check.
|
|
432
|
+
*/
|
|
367
433
|
declare const SUBPOINTS: {
|
|
368
|
-
/** D1.1,
|
|
434
|
+
/** D1.1, 11 = 5 + 3 + 3. */
|
|
369
435
|
reachable: {
|
|
370
436
|
status2xx: number;
|
|
371
437
|
withinRedirectLimit: number;
|
|
372
438
|
noAcceptConditionalRedirect: number;
|
|
373
439
|
};
|
|
374
|
-
/** D1.2,
|
|
440
|
+
/** D1.2, 10 = 6 + 2 + 1 + 1. A disallowed assistant audience scores 0 for all four (§3.7). */
|
|
375
441
|
robotsPolicy: {
|
|
376
442
|
assistantAllowed: number;
|
|
377
443
|
parsesClean: number;
|
|
@@ -379,7 +445,7 @@ declare const SUBPOINTS: {
|
|
|
379
445
|
sitemapDeclared: number;
|
|
380
446
|
};
|
|
381
447
|
/**
|
|
382
|
-
* D1.3,
|
|
448
|
+
* D1.3, 7. AT-LEAST band over `100 × coreFactsInHtml / coreProfileSize`, plus
|
|
383
449
|
* the `<noscript>` floor: a page whose facts are all client-rendered but which
|
|
384
450
|
* ships a non-empty `<noscript>` has told a JS-less caller something, and §3.8
|
|
385
451
|
* says that earns partial credit.
|
|
@@ -388,11 +454,11 @@ declare const SUBPOINTS: {
|
|
|
388
454
|
band: readonly number[];
|
|
389
455
|
noscriptFloor: number;
|
|
390
456
|
};
|
|
391
|
-
/** D2.1,
|
|
457
|
+
/** D2.1, 9. All-or-nothing: a machine media type AND a body that is not HTML. */
|
|
392
458
|
negotiatedResponse: {
|
|
393
459
|
full: number;
|
|
394
460
|
};
|
|
395
|
-
/** D2.2,
|
|
461
|
+
/** D2.2, 3. All-or-nothing. */
|
|
396
462
|
declaredAlternates: {
|
|
397
463
|
full: number;
|
|
398
464
|
};
|
|
@@ -404,17 +470,17 @@ declare const SUBPOINTS: {
|
|
|
404
470
|
substanceParity: {
|
|
405
471
|
full: number;
|
|
406
472
|
};
|
|
407
|
-
/** D5.1,
|
|
473
|
+
/** D5.1, 2. Structured data present AND parsing; a partly-broken graph scores 1. */
|
|
408
474
|
structuredDataPresent: {
|
|
409
475
|
clean: number;
|
|
410
476
|
partial: number;
|
|
411
477
|
};
|
|
412
|
-
/** D5.2,
|
|
478
|
+
/** D5.2, 3 = 1 (a recognised type) + 2 (required-property completeness, scaled). */
|
|
413
479
|
requiredProperties: {
|
|
414
480
|
recognisedType: number;
|
|
415
481
|
completeness: number;
|
|
416
482
|
};
|
|
417
|
-
/** D5.3,
|
|
483
|
+
/** D5.3, 1. All-or-nothing. */
|
|
418
484
|
textAgreement: {
|
|
419
485
|
full: number;
|
|
420
486
|
};
|
|
@@ -424,21 +490,27 @@ declare const SUBPOINTS: {
|
|
|
424
490
|
absolute: number;
|
|
425
491
|
consistentAcrossProbes: number;
|
|
426
492
|
};
|
|
427
|
-
/** D6.2,
|
|
493
|
+
/** D6.2, 2 = 1 + 1. */
|
|
428
494
|
cacheValidators: {
|
|
429
495
|
saneCacheControl: number;
|
|
430
496
|
validator: number;
|
|
431
497
|
};
|
|
432
|
-
/**
|
|
498
|
+
/**
|
|
499
|
+
* D6.3, 1. `specShaped` — an H1 and at least one Markdown link — is the whole
|
|
500
|
+
* point. `present` is 0 in 0.2: at two points 0.1 could pay one for the file
|
|
501
|
+
* existing and one for it being usable, but at one point that split would make
|
|
502
|
+
* "exists" and "usable" score identically, which is a distinction the standard
|
|
503
|
+
* would then be printing a remedy for and paying nothing to fix.
|
|
504
|
+
*/
|
|
433
505
|
llmsTxt: {
|
|
434
506
|
present: number;
|
|
435
507
|
specShaped: number;
|
|
436
508
|
};
|
|
437
|
-
/** D6.4,
|
|
509
|
+
/** D6.4, 1. All-or-nothing. */
|
|
438
510
|
sitemap: {
|
|
439
511
|
full: number;
|
|
440
512
|
};
|
|
441
|
-
/** D6.5,
|
|
513
|
+
/** D6.5, 2. All-or-nothing over any ONE declared machine endpoint. */
|
|
442
514
|
machineEndpoint: {
|
|
443
515
|
full: number;
|
|
444
516
|
};
|
|
@@ -472,12 +544,16 @@ declare function evidenceHash(evidence: ArsEvidence): string;
|
|
|
472
544
|
* requires reading the corpus directory, which the pure half cannot do, so it is
|
|
473
545
|
* a constant regenerated at corpus freeze.
|
|
474
546
|
*
|
|
475
|
-
* ARS 0.
|
|
547
|
+
* ARS 0.2 ships as a DRAFT (§3.10, "Calibration") and its corpus is still open:
|
|
476
548
|
* fixtures are landing. So the value below is deliberately NOT a corpus digest —
|
|
477
|
-
* it is the SHA-256 of the ASCII string `ars-0.
|
|
549
|
+
* it is the SHA-256 of the ASCII string `ars-0.2-corpus-unfrozen`. Anyone who
|
|
478
550
|
* recomputes the digest of the shipped corpus will find it does not match, which
|
|
479
551
|
* is the correct signal: a score carrying this constant is a draft score. It is
|
|
480
552
|
* computed rather than pasted so that no reader has to trust a magic literal.
|
|
553
|
+
*
|
|
554
|
+
* THE STRING CARRIES THE SPEC VERSION for the same reason `rulesetHash` exists:
|
|
555
|
+
* 0.1 and 0.2 score the same page differently, so a 0.1 draft score and a 0.2
|
|
556
|
+
* draft score must not be able to present identical identity triples.
|
|
481
557
|
*/
|
|
482
558
|
declare const ARS_CORPUS_HASH: string;
|
|
483
559
|
/** The band a score falls in. Bands headline; the integer is secondary (§3.6). */
|
|
@@ -515,7 +591,7 @@ declare function score(evidence: ArsEvidence, ruleset?: ArsRuleset): ArsResult;
|
|
|
515
591
|
* dimension are capped at the dimension weight. A property test asserts
|
|
516
592
|
* `Σ pointsAvailable ≤ 100 − score`.
|
|
517
593
|
*
|
|
518
|
-
* WHAT "UNLOCKS" MEANS, PRECISELY. Two checks
|
|
594
|
+
* WHAT "UNLOCKS" MEANS, PRECISELY. Two checks are gated on D2.1: D2.3
|
|
519
595
|
* (`Vary: Accept` is meaningless on a response that does not vary) and D2.4
|
|
520
596
|
* (substance parity has nothing to compare against). While D2.1 is at zero,
|
|
521
597
|
* their points are not reachable by any other action, so they belong to the
|
|
@@ -546,6 +622,91 @@ type ArsRecommendationInput = Pick<ArsResult, 'dimensions' | 'score'>;
|
|
|
546
622
|
*/
|
|
547
623
|
declare function recommend(input: ArsRecommendationInput): ArsRecommendation[];
|
|
548
624
|
|
|
625
|
+
/**
|
|
626
|
+
* extract.ts — pass 2 of the ARS pipeline: turn one fetched representation into
|
|
627
|
+
* a set of normalised fact observations, scored against the resolved page-kind
|
|
628
|
+
* profile (design §3.5, §3.6).
|
|
629
|
+
*
|
|
630
|
+
* WHAT A "REPRESENTATION" IS. The probe returns two captures that differ only in
|
|
631
|
+
* their `Accept` header (§3.3). Each one is turned into an `ArsRepresentation`:
|
|
632
|
+
* a decoded body, its byte length as the probe measured it, the tokenized
|
|
633
|
+
* document when the bytes are HTML, the JSON-LD blocks, and the counted text.
|
|
634
|
+
* Everything downstream reads a representation, never a raw capture, so the
|
|
635
|
+
* markdown path and the HTML path go through the same scoring code.
|
|
636
|
+
*
|
|
637
|
+
* WHICH REPRESENTATION SCORES WHAT — the decision that makes the golden pair
|
|
638
|
+
* (`001-pdp-gateway-md` vs `002-pdp-raw-html`) mean anything:
|
|
639
|
+
*
|
|
640
|
+
* D3 (coverage) and D4 (position) score the AGENT representation, because ARS
|
|
641
|
+
* measures what a caller actually receives. A merchant whose markdown omits
|
|
642
|
+
* `availability` loses coverage even though the HTML declares it — the agent
|
|
643
|
+
* never saw it.
|
|
644
|
+
*
|
|
645
|
+
* D1.3 (render independence) and D5 (structured data) score the HTML
|
|
646
|
+
* representation, because those checks are about the document a caller that
|
|
647
|
+
* only reads HTML gets. JSON-LD does not live in markdown, and "would this
|
|
648
|
+
* page work without JavaScript" is a question about HTML.
|
|
649
|
+
*
|
|
650
|
+
* CORROBORATION CROSSES THE TWO. §3.6 defines corroborated as "observed in ≥2
|
|
651
|
+
* sources (e.g. JSON-LD and visible text)". A price stated in the negotiated
|
|
652
|
+
* markdown *and* in the HTML's JSON-LD is observed in two sources and is
|
|
653
|
+
* corroborated; that is the only reason a correctly installed gateway can reach
|
|
654
|
+
* an A. But a fact observed ONLY in the HTML does not enter the scored fact set
|
|
655
|
+
* at all — corroboration strengthens a fact the agent received, it never
|
|
656
|
+
* conjures one it did not. See `mergeFacts`.
|
|
657
|
+
*
|
|
658
|
+
* VALUE FACTS vs PRESENCE FACTS. Some facts are compared by value (a price, a
|
|
659
|
+
* title, a phone number); others are only ever "declared or not" (shipping,
|
|
660
|
+
* returns, opening hours, question/answer shape). Presence facts normalise to
|
|
661
|
+
* the literal string `declared` from EVERY source, deliberately: two sources
|
|
662
|
+
* that describe the same shipping policy in different words must still
|
|
663
|
+
* corroborate each other, and a free-text comparison would make that
|
|
664
|
+
* non-deterministic. The split is pinned in `PRESENCE_FACTS` below and printed
|
|
665
|
+
* in the spec, because it is the difference between "we compared the values" and
|
|
666
|
+
* "we compared whether you said anything".
|
|
667
|
+
*
|
|
668
|
+
* EVERYTHING HERE IS PINNED DATA, NOT INFERENCE. The label lexicon, the
|
|
669
|
+
* availability vocabulary, the no-published-price phrases, the schema.org
|
|
670
|
+
* property aliases: all tables, all versioned. An extractor that guessed would
|
|
671
|
+
* make `score()` non-reproducible in a second implementation, which is the one
|
|
672
|
+
* property the whole package exists to provide.
|
|
673
|
+
*/
|
|
674
|
+
|
|
675
|
+
/**
|
|
676
|
+
* UTF-8 byte length of a JavaScript string, counting a lone surrogate as 3
|
|
677
|
+
* bytes — the width WHATWG encoding gives U+FFFD, which is what a lone
|
|
678
|
+
* surrogate actually costs on the wire. Matches `Utf8Cursor` in `./html`, which
|
|
679
|
+
* is why offsets from the two files are in the same address space.
|
|
680
|
+
*/
|
|
681
|
+
declare function utf8Length(text: string): number;
|
|
682
|
+
interface RobotsGroup {
|
|
683
|
+
/** Lowercased user-agent tokens this group applies to. */
|
|
684
|
+
readonly agents: readonly string[];
|
|
685
|
+
readonly allow: readonly string[];
|
|
686
|
+
readonly disallow: readonly string[];
|
|
687
|
+
}
|
|
688
|
+
interface RobotsFile {
|
|
689
|
+
readonly groups: readonly RobotsGroup[];
|
|
690
|
+
readonly sitemaps: readonly string[];
|
|
691
|
+
/** Lines that are neither blank, a comment, nor a `field: value` pair. */
|
|
692
|
+
readonly malformedLines: number;
|
|
693
|
+
/** Directives that appeared before any `User-agent:` line — the classic authoring bug. */
|
|
694
|
+
readonly orphanRules: number;
|
|
695
|
+
}
|
|
696
|
+
/**
|
|
697
|
+
* RFC 9309 robots.txt, in the subset ARS reads. Deliberately small: we consume
|
|
698
|
+
* `User-agent`, `Allow`, `Disallow` and `Sitemap`, count what we could not
|
|
699
|
+
* parse, and ignore everything else. `Crawl-delay` is honoured by the PROBE, not
|
|
700
|
+
* by the score — waiting longer is not worse markup.
|
|
701
|
+
*/
|
|
702
|
+
declare function parseRobots(text: string): RobotsFile;
|
|
703
|
+
/**
|
|
704
|
+
* Path matching with `*` and `$`, done as a bounded scan rather than a compiled
|
|
705
|
+
* regex: a robots.txt is attacker-controlled input and
|
|
706
|
+
* `new RegExp(pathFromTheInternet)` is a denial-of-service primitive.
|
|
707
|
+
*/
|
|
708
|
+
declare function pathMatches(pattern: string, path: string): boolean;
|
|
709
|
+
|
|
549
710
|
/**
|
|
550
711
|
* classify.ts — the two-pass page-kind classifier (design §3.5).
|
|
551
712
|
*
|
|
@@ -782,4 +943,4 @@ declare function minorUnitDigits(code: string): number;
|
|
|
782
943
|
*/
|
|
783
944
|
declare function parseMoneyText(text: string, hints?: MoneyHints): ParsedMoney | null;
|
|
784
945
|
|
|
785
|
-
export { ARS_CORPUS_HASH, ARS_HEURISTIC_WEIGHT, ARS_HEURISTIC_WEIGHT_CEILING, ARS_MEASURED_WEIGHT, ArsBand, ArsBasis, type ArsCheckMeta, type ArsClassification, ArsDimensionId, ArsEvidence, ArsFactProfile, ArsPageKind, type ArsPass1Signals, ArsRecommendation, type ArsRecommendationInput, ArsResult, ArsRuleset, CHECK_META, DEFAULT_RULESET, DIMENSION_META, type Money, type MoneyHints, PROFILES, type ParsedMoney, SUBPOINTS, bandFor, canonicalJson, classify, evidenceHash, minorUnitDigits, parseMoneyText, profileFor, recommend, rulesetHash, score, sha256Hex };
|
|
946
|
+
export { ARS_CORPUS_HASH, ARS_HEURISTIC_WEIGHT, ARS_HEURISTIC_WEIGHT_CEILING, ARS_MEASURED_WEIGHT, ArsBand, ArsBasis, type ArsCheckMeta, type ArsClassification, ArsDimensionId, ArsEvidence, ArsFactProfile, ArsPageKind, type ArsPass1Signals, ArsRecommendation, type ArsRecommendationInput, ArsResult, ArsRuleset, CHECK_META, DEFAULT_RULESET, DIMENSION_META, type Money, type MoneyHints, PROFILES, type ParsedMoney, SUBPOINTS, bandFor, canonicalJson, classify, evidenceHash, minorUnitDigits, parseMoneyText, parseRobots, pathMatches, profileFor, recommend, rulesetHash, score, sha256Hex, utf8Length };
|