@rebilder/agent-readability 0.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.
@@ -0,0 +1,785 @@
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 './types-B2FhQ1YC.cjs';
2
+ export { i as ARS_SPEC_VERSION, j as ArsAudience, k as ArsAudienceDecision, l as ArsCheck, m as ArsCheckEvidence, n as ArsCheckId, o as ArsCostReport, p as ArsDimension, q as ArsFactKind, r as ArsFactObservation, s as ArsFlag, t as ArsFlagId, u as ArsGrade, v as ArsHttpCapture, w as ArsOutcome, x as ArsPolicyReport, y as ArsProbeError, z as ArsProbeRecord, B as ArsUnscoredReason, C as ArsVantage } from './types-B2FhQ1YC.cjs';
3
+
4
+ /** Descriptive metadata per check: which dimension it belongs to, its published label, its basis. */
5
+ interface ArsCheckMeta {
6
+ dimension: ArsDimensionId;
7
+ label: string;
8
+ basis: ArsBasis;
9
+ }
10
+ /**
11
+ * The published catalogue of checks. `dimension` is redundant with the check id
12
+ * prefix by construction — the id shape `<dimension>.<check>` is normative — and
13
+ * is spelled out anyway so consumers never parse an id string to group results.
14
+ *
15
+ * `basis` is spec data (it appears in every `expected.json` and is printed next
16
+ * to every check in the UI) but it is not part of `ArsRuleset` in §3.9, so it is
17
+ * exported here rather than folded into the hashed object. A second
18
+ * implementation reads it from the published §3.4 table.
19
+ */
20
+ declare const CHECK_META: {
21
+ readonly 'retrievability.reachable': {
22
+ readonly dimension: "retrievability";
23
+ readonly label: "Reachable on the agent path";
24
+ readonly basis: "measured";
25
+ };
26
+ readonly 'retrievability.robots-policy': {
27
+ readonly dimension: "retrievability";
28
+ readonly label: "Robots policy for assistants";
29
+ readonly basis: "measured";
30
+ };
31
+ readonly 'retrievability.render-independence': {
32
+ readonly dimension: "retrievability";
33
+ readonly label: "Core facts present without JavaScript";
34
+ readonly basis: "heuristic";
35
+ };
36
+ readonly 'machine-representation.negotiated-response': {
37
+ readonly dimension: "machine-representation";
38
+ readonly label: "Machine representation on Accept negotiation";
39
+ readonly basis: "measured";
40
+ };
41
+ readonly 'machine-representation.declared-alternates': {
42
+ readonly dimension: "machine-representation";
43
+ readonly label: "Declared alternate representations";
44
+ readonly basis: "measured";
45
+ };
46
+ readonly 'machine-representation.vary-accept': {
47
+ readonly dimension: "machine-representation";
48
+ readonly label: "Vary: Accept declared correctly";
49
+ readonly basis: "measured";
50
+ };
51
+ readonly 'machine-representation.substance-parity': {
52
+ readonly dimension: "machine-representation";
53
+ readonly label: "Same substance across representations";
54
+ readonly basis: "heuristic";
55
+ };
56
+ readonly 'fact-coverage.core-facts': {
57
+ readonly dimension: "fact-coverage";
58
+ readonly label: "Core facts for this page kind";
59
+ readonly basis: "heuristic";
60
+ };
61
+ readonly 'fact-coverage.context-cost': {
62
+ readonly dimension: "fact-coverage";
63
+ readonly label: "Context cost relative to this page kind";
64
+ readonly basis: "measured";
65
+ };
66
+ readonly 'fact-position.first-core-fact-offset': {
67
+ readonly dimension: "fact-position";
68
+ readonly label: "Byte offset of the first core fact";
69
+ readonly basis: "heuristic";
70
+ };
71
+ readonly 'fact-position.front-window': {
72
+ readonly dimension: "fact-position";
73
+ readonly label: "Core facts inside the front window";
74
+ readonly basis: "heuristic";
75
+ };
76
+ readonly 'structured-data.present': {
77
+ readonly dimension: "structured-data";
78
+ readonly label: "Structured data present and parsing";
79
+ readonly basis: "measured";
80
+ };
81
+ readonly 'structured-data.required-properties': {
82
+ readonly dimension: "structured-data";
83
+ readonly label: "Recognised type with its required properties";
84
+ readonly basis: "measured";
85
+ };
86
+ readonly 'structured-data.text-agreement': {
87
+ readonly dimension: "structured-data";
88
+ readonly label: "Structured data agrees with visible text";
89
+ readonly basis: "heuristic";
90
+ };
91
+ readonly 'contract-discovery.canonical': {
92
+ readonly dimension: "contract-discovery";
93
+ readonly label: "Canonical URL present and self-consistent";
94
+ readonly basis: "measured";
95
+ };
96
+ readonly 'contract-discovery.cache-validators': {
97
+ readonly dimension: "contract-discovery";
98
+ readonly label: "Cache validators";
99
+ readonly basis: "measured";
100
+ };
101
+ readonly 'contract-discovery.llms-txt': {
102
+ readonly dimension: "contract-discovery";
103
+ readonly label: "llms.txt present and spec-shaped";
104
+ readonly basis: "measured";
105
+ };
106
+ readonly 'contract-discovery.sitemap': {
107
+ readonly dimension: "contract-discovery";
108
+ readonly label: "Sitemap declared in robots.txt";
109
+ readonly basis: "measured";
110
+ };
111
+ readonly 'contract-discovery.machine-endpoint': {
112
+ readonly dimension: "contract-discovery";
113
+ readonly label: "Declared machine endpoint";
114
+ readonly basis: "measured";
115
+ };
116
+ };
117
+ /**
118
+ * The six dimensions and their frozen weights (§3.4): 20 · 20 · 20 · 10 · 15 ·
119
+ * 15 = 100, identical for every page kind. Each weight is the sum of its
120
+ * checks' weights in `WEIGHTS`; both are written out because both are published,
121
+ * and conformance fixture `052` asserts they agree and that the total is 100.
122
+ */
123
+ declare const DIMENSION_META: {
124
+ readonly retrievability: {
125
+ readonly label: "Retrievability";
126
+ readonly weight: 20;
127
+ };
128
+ readonly 'machine-representation': {
129
+ readonly label: "Machine representation";
130
+ readonly weight: 20;
131
+ };
132
+ readonly 'fact-coverage': {
133
+ readonly label: "Fact coverage";
134
+ readonly weight: 20;
135
+ };
136
+ readonly 'fact-position': {
137
+ readonly label: "Fact position";
138
+ readonly weight: 10;
139
+ };
140
+ readonly 'structured-data': {
141
+ readonly label: "Structured data";
142
+ readonly weight: 15;
143
+ };
144
+ readonly 'contract-discovery': {
145
+ readonly label: "Contract & discovery";
146
+ readonly weight: 15;
147
+ };
148
+ };
149
+ /** Published totals (§3.4). Heuristic weight has a spec ceiling of 40; fixture `053` enforces it. */
150
+ declare const ARS_MEASURED_WEIGHT = 64;
151
+ declare const ARS_HEURISTIC_WEIGHT = 36;
152
+ declare const ARS_HEURISTIC_WEIGHT_CEILING = 40;
153
+ /**
154
+ * ARS 0.1's frozen ruleset.
155
+ *
156
+ * DESIGNED CEILINGS, printed in the spec as intentional rather than discovered:
157
+ * no content negotiation loses D2.1 (10) + D2.3 (3, gated on D2.1) + D2.4 (3,
158
+ * uncomparable) → max 84, capped at B. No valid structured data loses all of D5
159
+ * (15) → max 85, capped at B. Reaching an A therefore requires BOTH a machine
160
+ * representation and valid structured data — provable from these numbers alone,
161
+ * which is why it is disclosed next to the conflict-of-interest note rather than
162
+ * left for someone to discover.
163
+ */
164
+ declare const DEFAULT_RULESET: {
165
+ readonly version: "0.1.0";
166
+ readonly weights: {
167
+ readonly 'retrievability.reachable': 8;
168
+ readonly 'retrievability.robots-policy': 6;
169
+ readonly 'retrievability.render-independence': 6;
170
+ readonly 'machine-representation.negotiated-response': 10;
171
+ readonly 'machine-representation.declared-alternates': 4;
172
+ readonly 'machine-representation.vary-accept': 3;
173
+ readonly 'machine-representation.substance-parity': 3;
174
+ readonly 'fact-coverage.core-facts': 14;
175
+ readonly 'fact-coverage.context-cost': 6;
176
+ readonly 'fact-position.first-core-fact-offset': 5;
177
+ readonly 'fact-position.front-window': 5;
178
+ readonly 'structured-data.present': 5;
179
+ readonly 'structured-data.required-properties': 7;
180
+ readonly 'structured-data.text-agreement': 3;
181
+ readonly 'contract-discovery.canonical': 4;
182
+ readonly 'contract-discovery.cache-validators': 3;
183
+ readonly 'contract-discovery.llms-txt': 2;
184
+ readonly 'contract-discovery.sitemap': 2;
185
+ readonly 'contract-discovery.machine-endpoint': 4;
186
+ };
187
+ readonly thresholds: {
188
+ /**
189
+ * D3.1 fact weighting, in quarter-units (§3.6), as
190
+ * `[corroboratedCore, uncorroboratedCore, corroboratedExtended, uncorroboratedExtended]`:
191
+ * coreUnits = 4 × corroborated core + 2 × uncorroborated core
192
+ * extendedUnits = 1 × corroborated extended + 0 × uncorroborated extended
193
+ * "Extended = ¼ credit" is the single definition of extended credit.
194
+ */
195
+ readonly 'fact-coverage.fact-units': readonly [4, 2, 1, 0];
196
+ /**
197
+ * D3.1 denominator multiplier: `denominator = 4 × coreSize`, i.e. full credit
198
+ * is every core fact corroborated. `coveragePct` is then
199
+ * `min(100, (100 × (coreUnits + extendedUnits) + denominator / 2) / denominator)`.
200
+ */
201
+ readonly 'fact-coverage.core-denominator-multiplier': readonly [4];
202
+ /**
203
+ * D3.1 density band. AT-LEAST over
204
+ * `factsPerKiB100 = (coreFound × 100 + extendedFound × 25) × 1024 / max(1, bytes)`.
205
+ * The `max(1, bytes)` clamp is normative and replaces `max(1, bytes / 1024)`,
206
+ * which let a 200-byte stub top the band. Density saturates at ≥2 facts/KiB so
207
+ * that keyword stuffing is pointless — fixtures `031` and `032` must score
208
+ * identically.
209
+ * Earned = `(14 × coveragePct × densityPct + 5000) / 10000`.
210
+ */
211
+ readonly 'fact-coverage.density': readonly [200, 100, 100, 85, 50, 70, 20, 50, 5, 30, 0, 15];
212
+ /**
213
+ * D3.2 context cost, 6 pts. AT-MOST over
214
+ * `ratio = 100 × bytes / byteReference[pageKind]`; above the last threshold, 0.
215
+ */
216
+ readonly 'fact-coverage.context-cost': readonly [100, 6, 200, 5, 500, 3, 1500, 1];
217
+ /** D4.1 first-core-fact byte offset, 5 pts. AT-MOST over the offset in bytes; else 0. */
218
+ readonly 'fact-position.first-core-fact-offset': readonly [512, 5, 2048, 4, 8192, 2, 32768, 1];
219
+ /**
220
+ * D4.2 front window, 5 pts. AT-LEAST over the percentage of core facts whose
221
+ * offset falls inside the window; below the last threshold, 0.
222
+ */
223
+ readonly 'fact-position.front-window': readonly [90, 5, 70, 4, 50, 3, 25, 1];
224
+ /**
225
+ * D4.2 window size: `max(2048, bytes / 5)`, as `[floor, divisor]`. ONE
226
+ * expression, integer division — the `0.2 × bytes` form is deleted, because
227
+ * two implementations rounding a float disagree at the boundary.
228
+ */
229
+ readonly 'fact-position.front-window-size': readonly [2048, 5];
230
+ /**
231
+ * Approximate token estimate, as `[bytesPerToken]`. HEURISTIC: decoded UTF-8
232
+ * bytes are the normative measurement and approximate tokens are always
233
+ * rendered with `≈` and an "est." chip. chars/4 is not a token count and the
234
+ * spec says so.
235
+ */
236
+ readonly 'cost.approx-bytes-per-token': readonly [4];
237
+ };
238
+ readonly audienceTokens: {
239
+ /** User-triggered assistant fetches. THE audience ARS scores. */
240
+ readonly assistant: readonly ["ChatGPT-User", "Claude-User", "Claude-SearchBot", "DuckAssistBot", "Meta-ExternalFetcher", "MistralAI-User", "OAI-SearchBot", "Perplexity-User"];
241
+ /** Corpus/model-training crawlers. STRICTLY NEUTRAL — never lowers the score. */
242
+ readonly training: readonly ["AI2Bot", "Applebot-Extended", "Bytespider", "CCBot", "ClaudeBot", "Diffbot", "FacebookBot", "Google-Extended", "GPTBot", "Meta-ExternalAgent", "PanguBot", "Timpibot", "anthropic-ai", "cohere-ai", "omgili"];
243
+ /** Classic search indexers. Reported only. */
244
+ readonly search: readonly ["Applebot", "Baiduspider", "Bingbot", "DuckDuckBot", "Googlebot", "Slurp", "YandexBot"];
245
+ };
246
+ readonly requiredProperties: {
247
+ readonly product: readonly ["name", "offers.price", "offers.priceCurrency", "offers.availability"];
248
+ readonly collection: readonly ["name", "numberOfItems", "itemListElement"];
249
+ readonly article: readonly ["headline", "author", "datePublished"];
250
+ readonly place: readonly ["name", "address", "openingHours", "telephone"];
251
+ readonly service: readonly ["name", "offers.price", "offers.priceCurrency", "potentialAction.target"];
252
+ readonly faq: readonly ["name", "mainEntity", "mainEntity.acceptedAnswer"];
253
+ readonly document: readonly ["name", "dateModified", "publisher"];
254
+ readonly unknown: readonly ["name"];
255
+ };
256
+ readonly actionLexicon: readonly ["add to bag", "add to basket", "add to cart", "apply", "apply now", "book", "book now", "buy", "buy now", "call now", "checkout", "contact", "contact us", "donate", "download", "email us", "enroll", "get a quote", "get quote", "get started", "join", "make an appointment", "order", "order now", "purchase", "register", "request", "request a demo", "request a quote", "reserve", "schedule", "sign up", "signup", "start", "start free trial", "subscribe"];
257
+ /** 2 MiB decoded. Streamed and aborted at the cap; `await response.text()` is forbidden. */
258
+ readonly maxBodyBytes: number;
259
+ /** 3 hops. Every hop re-resolves DNS and re-validates (§5.2). */
260
+ readonly maxRedirects: 3;
261
+ /** 5s per request. See the ADDED note on `ArsRuleset` in ./types. */
262
+ readonly timeoutMs: 5000;
263
+ readonly profiles: readonly ArsFactProfile[];
264
+ readonly bands: readonly [{
265
+ readonly grade: "A";
266
+ readonly min: 90;
267
+ readonly max: 100;
268
+ readonly label: "Agent-native";
269
+ readonly meaning: "Facts are in a machine representation, complete for this page kind, front-loaded, and cheap to fetch.";
270
+ }, {
271
+ readonly grade: "B";
272
+ readonly min: 75;
273
+ readonly max: 89;
274
+ readonly label: "Agent-friendly";
275
+ readonly meaning: "All core facts are present and findable; the agent pays more bytes than it needs, or one signal is missing.";
276
+ }, {
277
+ readonly grade: "C";
278
+ readonly min: 60;
279
+ readonly max: 74;
280
+ readonly label: "Readable with effort";
281
+ readonly meaning: "Core facts are extractable from HTML, at high cost.";
282
+ }, {
283
+ readonly grade: "D";
284
+ readonly min: 40;
285
+ readonly max: 59;
286
+ readonly label: "Partial";
287
+ readonly meaning: "Some core facts for this page kind were not found in the fetched response.";
288
+ }, {
289
+ readonly grade: "F";
290
+ readonly min: 0;
291
+ readonly max: 39;
292
+ readonly label: "Not extractable";
293
+ readonly meaning: "Few or no core facts for this page kind were found in the fetched response.";
294
+ }];
295
+ };
296
+
297
+ /**
298
+ * score.ts — the ARS 0.1 scoring engine. The whole pure half comes together here.
299
+ *
300
+ * THE CONTRACT. `score(evidence, ruleset)` is a pure function: same evidence,
301
+ * same ruleset, same `ArsResult`, byte for byte, in any conformant
302
+ * implementation in any language. No network, no clock, no randomness, no LLM.
303
+ * The ESLint rule in `eslint.config.mjs` enforces the first three at build time;
304
+ * the fourth has nowhere to hide, because there is no model call anywhere in this
305
+ * package.
306
+ *
307
+ * INTEGER ARITHMETIC ONLY (§3.6). Every number below is produced by `idiv` /
308
+ * `divRoundHalfUp`, never by `/` on values that do not divide, and never by
309
+ * `Math.round`. Cross-language conformance is impossible with float rounding
310
+ * drift, and publishing a standard whose scores differ in the third
311
+ * implementation would be worse than publishing nothing. All inputs are
312
+ * non-negative, so rounding is unambiguous half-up via
313
+ * `(numerator + denominator / 2) / denominator`.
314
+ *
315
+ * FIXED WEIGHTS. 100 points for every page, whatever its kind. What varies by
316
+ * page kind is the fact set and the byte reference (`./profiles`) — never a
317
+ * weight. Redistribution would be a gaming vector: make the dimension you are bad
318
+ * at inapplicable and everything else inflates.
319
+ *
320
+ * TWO GATES EXIST, AND THEY POINT THE SAFE WAY. D2.3 (`Vary: Accept`) and D2.4
321
+ * (substance parity) are gated on D2.1 (a machine representation was served),
322
+ * which is a MEASURED check gating others. That direction is fine and is what
323
+ * makes the published ceiling provable: no content negotiation loses D2.1 (10) +
324
+ * D2.3 (3) + D2.4 (3) → max 84 → capped at B. The forbidden direction — a
325
+ * heuristic that can zero measured points — appears nowhere. In particular D2.4
326
+ * and D5.3 are SCORED CHECKS, NOT GATES: a parity failure loses its own 3 points
327
+ * and raises a `warn`, and leaves D2's other 17 measured points alone. That is
328
+ * the whole reason "measured 64 / heuristic 36" is an honest split rather than a
329
+ * presentational one.
330
+ *
331
+ * WHICH REPRESENTATION SCORES WHAT (the decision `./extract` states in its own
332
+ * header, repeated here because it is the reason the golden pair means anything):
333
+ * D3 (coverage) and D4 (position) score the AGENT representation, because ARS
334
+ * measures what a caller actually receives. D1.3 (render independence) and D5
335
+ * (structured data) score the representation that carries a document, because
336
+ * those checks are about the HTML a caller that only reads HTML gets.
337
+ *
338
+ * MEASURED CHECKS NEVER AWARD POINTS FOR AN OBSERVATION WE DID NOT MAKE. When
339
+ * the browser probe is missing, the sub-conditions that compare the two probes
340
+ * (D1.1's "no Accept-conditional redirect", D6.1's "self-consistent") score 0 and
341
+ * say so in their evidence. Awarding them by default would make a measured check
342
+ * heuristic; deducting them silently would be unexplained. The evidence line is
343
+ * the difference.
344
+ *
345
+ * WHAT LIVES IN THE RULESET AND WHAT LIVES HERE. `DEFAULT_RULESET.thresholds`
346
+ * holds exactly the §3.6 numeric tables (density, context cost, offsets, front
347
+ * window). The remaining checks are conjunctions of named conditions rather than
348
+ * bands, and their point splits are `SUBPOINTS` below: published, frozen, and —
349
+ * like the classification tables in `./classify` — NOT covered by `rulesetHash`,
350
+ * because §3.9's `ArsRuleset` has no field for them. That gap is recorded in the
351
+ * package README as a known limitation of 0.1 rather than papered over.
352
+ */
353
+
354
+ /**
355
+ * The point split inside each check that scores a CONJUNCTION of named
356
+ * conditions rather than a numeric band. §3.4 states the conditions ("D1.1 2xx on
357
+ * the agent path, ≤3 hops, no Accept-conditional redirect"); this is how the
358
+ * check's points are divided between them, and every split sums to the check's
359
+ * weight in `DEFAULT_RULESET.weights`.
360
+ *
361
+ * Published here rather than in `DEFAULT_RULESET` because §3.9's `ArsRuleset` has
362
+ * no field for them. The consequence is stated rather than hidden: these numbers
363
+ * are NOT covered by `rulesetHash`, exactly like the classification tables in
364
+ * `./classify`. Editing one moves conformance `expected.json` files and is
365
+ * therefore a MINOR, and the corpus is what actually pins them.
366
+ */
367
+ declare const SUBPOINTS: {
368
+ /** D1.1, 8 = 4 + 2 + 2. */
369
+ reachable: {
370
+ status2xx: number;
371
+ withinRedirectLimit: number;
372
+ noAcceptConditionalRedirect: number;
373
+ };
374
+ /** D1.2, 6 = 3 + 1 + 1 + 1. A disallowed assistant audience scores 0 for all four (§3.7). */
375
+ robotsPolicy: {
376
+ assistantAllowed: number;
377
+ parsesClean: number;
378
+ noOrphanRules: number;
379
+ sitemapDeclared: number;
380
+ };
381
+ /**
382
+ * D1.3, 6. AT-LEAST band over `100 × coreFactsInHtml / coreProfileSize`, plus
383
+ * the `<noscript>` floor: a page whose facts are all client-rendered but which
384
+ * ships a non-empty `<noscript>` has told a JS-less caller something, and §3.8
385
+ * says that earns partial credit.
386
+ */
387
+ renderIndependence: {
388
+ band: readonly number[];
389
+ noscriptFloor: number;
390
+ };
391
+ /** D2.1, 10. All-or-nothing: a machine media type AND a body that is not HTML. */
392
+ negotiatedResponse: {
393
+ full: number;
394
+ };
395
+ /** D2.2, 4. All-or-nothing. */
396
+ declaredAlternates: {
397
+ full: number;
398
+ };
399
+ /** D2.3, 3. All-or-nothing, and 0 unless D2.1 > 0. */
400
+ varyAccept: {
401
+ full: number;
402
+ };
403
+ /** D2.4, 3. All-or-nothing, and 0 unless D2.1 > 0 and a browser capture exists. */
404
+ substanceParity: {
405
+ full: number;
406
+ };
407
+ /** D5.1, 5. Structured data present AND parsing; a partly-broken graph scores 3. */
408
+ structuredDataPresent: {
409
+ clean: number;
410
+ partial: number;
411
+ };
412
+ /** D5.2, 7 = 2 (a recognised type) + 5 (required-property completeness, scaled). */
413
+ requiredProperties: {
414
+ recognisedType: number;
415
+ completeness: number;
416
+ };
417
+ /** D5.3, 3. All-or-nothing. */
418
+ textAgreement: {
419
+ full: number;
420
+ };
421
+ /** D6.1, 4 = 2 + 1 + 1. */
422
+ canonical: {
423
+ present: number;
424
+ absolute: number;
425
+ consistentAcrossProbes: number;
426
+ };
427
+ /** D6.2, 3 = 2 + 1. */
428
+ cacheValidators: {
429
+ saneCacheControl: number;
430
+ validator: number;
431
+ };
432
+ /** D6.3, 2. `present` alone for a file that exists; `specShaped` for one that parses as llms.txt. */
433
+ llmsTxt: {
434
+ present: number;
435
+ specShaped: number;
436
+ };
437
+ /** D6.4, 2. All-or-nothing. */
438
+ sitemap: {
439
+ full: number;
440
+ };
441
+ /** D6.5, 4. All-or-nothing over any ONE declared machine endpoint. */
442
+ machineEndpoint: {
443
+ full: number;
444
+ };
445
+ };
446
+ /** SHA-256 of a UTF-8 string, lowercase hex. FIPS 180-4. */
447
+ declare function sha256Hex(message: string): string;
448
+ /**
449
+ * RFC 8785 (JCS) canonical JSON, over the value shapes ARS actually hashes:
450
+ * objects, arrays, strings, booleans, null and JSON numbers.
451
+ *
452
+ * Two details make this RFC-conformant rather than merely deterministic:
453
+ * object keys are sorted by UTF-16 code unit (JCS §3.2.3, which is what
454
+ * JavaScript's default string comparison already does), and numbers are
455
+ * serialised with `JSON.stringify`, whose output is the ECMAScript
456
+ * `Number::toString` shortest round-trip form that JCS §3.2.2.3 mandates.
457
+ * `undefined` and functions cannot appear in the data we hash and are dropped.
458
+ */
459
+ declare function canonicalJson(value: unknown): string;
460
+ /** SHA-256 of the RFC 8785 canonical JSON of the frozen ruleset (§3.1). */
461
+ declare function rulesetHash(ruleset: ArsRuleset): string;
462
+ /**
463
+ * SHA-256 over the evidence bundle with the volatile fields removed: the header
464
+ * denylist above, and `capturedAt`, which is wall-clock time and is never an
465
+ * input to scoring. Bodies ARE hashed — `bodySha256` is already in the capture,
466
+ * but hashing the body itself means a bundle whose body was edited without
467
+ * updating its digest does not silently keep its identity.
468
+ */
469
+ declare function evidenceHash(evidence: ArsEvidence): string;
470
+ /**
471
+ * `corpusHash` — SHA-256 over the FROZEN conformance corpus (§3.1). Computing it
472
+ * requires reading the corpus directory, which the pure half cannot do, so it is
473
+ * a constant regenerated at corpus freeze.
474
+ *
475
+ * ARS 0.1 ships as a DRAFT (§3.10, "Calibration") and its corpus is still open:
476
+ * 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.1-corpus-unfrozen`. Anyone who
478
+ * recomputes the digest of the shipped corpus will find it does not match, which
479
+ * is the correct signal: a score carrying this constant is a draft score. It is
480
+ * computed rather than pasted so that no reader has to trust a magic literal.
481
+ */
482
+ declare const ARS_CORPUS_HASH: string;
483
+ /** The band a score falls in. Bands headline; the integer is secondary (§3.6). */
484
+ declare function bandFor(score: number, ruleset?: ArsRuleset): ArsBand | null;
485
+ /**
486
+ * The entire pure surface. No network. No clock. No randomness. No LLM.
487
+ *
488
+ * GATE ORDER, and why it is this order:
489
+ * 1. `robots-disallow-scanner` — a statement about OUR conduct. If we were not
490
+ * allowed to fetch, nothing else about the evidence should be reported.
491
+ * Only `vantage: 'public'` is gated; an owner can consent for their own
492
+ * origin (§3.7), and a merchant scanning their own store getting `unscored`
493
+ * because they block unknown tokens is a product regression dressed as rigour.
494
+ * 2. `robots-unavailable` — a persistent 5xx means we could not learn the policy.
495
+ * 3. `opt-out` — the site's own decision, reported before any failure of ours,
496
+ * because it is a choice and not a failure.
497
+ * 4. Fetch failures, then a bundle with no body, then a truncated body.
498
+ */
499
+ declare function score(evidence: ArsEvidence, ruleset?: ArsRuleset): ArsResult;
500
+
501
+ /**
502
+ * recommend.ts — what to fix, in what order, and what each fix is worth.
503
+ *
504
+ * WHY THIS FILE HAS A SPEC AT ALL. Recommendation arithmetic was undefined in
505
+ * every source design, and it is the surface merchants actually act on: nobody
506
+ * ships a change because a dimension moved, they ship it because a list said
507
+ * "this is worth 13 points". A list that double-counts is a list that promises 30
508
+ * points and delivers 16, and the second scan is where the product loses its
509
+ * credibility. So §3.9's final paragraph pins the arithmetic and this file
510
+ * implements exactly that:
511
+ *
512
+ * Recommendations are computed over a DEPENDENCY DAG. A recommendation's
513
+ * `pointsAvailable` counts only the checks not already claimed by a
514
+ * higher-ranked recommendation, plus the checks it uniquely UNLOCKS. Sums per
515
+ * dimension are capped at the dimension weight. A property test asserts
516
+ * `Σ pointsAvailable ≤ 100 − score`.
517
+ *
518
+ * WHAT "UNLOCKS" MEANS, PRECISELY. Two checks in ARS 0.1 are gated on D2.1: D2.3
519
+ * (`Vary: Accept` is meaningless on a response that does not vary) and D2.4
520
+ * (substance parity has nothing to compare against). While D2.1 is at zero,
521
+ * their points are not reachable by any other action, so they belong to the
522
+ * recommendation that closes D2.1 — and to no other, which is what stops
523
+ * "declare Vary: Accept" from also claiming them. Once D2.1 is earned, the gate
524
+ * is open and D2.3 stands on its own. `unlocks` is therefore CONDITIONAL, not a
525
+ * fixed edge list, and each template says when its edge exists.
526
+ *
527
+ * ORDER IS THE RANKING. The output array is in priority order: biggest raw
528
+ * recovery first, ties broken by effort (a config change before an engineering
529
+ * project) and then by id, so two runs over the same result produce the same
530
+ * list. The dedup walks that same order, which is what "higher-ranked" means.
531
+ *
532
+ * NO POINTS ARE INVENTED. Every number is the gap between a check's `earned` and
533
+ * its `weight` in the result being explained. A recommendation whose checks are
534
+ * all already full does not appear at all — an empty list is the correct output
535
+ * for a page at 100, and a list of platitudes would be worse than nothing.
536
+ */
537
+
538
+ /** What `recommend()` needs from a result. Callers holding an `ArsResult` can pass it directly. */
539
+ type ArsRecommendationInput = Pick<ArsResult, 'dimensions' | 'score'>;
540
+ /**
541
+ * Ranked, deduplicated remedies for a scored result.
542
+ *
543
+ * Returns an empty array for a non-grade (`score: null`): an unscored or
544
+ * opted-out target has no sub-scores, so there is nothing to recover and no
545
+ * honest number to attach to advice.
546
+ */
547
+ declare function recommend(input: ArsRecommendationInput): ArsRecommendation[];
548
+
549
+ /**
550
+ * classify.ts — the two-pass page-kind classifier (design §3.5).
551
+ *
552
+ * THE CIRCULARITY THIS RESOLVES. Fact extraction needs a profile; the profile
553
+ * comes from the page kind; the page kind looks like something you would infer
554
+ * from the facts. Every source design had that loop and none of them cut it. The
555
+ * decided answer is two passes with a hard wall between them:
556
+ *
557
+ * PASS 1 extracts a FIXED, KIND-INDEPENDENT probe set — JSON-LD `@type`,
558
+ * microdata `itemtype`, RDFa `typeof`, `og:type`, URL path grammar,
559
+ * currency-token presence, day-name/`HH:MM` adjacency, and `tel:` presence.
560
+ * **Only pass-1 output may inform classification.** Nothing in this file reads
561
+ * a profile, and `pass1Signals()` takes no page kind.
562
+ *
563
+ * PASS 2 (`./extract`) extracts against the resolved profile.
564
+ *
565
+ * Because pass 1 is fixed, two implementations classify the same bytes the same
566
+ * way, and because it is small, a reader can check that it is fixed.
567
+ *
568
+ * PRECEDENCE, from §3.5: JSON-LD `@type` (through a pinned table) → microdata /
569
+ * RDFa → `og:type` → URL path patterns → pass-1 structural signals. Ties are
570
+ * broken by declared precedence, then lexicographically by `@type`.
571
+ *
572
+ * CONFIDENCE, AND WHY `unknown` IS NOT A PENALTY BOX. Below `medium` confidence
573
+ * the kind is `unknown` — **we never guess into a vertical**, because guessing
574
+ * `product` on an article scores that article against a fact set it has no
575
+ * reason to carry, and the merchant cannot argue with a number. `unknown` is
576
+ * also not an easy exit: it carries its own profile (title, description,
577
+ * primary-action-url) and still scores D5.2 against "any recognised schema.org
578
+ * type present", so hiding your page kind costs up to 7 points and gains nothing.
579
+ *
580
+ * THE TABLES BELOW ARE VERSIONED DATA. Adding a schema.org type or a URL pattern
581
+ * changes the kind of some real page, which changes its profile, which changes
582
+ * its score — so additions land as a MINOR, exactly like a ruleset edit. They
583
+ * live here rather than in `DEFAULT_RULESET` because §3.9's `ArsRuleset` has no
584
+ * field for them; that means they are NOT covered by `rulesetHash`, and the gap
585
+ * is recorded in the package README as a known limitation of 0.1.
586
+ */
587
+
588
+ interface ArsPass1Signals {
589
+ /** `@type` values from every JSON-LD node, prefix-stripped, document order. */
590
+ readonly jsonLdTypes: readonly string[];
591
+ /** `itemtype` values, reduced to their final path segment. */
592
+ readonly microdataTypes: readonly string[];
593
+ /** RDFa `typeof` values, whitespace-split. */
594
+ readonly rdfaTypes: readonly string[];
595
+ /** `<meta property="og:type">`, lowercased. */
596
+ readonly ogType: string | null;
597
+ /** Lowercased, non-empty path segments of the target URL. */
598
+ readonly pathSegments: readonly string[];
599
+ /** At least one substring that `parseMoneyText` accepts. */
600
+ readonly hasCurrencyToken: boolean;
601
+ /** A day name within 40 characters of a clock time. */
602
+ readonly hasOpeningHours: boolean;
603
+ /** A `tel:` link, or a `telephone` property in structured data. */
604
+ readonly hasTelephone: boolean;
605
+ }
606
+ interface ArsClassification {
607
+ readonly pageKind: ArsPageKind;
608
+ readonly confidence: 'high' | 'medium' | 'low';
609
+ /** Which pass-1 signal decided it. Published as check evidence, not just logged. */
610
+ readonly signal: string;
611
+ /** True when SOME recognised schema.org type was present, whatever the kind. */
612
+ readonly hasRecognisedType: boolean;
613
+ }
614
+ /**
615
+ * Resolves the page kind from pass-1 signals and nothing else.
616
+ *
617
+ * The `low` → `unknown` collapse at the end is the "never guess into a vertical"
618
+ * rule made mechanical: a lone currency token on a page with no type, no og:type
619
+ * and no path grammar is not enough to call it a product, and a wrong vertical
620
+ * is worse than no vertical because it scores the page against facts it was
621
+ * never trying to state.
622
+ */
623
+ declare function classify(signals: ArsPass1Signals): ArsClassification;
624
+
625
+ /**
626
+ * profiles.ts — the eight page-kind fact profiles. Design §3.5, table verbatim.
627
+ *
628
+ * THE ONE IDEA IN THIS FILE. ARS uses fixed weights for every page kind. What
629
+ * varies is *what counts as a fact* and *what a page of that kind reasonably
630
+ * costs*:
631
+ *
632
+ * > ARS does not measure how much you say. It measures whether the facts a
633
+ * > caller needs **for this kind of page** are present, findable, and cheap
634
+ * > **relative to what that kind of page costs**.
635
+ *
636
+ * Per-vertical *weights* would be the wrong design — it makes an 88 mean
637
+ * different things on different pages and invites site-type shopping. A
638
+ * per-vertical *fact set* and *byte reference* are not weights: an article that
639
+ * spends 38 KB saying something is not penalised against a 40 KB reference,
640
+ * while a product page that spends 38 KB to state four facts is. The byte
641
+ * reference is specifically what stops long-form content being structurally
642
+ * capped around C, which every source design that used absolute byte bands did.
643
+ *
644
+ * The set is CLOSED at eight, and every kind has a complete profile — there is
645
+ * no "no profile" path. Conformance fixture `058-profiles-total-and-typed`
646
+ * asserts both halves of that: the mapping is total over `ArsPageKind`, and
647
+ * every fact name is a member of `ArsFactKind`. `PROFILE_BY_KIND` is typed as a
648
+ * total `Record`, so the first half is also a compile error.
649
+ *
650
+ * `unknown` is deliberately not an easy exit. It carries the smallest core set,
651
+ * but it still scores D5.2 against "any recognised schema.org type present",
652
+ * which requires having a type at all. Hiding your page kind costs up to 7
653
+ * points and gains nothing on coverage.
654
+ *
655
+ * ── Definitions of the fact terms the source designs left undefined (§3.5) ──
656
+ *
657
+ * `primary-action-url` — a same-origin-or-declared URL reachable from an
658
+ * `<a href>`, a `<form action>`, or JSON-LD `potentialAction.target`, whose
659
+ * anchor text or `name` matches the ruleset's action lexicon (`book`, `apply`,
660
+ * `contact`, `buy`, `subscribe`, `start`, `request`, `download`, `sign up`,
661
+ * `get a quote` and their pinned synonyms). The lexicon is pinned in
662
+ * `DEFAULT_RULESET.actionLexicon`, not inferred per page.
663
+ *
664
+ * `authority` — an organisation or person named as the publisher of the content,
665
+ * extracted from JSON-LD `publisher`/`author`, `<meta name="author">`, or a
666
+ * `rel="publisher"` link.
667
+ *
668
+ * `org-name` — JSON-LD `Organization.name` / `LocalBusiness.name`,
669
+ * `og:site_name`, or `<meta itemprop="name">` on an org-typed scope.
670
+ *
671
+ * `item-count` / `item-link` — for `collection`: the number of distinct item
672
+ * links inside the largest repeated-structure block, and whether those links
673
+ * resolve to same-origin URLs. Counted from the largest repeated block
674
+ * specifically so that a nav menu is not mistaken for a product grid.
675
+ *
676
+ * `question-answer` — a `FAQPage`/`Question` JSON-LD pair, or a `<dt>/<dd>`, a
677
+ * `<details><summary>`, or a heading-followed-by-paragraph pair. Counted ONCE
678
+ * as present, not per item: a page with 40 questions is not four times better
679
+ * than a page with 10.
680
+ *
681
+ * `price` is satisfied by an explicit "no published price" signal as well as by
682
+ * a number. We score honesty, not disclosure — a service page that says
683
+ * "pricing on request" has told the agent what it needs to know.
684
+ */
685
+
686
+ /**
687
+ * The same eight profiles as the array `ArsRuleset.profiles` expects, in
688
+ * declaration order (which is the order they appear in the §3.5 table, and is
689
+ * therefore the order the spec renders them in).
690
+ *
691
+ * Runtime immutability: `as const` above makes every profile deeply readonly to
692
+ * TypeScript, and `DEFAULT_RULESET` deep-freezes these exact objects at module
693
+ * load, so a consumer cannot mutate a shared profile and silently change every
694
+ * subsequent score.
695
+ */
696
+ declare const PROFILES: readonly ArsFactProfile[];
697
+ /** Total by construction — `PROFILE_BY_KIND` is typed as a total Record. */
698
+ declare function profileFor(pageKind: ArsPageKind): ArsFactProfile;
699
+
700
+ /**
701
+ * parse-money.ts — text → `Money`, or `null` when ambiguous. Design §3.11.
702
+ *
703
+ * WHY THIS IS ITS OWN FILE, AND WHY IT IS BIG. `packages/render-md/src/money.ts`
704
+ * only *formats* an already-structured `Money`. It cannot parse text, and the
705
+ * claim that it could hid the largest single piece of extraction work in the
706
+ * program. Price is a core fact for `product` and `service`, it is one of the
707
+ * four values compared by the D2.4 substance-parity check, and it is the value a
708
+ * buying agent acts on. Everything downstream of a wrong price is wrong.
709
+ *
710
+ * FAILS CLOSED, like `formatMoney`. Ambiguous input returns `null`, and a `null`
711
+ * price is simply not a fact — it costs coverage points and nothing else. A
712
+ * *wrong* price would be reported as truth on a public scanner page, and would
713
+ * make a parity check accuse a merchant of divergence they did not commit.
714
+ * Every rule below resolves in favour of `null`.
715
+ *
716
+ * WHY `Money` IS DECLARED HERE RATHER THAN IMPORTED. It is structurally
717
+ * identical to `@rebilder/render-md`'s `Money`, and duplicating it is
718
+ * deliberate: `tooling/check-package-graph.ts` forbids
719
+ * `agent-readability → render-md` (and the reverse) in the `ars-boundary` rule.
720
+ * The two packages point in opposite directions — gateway/render-md turn a
721
+ * source of truth into output; the scorer turns a response into a judgment — so
722
+ * a dependency either way is a design error before it is a size one. Four bytes
723
+ * of duplicated interface is the cheap side of that trade.
724
+ *
725
+ * NO `String.prototype.normalize()`. Unicode normalisation is deterministic only
726
+ * for a fixed Unicode version, and the Unicode version is a property of the
727
+ * host's ICU build. That is the same class of unversioned input as a
728
+ * third-party HTML parser, and the same answer applies: every character this
729
+ * parser special-cases is listed here, in a pinned table.
730
+ *
731
+ * SUPPORTED FORMATS (§3.11 enumerates these; each has a test):
732
+ * leading symbol `$1,499.00` `€49` `¥4,900`
733
+ * trailing symbol `1.499,00 €` `49 zł`
734
+ * ISO code prefix/suffix `USD 1499` `1499 USD`
735
+ * comma and period as BOTH group and decimal separator, disambiguated by
736
+ * position and by the minor-unit digits of the resolved currency
737
+ * space / NBSP / narrow-NBSP / apostrophe group separators `1 499,00` `1'499.00`
738
+ * zero-decimal currencies `¥4,900` → 4900, not 490000
739
+ * ranges `$148.00 – $198.00` → the LOWER bound, `qualified: true`
740
+ * qualifiers `From $9`, `$9+` → the stated bound, `qualified: true`
741
+ *
742
+ * `qualified: true` EXISTS FOR ONE REASON: qualified values are excluded from
743
+ * the D2.4 parity comparison. "From $9" in markdown against "$9 – $40" in HTML is
744
+ * the same page saying the same thing in two shapes, and flagging it as a
745
+ * substance divergence would be a false accusation.
746
+ */
747
+ /**
748
+ * Structural duplicate of `@rebilder/render-md`'s `Money` — same field names,
749
+ * same semantics, deliberately not imported (see the file header).
750
+ * `amount` is an INTEGER NUMBER OF MINOR UNITS: 4900 is $49.00 in USD and ¥4,900
751
+ * in JPY, because JPY has no minor unit.
752
+ */
753
+ interface Money {
754
+ amount: number;
755
+ currency: string;
756
+ }
757
+ /**
758
+ * What `parseMoneyText` returns: a `Money`, plus whether the source text stated
759
+ * a bound rather than a price.
760
+ */
761
+ interface ParsedMoney extends Money {
762
+ /** True for ranges (`$148 – $198`) and qualifiers (`From $9`, `$9+`). */
763
+ qualified: boolean;
764
+ }
765
+ interface MoneyHints {
766
+ /**
767
+ * ISO 4217 code the page is known to price in — from JSON-LD `priceCurrency`,
768
+ * a `<meta itemprop="priceCurrency">`, or the negotiated representation.
769
+ * Does two jobs: it resolves symbols shared by several currencies (`$`, `¥`,
770
+ * `kr`), and its minor-unit digit count disambiguates a lone separator
771
+ * followed by three digits.
772
+ */
773
+ currency?: string;
774
+ }
775
+ /** Minor-unit digit count for an ISO 4217 code. Unknown codes are treated as 2. */
776
+ declare function minorUnitDigits(code: string): number;
777
+ /**
778
+ * Text → `Money`, or `null` when ambiguous. Fails closed, like `formatMoney`.
779
+ *
780
+ * Ranges and qualifiers return the lower bound with `qualified: true`, which
781
+ * excludes them from the D2.4 parity comparison.
782
+ */
783
+ declare function parseMoneyText(text: string, hints?: MoneyHints): ParsedMoney | null;
784
+
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 };