@rebilder/agent-readability 0.1.1 → 0.3.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.
@@ -85,13 +85,13 @@ function deepFreeze(value) {
85
85
  return Object.freeze(value);
86
86
  }
87
87
  var WEIGHTS = {
88
- // D1 Retrievability — 20
89
- "retrievability.reachable": 8,
90
- "retrievability.robots-policy": 6,
91
- "retrievability.render-independence": 6,
92
- // D2 Machine representation — 20
93
- "machine-representation.negotiated-response": 10,
94
- "machine-representation.declared-alternates": 4,
88
+ // D1 Retrievability — 28
89
+ "retrievability.reachable": 11,
90
+ "retrievability.robots-policy": 10,
91
+ "retrievability.render-independence": 7,
92
+ // D2 Machine representation — 18
93
+ "machine-representation.negotiated-response": 9,
94
+ "machine-representation.declared-alternates": 3,
95
95
  "machine-representation.vary-accept": 3,
96
96
  "machine-representation.substance-parity": 3,
97
97
  // D3 Fact coverage — 20
@@ -100,16 +100,20 @@ var WEIGHTS = {
100
100
  // D4 Fact position — 10
101
101
  "fact-position.first-core-fact-offset": 5,
102
102
  "fact-position.front-window": 5,
103
- // D5 Structured data — 15
104
- "structured-data.present": 5,
105
- "structured-data.required-properties": 7,
106
- "structured-data.text-agreement": 3,
107
- // D6 Contract & discovery — 15
103
+ // D5 Structured data — 6
104
+ "structured-data.present": 2,
105
+ "structured-data.required-properties": 3,
106
+ "structured-data.text-agreement": 1,
107
+ // D6 Contract & discovery — 10
108
108
  "contract-discovery.canonical": 4,
109
- "contract-discovery.cache-validators": 3,
110
- "contract-discovery.llms-txt": 2,
111
- "contract-discovery.sitemap": 2,
112
- "contract-discovery.machine-endpoint": 4
109
+ "contract-discovery.cache-validators": 2,
110
+ "contract-discovery.llms-txt": 1,
111
+ "contract-discovery.sitemap": 1,
112
+ "contract-discovery.machine-endpoint": 2,
113
+ // D7 Evidence density — 8
114
+ "evidence-density.quantities": 4,
115
+ "evidence-density.definitions": 2,
116
+ "evidence-density.comparisons": 2
113
117
  };
114
118
  var THRESHOLDS = {
115
119
  /**
@@ -141,6 +145,31 @@ var THRESHOLDS = {
141
145
  * `ratio = 100 × bytes / byteReference[pageKind]`; above the last threshold, 0.
142
146
  */
143
147
  "fact-coverage.context-cost": [100, 6, 200, 5, 500, 3, 1500, 1],
148
+ /**
149
+ * D7.1 quantities, 4 pts. AT-LEAST over the count of DISTINCT quantity tokens
150
+ * in the agent's counted text: a currency amount, a percentage, a number
151
+ * carrying a unit, or an ISO date. Distinct, because a price repeated in a
152
+ * header, a buy box and a footer is one fact stated three times, and counting
153
+ * it three times would reward the repetition this score exists to discourage.
154
+ * Saturates at 12 so a specification table cannot outscore a page that simply
155
+ * states its facts.
156
+ */
157
+ "evidence-density.quantities": [12, 4, 6, 3, 3, 2, 1, 1],
158
+ /**
159
+ * D7.2 definitions, 2 pts. AT-LEAST over the count of `term: value` pairs the
160
+ * agent can read as a labelled fact, counting markdown bold-label lines,
161
+ * list items with a leading label, and HTML definition lists.
162
+ */
163
+ "evidence-density.definitions": [6, 2, 2, 1],
164
+ /**
165
+ * D7.3 comparisons, 2 pts. AT-LEAST over the number of comparable ROWS: a
166
+ * table with at least two data columns contributes its data-row count, minus
167
+ * the header. One row is not a comparison, so the band starts at two; three
168
+ * options laid side by side is a full comparison and pays out. Calibrated
169
+ * against fixture `060`, where a three-row size table is exactly the shape
170
+ * this check exists to reward, and `063`, where one row is not.
171
+ */
172
+ "evidence-density.comparisons": [3, 2, 2, 1],
144
173
  /** D4.1 first-core-fact byte offset, 5 pts. AT-MOST over the offset in bytes; else 0. */
145
174
  "fact-position.first-core-fact-offset": [512, 5, 2048, 4, 8192, 2, 32768, 1],
146
175
  /**
@@ -281,7 +310,7 @@ var BANDS = [
281
310
  }
282
311
  ];
283
312
  var DEFAULT_RULESET = deepFreeze({
284
- version: "0.1.0",
313
+ version: "0.2.0",
285
314
  weights: WEIGHTS,
286
315
  thresholds: THRESHOLDS,
287
316
  audienceTokens: AUDIENCE_TOKENS,
@@ -385,6 +414,33 @@ function pathMatches(pattern, path) {
385
414
  return true;
386
415
  }
387
416
 
417
+ // src/robots-policy.ts
418
+ var ARS_ROBOTS_TOKEN = "rebilder-ars";
419
+ function robotsDisallowsScanner(robotsBody, path) {
420
+ const robots = parseRobots(robotsBody);
421
+ for (const group of robots.groups) {
422
+ if (!group.agents.some((agent) => agent.toLowerCase() === ARS_ROBOTS_TOKEN)) continue;
423
+ let best = null;
424
+ for (const value of group.allow) {
425
+ if (!pathMatches(value, path)) continue;
426
+ if (best === null || value.length > best.value.length) best = { field: "allow", value };
427
+ }
428
+ for (const value of group.disallow) {
429
+ if (!pathMatches(value, path)) continue;
430
+ if (best === null || value.length > best.value.length) best = { field: "disallow", value };
431
+ }
432
+ if (best !== null && best.field === "disallow") {
433
+ return `User-agent: ${ARS_ROBOTS_TOKEN} / Disallow: ${best.value}`;
434
+ }
435
+ }
436
+ return null;
437
+ }
438
+
439
+ // src/probe/headers.ts
440
+ var AGENT_ACCEPT = "text/markdown;q=1.0, text/html;q=0.8, text/plain;q=0.5, */*;q=0.1";
441
+ var BROWSER_ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
442
+ var ASSET_ACCEPT = "text/plain,*/*;q=0.5";
443
+
388
444
  // src/score.ts
389
445
  function idiv(numerator, denominator) {
390
446
  if (denominator === 0) return 0;
@@ -396,44 +452,50 @@ function deepFreeze2(value) {
396
452
  return Object.freeze(value);
397
453
  }
398
454
  deepFreeze2({
399
- /** D1.1, 8 = 4 + 2 + 2. */
400
- reachable: { status2xx: 4, withinRedirectLimit: 2, noAcceptConditionalRedirect: 2 },
401
- /** D1.2, 6 = 3 + 1 + 1 + 1. A disallowed assistant audience scores 0 for all four (§3.7). */
402
- robotsPolicy: { assistantAllowed: 3, parsesClean: 1, noOrphanRules: 1, sitemapDeclared: 1 },
455
+ /** D1.1, 11 = 5 + 3 + 3. */
456
+ reachable: { status2xx: 5, withinRedirectLimit: 3, noAcceptConditionalRedirect: 3 },
457
+ /** D1.2, 10 = 6 + 2 + 1 + 1. A disallowed assistant audience scores 0 for all four (§3.7). */
458
+ robotsPolicy: { assistantAllowed: 6, parsesClean: 2, noOrphanRules: 1, sitemapDeclared: 1 },
403
459
  /**
404
- * D1.3, 6. AT-LEAST band over `100 × coreFactsInHtml / coreProfileSize`, plus
460
+ * D1.3, 7. AT-LEAST band over `100 × coreFactsInHtml / coreProfileSize`, plus
405
461
  * the `<noscript>` floor: a page whose facts are all client-rendered but which
406
462
  * ships a non-empty `<noscript>` has told a JS-less caller something, and §3.8
407
463
  * says that earns partial credit.
408
464
  */
409
465
  renderIndependence: {
410
- band: [100, 6, 75, 5, 50, 3, 25, 1],
466
+ band: [100, 7, 75, 5, 50, 3, 25, 1],
411
467
  noscriptFloor: 1
412
468
  },
413
- /** D2.1, 10. All-or-nothing: a machine media type AND a body that is not HTML. */
414
- negotiatedResponse: { full: 10 },
415
- /** D2.2, 4. All-or-nothing. */
416
- declaredAlternates: { full: 4 },
469
+ /** D2.1, 9. All-or-nothing: a machine media type AND a body that is not HTML. */
470
+ negotiatedResponse: { full: 9 },
471
+ /** D2.2, 3. All-or-nothing. */
472
+ declaredAlternates: { full: 3 },
417
473
  /** D2.3, 3. All-or-nothing, and 0 unless D2.1 > 0. */
418
474
  varyAccept: { full: 3 },
419
475
  /** D2.4, 3. All-or-nothing, and 0 unless D2.1 > 0 and a browser capture exists. */
420
476
  substanceParity: { full: 3 },
421
- /** D5.1, 5. Structured data present AND parsing; a partly-broken graph scores 3. */
422
- structuredDataPresent: { clean: 5, partial: 3 },
423
- /** D5.2, 7 = 2 (a recognised type) + 5 (required-property completeness, scaled). */
424
- requiredProperties: { recognisedType: 2, completeness: 5 },
425
- /** D5.3, 3. All-or-nothing. */
426
- textAgreement: { full: 3 },
477
+ /** D5.1, 2. Structured data present AND parsing; a partly-broken graph scores 1. */
478
+ structuredDataPresent: { clean: 2, partial: 1 },
479
+ /** D5.2, 3 = 1 (a recognised type) + 2 (required-property completeness, scaled). */
480
+ requiredProperties: { recognisedType: 1, completeness: 2 },
481
+ /** D5.3, 1. All-or-nothing. */
482
+ textAgreement: { full: 1 },
427
483
  /** D6.1, 4 = 2 + 1 + 1. */
428
484
  canonical: { present: 2, absolute: 1, consistentAcrossProbes: 1 },
429
- /** D6.2, 3 = 2 + 1. */
430
- cacheValidators: { saneCacheControl: 2, validator: 1 },
431
- /** D6.3, 2. `present` alone for a file that exists; `specShaped` for one that parses as llms.txt. */
432
- llmsTxt: { present: 1, specShaped: 2 },
433
- /** D6.4, 2. All-or-nothing. */
434
- sitemap: { full: 2 },
435
- /** D6.5, 4. All-or-nothing over any ONE declared machine endpoint. */
436
- machineEndpoint: { full: 4 }
485
+ /** D6.2, 2 = 1 + 1. */
486
+ cacheValidators: { saneCacheControl: 1, validator: 1 },
487
+ /**
488
+ * D6.3, 1. `specShaped` — an H1 and at least one Markdown link — is the whole
489
+ * point. `present` is 0 in 0.2: at two points 0.1 could pay one for the file
490
+ * existing and one for it being usable, but at one point that split would make
491
+ * "exists" and "usable" score identically, which is a distinction the standard
492
+ * would then be printing a remedy for and paying nothing to fix.
493
+ */
494
+ llmsTxt: { present: 0, specShaped: 1 },
495
+ /** D6.4, 1. All-or-nothing. */
496
+ sitemap: { full: 1 },
497
+ /** D6.5, 2. All-or-nothing over any ONE declared machine endpoint. */
498
+ machineEndpoint: { full: 2 }
437
499
  });
438
500
  var SHA256_K = [
439
501
  1116352408,
@@ -557,7 +619,7 @@ function sha256Hex(message) {
557
619
  for (const word of h) hex += word.toString(16).padStart(8, "0");
558
620
  return hex;
559
621
  }
560
- sha256Hex("ars-0.1-corpus-unfrozen");
622
+ sha256Hex("ars-0.2-corpus-unfrozen");
561
623
  var ALLOW_PRIVATE_HOSTS = /* @__PURE__ */ Symbol("rebilder.ars.probe.allow-private-hosts");
562
624
  var allowsPrivateHosts = (policy) => policy === ALLOW_PRIVATE_HOSTS;
563
625
  var NOT_AN_IP = { family: null, reserved: false, label: "hostname" };
@@ -1005,11 +1067,7 @@ function createLimiter(options = {}) {
1005
1067
  }
1006
1068
 
1007
1069
  // src/probe/index.ts
1008
- var ARS_USER_AGENT = "rebilder-ars/0.1 (+https://rebilder.com/bots)";
1009
- var ARS_ROBOTS_TOKEN = "rebilder-ars";
1010
- var AGENT_ACCEPT = "text/markdown;q=1.0, text/html;q=0.8, text/plain;q=0.5, */*;q=0.1";
1011
- var BROWSER_ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
1012
- var ASSET_ACCEPT = "text/plain,*/*;q=0.5";
1070
+ var ARS_USER_AGENT = "rebilder-ars/0.2 (+https://rebilder.com/bots)";
1013
1071
  var AGENT_IDENTITY = {
1014
1072
  role: "agent",
1015
1073
  userAgent: ARS_USER_AGENT,
@@ -1244,25 +1302,6 @@ async function fetchWithPolicy(startUrl, headers, context) {
1244
1302
  }
1245
1303
  return failed("too-many-redirects", `More than ${policy.maxRedirects - 1} redirects.`);
1246
1304
  }
1247
- function scannerDisallows(robotsBody, path) {
1248
- const robots = parseRobots(robotsBody);
1249
- for (const group of robots.groups) {
1250
- if (!group.agents.some((agent) => agent.toLowerCase() === ARS_ROBOTS_TOKEN)) continue;
1251
- let best = null;
1252
- for (const value of group.allow) {
1253
- if (!pathMatches(value, path)) continue;
1254
- if (best === null || value.length > best.value.length) best = { field: "allow", value };
1255
- }
1256
- for (const value of group.disallow) {
1257
- if (!pathMatches(value, path)) continue;
1258
- if (best === null || value.length > best.value.length) best = { field: "disallow", value };
1259
- }
1260
- if (best !== null && best.field === "disallow") {
1261
- return `User-agent: ${ARS_ROBOTS_TOKEN} / Disallow: ${best.value}`;
1262
- }
1263
- }
1264
- return null;
1265
- }
1266
1305
  function headersFor(identity) {
1267
1306
  return { accept: identity.accept, "user-agent": identity.userAgent };
1268
1307
  }
@@ -1353,7 +1392,7 @@ async function probeWithHostPolicy(target, policy, hostPolicy, options = {}) {
1353
1392
  }
1354
1393
  const robotsBody = robotsTxt.result.ok ? robotsTxt.result.capture.body ?? "" : "";
1355
1394
  const robotsUsable = robotsTxt.result.ok && robotsTxt.result.capture.status < 400;
1356
- const disallowedFor = (path) => vantage === "public" && robotsUsable ? scannerDisallows(robotsBody, path) : null;
1395
+ const disallowedFor = (path) => vantage === "public" && robotsUsable ? robotsDisallowsScanner(robotsBody, path) : null;
1357
1396
  const pageRule = disallowedFor(url.pathname);
1358
1397
  if (pageRule !== null) {
1359
1398
  const detail = `robots.txt disallows the ${ARS_ROBOTS_TOKEN} token (${pageRule})`;
@@ -1412,5 +1451,3 @@ exports.probeWithHostPolicy = probeWithHostPolicy;
1412
1451
  exports.resolveAndValidate = resolveAndValidate;
1413
1452
  exports.strictPolicy = strictPolicy;
1414
1453
  exports.strictPolicyForRun = strictPolicyForRun;
1415
- //# sourceMappingURL=index.cjs.map
1416
- //# sourceMappingURL=index.cjs.map
@@ -1,4 +1,5 @@
1
- import { C as ArsVantage, e as ArsEvidence, c as ArsRuleset } from '../types-B2FhQ1YC.cjs';
1
+ import { F as ArsVantage, e as ArsEvidence, c as ArsRuleset } from '../robots-policy-DE8jix-e.cjs';
2
+ export { i as AGENT_ACCEPT, j as ARS_ROBOTS_TOKEN, l as ASSET_ACCEPT, G as BROWSER_ACCEPT } from '../robots-policy-DE8jix-e.cjs';
2
3
 
3
4
  /**
4
5
  * probe/ssrf.ts — the network-side host policy for `@rebilder/agent-readability`.
@@ -298,13 +299,17 @@ interface ProbeIdentity {
298
299
  readonly userAgent: string;
299
300
  readonly accept: string;
300
301
  }
301
- /** Honest, contactable, and never anybody else's. */
302
- declare const ARS_USER_AGENT = "rebilder-ars/0.1 (+https://rebilder.com/bots)";
303
- /** The robots.txt token this probe answers to. Matched case-insensitively. */
304
- declare const ARS_ROBOTS_TOKEN = "rebilder-ars";
305
- declare const AGENT_ACCEPT = "text/markdown;q=1.0, text/html;q=0.8, text/plain;q=0.5, */*;q=0.1";
306
- declare const BROWSER_ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
307
- declare const ASSET_ACCEPT = "text/plain,*/*;q=0.5";
302
+ /**
303
+ * Honest, contactable, and never anybody else's. The number tracks the spec
304
+ * version, so a server log tells its operator which ruleset scored them.
305
+ *
306
+ * IT IS NOT THE REFUSAL TOKEN. A site that disallowed us under 0.1 is still
307
+ * refusing us under 0.2, because robots.txt is matched on `ARS_ROBOTS_TOKEN`
308
+ * below and that string never moves. Versioning the refusal token would let a
309
+ * spec bump quietly re-open sites that already said no.
310
+ */
311
+ declare const ARS_USER_AGENT = "rebilder-ars/0.2 (+https://rebilder.com/bots)";
312
+
308
313
  declare const DEFAULT_IDENTITIES: readonly ProbeIdentity[];
309
314
  /**
310
315
  * Policy as a type rather than a pile of booleans — and note what is NOT here:
@@ -382,4 +387,4 @@ declare function probeStrict(target: string, policy: ProbePolicy, options?: Prob
382
387
  /** Convenience for one-off callers: a fresh run-scoped limiter and the strict policy. */
383
388
  declare function strictPolicyForRun(overrides?: Partial<ProbePolicy>): ProbePolicy;
384
389
 
385
- export { AGENT_ACCEPT, ARS_ROBOTS_TOKEN, ARS_USER_AGENT, ASSET_ACCEPT, BROWSER_ACCEPT, DEFAULT_IDENTITIES, type HostPolicy, type HostResolver, type IpClassification, type Limiter, type LimiterLease, type LimiterOptions, type PinnedAddress, ProbeBudgetExceededError, type ProbeHttpResponse, type ProbeIdentity, type ProbeOptions, type ProbeOutcome, type ProbePolicy, type ProbeRejection, type ProbeRequestInit, type ProbeRole, type ProbeTransport, type ResolveOutcome, type UrlGuardPolicy, type UrlGuardResult, classifyIp, createDnsResolver, createLimiter, createPinnedTransport, fromWebResponse, guardPreviewUrl, guardUrl, parseIpv4, parseIpv6, probeStrict, probeWithHostPolicy, resolveAndValidate, strictPolicy, strictPolicyForRun };
390
+ export { ARS_USER_AGENT, DEFAULT_IDENTITIES, type HostPolicy, type HostResolver, type IpClassification, type Limiter, type LimiterLease, type LimiterOptions, type PinnedAddress, ProbeBudgetExceededError, type ProbeHttpResponse, type ProbeIdentity, type ProbeOptions, type ProbeOutcome, type ProbePolicy, type ProbeRejection, type ProbeRequestInit, type ProbeRole, type ProbeTransport, type ResolveOutcome, type UrlGuardPolicy, type UrlGuardResult, classifyIp, createDnsResolver, createLimiter, createPinnedTransport, fromWebResponse, guardPreviewUrl, guardUrl, parseIpv4, parseIpv6, probeStrict, probeWithHostPolicy, resolveAndValidate, strictPolicy, strictPolicyForRun };
@@ -1,4 +1,5 @@
1
- import { C as ArsVantage, e as ArsEvidence, c as ArsRuleset } from '../types-B2FhQ1YC.js';
1
+ import { F as ArsVantage, e as ArsEvidence, c as ArsRuleset } from '../robots-policy-DE8jix-e.js';
2
+ export { i as AGENT_ACCEPT, j as ARS_ROBOTS_TOKEN, l as ASSET_ACCEPT, G as BROWSER_ACCEPT } from '../robots-policy-DE8jix-e.js';
2
3
 
3
4
  /**
4
5
  * probe/ssrf.ts — the network-side host policy for `@rebilder/agent-readability`.
@@ -298,13 +299,17 @@ interface ProbeIdentity {
298
299
  readonly userAgent: string;
299
300
  readonly accept: string;
300
301
  }
301
- /** Honest, contactable, and never anybody else's. */
302
- declare const ARS_USER_AGENT = "rebilder-ars/0.1 (+https://rebilder.com/bots)";
303
- /** The robots.txt token this probe answers to. Matched case-insensitively. */
304
- declare const ARS_ROBOTS_TOKEN = "rebilder-ars";
305
- declare const AGENT_ACCEPT = "text/markdown;q=1.0, text/html;q=0.8, text/plain;q=0.5, */*;q=0.1";
306
- declare const BROWSER_ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
307
- declare const ASSET_ACCEPT = "text/plain,*/*;q=0.5";
302
+ /**
303
+ * Honest, contactable, and never anybody else's. The number tracks the spec
304
+ * version, so a server log tells its operator which ruleset scored them.
305
+ *
306
+ * IT IS NOT THE REFUSAL TOKEN. A site that disallowed us under 0.1 is still
307
+ * refusing us under 0.2, because robots.txt is matched on `ARS_ROBOTS_TOKEN`
308
+ * below and that string never moves. Versioning the refusal token would let a
309
+ * spec bump quietly re-open sites that already said no.
310
+ */
311
+ declare const ARS_USER_AGENT = "rebilder-ars/0.2 (+https://rebilder.com/bots)";
312
+
308
313
  declare const DEFAULT_IDENTITIES: readonly ProbeIdentity[];
309
314
  /**
310
315
  * Policy as a type rather than a pile of booleans — and note what is NOT here:
@@ -382,4 +387,4 @@ declare function probeStrict(target: string, policy: ProbePolicy, options?: Prob
382
387
  /** Convenience for one-off callers: a fresh run-scoped limiter and the strict policy. */
383
388
  declare function strictPolicyForRun(overrides?: Partial<ProbePolicy>): ProbePolicy;
384
389
 
385
- export { AGENT_ACCEPT, ARS_ROBOTS_TOKEN, ARS_USER_AGENT, ASSET_ACCEPT, BROWSER_ACCEPT, DEFAULT_IDENTITIES, type HostPolicy, type HostResolver, type IpClassification, type Limiter, type LimiterLease, type LimiterOptions, type PinnedAddress, ProbeBudgetExceededError, type ProbeHttpResponse, type ProbeIdentity, type ProbeOptions, type ProbeOutcome, type ProbePolicy, type ProbeRejection, type ProbeRequestInit, type ProbeRole, type ProbeTransport, type ResolveOutcome, type UrlGuardPolicy, type UrlGuardResult, classifyIp, createDnsResolver, createLimiter, createPinnedTransport, fromWebResponse, guardPreviewUrl, guardUrl, parseIpv4, parseIpv6, probeStrict, probeWithHostPolicy, resolveAndValidate, strictPolicy, strictPolicyForRun };
390
+ export { ARS_USER_AGENT, DEFAULT_IDENTITIES, type HostPolicy, type HostResolver, type IpClassification, type Limiter, type LimiterLease, type LimiterOptions, type PinnedAddress, ProbeBudgetExceededError, type ProbeHttpResponse, type ProbeIdentity, type ProbeOptions, type ProbeOutcome, type ProbePolicy, type ProbeRejection, type ProbeRequestInit, type ProbeRole, type ProbeTransport, type ResolveOutcome, type UrlGuardPolicy, type UrlGuardResult, classifyIp, createDnsResolver, createLimiter, createPinnedTransport, fromWebResponse, guardPreviewUrl, guardUrl, parseIpv4, parseIpv6, probeStrict, probeWithHostPolicy, resolveAndValidate, strictPolicy, strictPolicyForRun };
@@ -62,13 +62,13 @@ function deepFreeze(value) {
62
62
  return Object.freeze(value);
63
63
  }
64
64
  var WEIGHTS = {
65
- // D1 Retrievability — 20
66
- "retrievability.reachable": 8,
67
- "retrievability.robots-policy": 6,
68
- "retrievability.render-independence": 6,
69
- // D2 Machine representation — 20
70
- "machine-representation.negotiated-response": 10,
71
- "machine-representation.declared-alternates": 4,
65
+ // D1 Retrievability — 28
66
+ "retrievability.reachable": 11,
67
+ "retrievability.robots-policy": 10,
68
+ "retrievability.render-independence": 7,
69
+ // D2 Machine representation — 18
70
+ "machine-representation.negotiated-response": 9,
71
+ "machine-representation.declared-alternates": 3,
72
72
  "machine-representation.vary-accept": 3,
73
73
  "machine-representation.substance-parity": 3,
74
74
  // D3 Fact coverage — 20
@@ -77,16 +77,20 @@ var WEIGHTS = {
77
77
  // D4 Fact position — 10
78
78
  "fact-position.first-core-fact-offset": 5,
79
79
  "fact-position.front-window": 5,
80
- // D5 Structured data — 15
81
- "structured-data.present": 5,
82
- "structured-data.required-properties": 7,
83
- "structured-data.text-agreement": 3,
84
- // D6 Contract & discovery — 15
80
+ // D5 Structured data — 6
81
+ "structured-data.present": 2,
82
+ "structured-data.required-properties": 3,
83
+ "structured-data.text-agreement": 1,
84
+ // D6 Contract & discovery — 10
85
85
  "contract-discovery.canonical": 4,
86
- "contract-discovery.cache-validators": 3,
87
- "contract-discovery.llms-txt": 2,
88
- "contract-discovery.sitemap": 2,
89
- "contract-discovery.machine-endpoint": 4
86
+ "contract-discovery.cache-validators": 2,
87
+ "contract-discovery.llms-txt": 1,
88
+ "contract-discovery.sitemap": 1,
89
+ "contract-discovery.machine-endpoint": 2,
90
+ // D7 Evidence density — 8
91
+ "evidence-density.quantities": 4,
92
+ "evidence-density.definitions": 2,
93
+ "evidence-density.comparisons": 2
90
94
  };
91
95
  var THRESHOLDS = {
92
96
  /**
@@ -118,6 +122,31 @@ var THRESHOLDS = {
118
122
  * `ratio = 100 × bytes / byteReference[pageKind]`; above the last threshold, 0.
119
123
  */
120
124
  "fact-coverage.context-cost": [100, 6, 200, 5, 500, 3, 1500, 1],
125
+ /**
126
+ * D7.1 quantities, 4 pts. AT-LEAST over the count of DISTINCT quantity tokens
127
+ * in the agent's counted text: a currency amount, a percentage, a number
128
+ * carrying a unit, or an ISO date. Distinct, because a price repeated in a
129
+ * header, a buy box and a footer is one fact stated three times, and counting
130
+ * it three times would reward the repetition this score exists to discourage.
131
+ * Saturates at 12 so a specification table cannot outscore a page that simply
132
+ * states its facts.
133
+ */
134
+ "evidence-density.quantities": [12, 4, 6, 3, 3, 2, 1, 1],
135
+ /**
136
+ * D7.2 definitions, 2 pts. AT-LEAST over the count of `term: value` pairs the
137
+ * agent can read as a labelled fact, counting markdown bold-label lines,
138
+ * list items with a leading label, and HTML definition lists.
139
+ */
140
+ "evidence-density.definitions": [6, 2, 2, 1],
141
+ /**
142
+ * D7.3 comparisons, 2 pts. AT-LEAST over the number of comparable ROWS: a
143
+ * table with at least two data columns contributes its data-row count, minus
144
+ * the header. One row is not a comparison, so the band starts at two; three
145
+ * options laid side by side is a full comparison and pays out. Calibrated
146
+ * against fixture `060`, where a three-row size table is exactly the shape
147
+ * this check exists to reward, and `063`, where one row is not.
148
+ */
149
+ "evidence-density.comparisons": [3, 2, 2, 1],
121
150
  /** D4.1 first-core-fact byte offset, 5 pts. AT-MOST over the offset in bytes; else 0. */
122
151
  "fact-position.first-core-fact-offset": [512, 5, 2048, 4, 8192, 2, 32768, 1],
123
152
  /**
@@ -258,7 +287,7 @@ var BANDS = [
258
287
  }
259
288
  ];
260
289
  var DEFAULT_RULESET = deepFreeze({
261
- version: "0.1.0",
290
+ version: "0.2.0",
262
291
  weights: WEIGHTS,
263
292
  thresholds: THRESHOLDS,
264
293
  audienceTokens: AUDIENCE_TOKENS,
@@ -362,6 +391,33 @@ function pathMatches(pattern, path) {
362
391
  return true;
363
392
  }
364
393
 
394
+ // src/robots-policy.ts
395
+ var ARS_ROBOTS_TOKEN = "rebilder-ars";
396
+ function robotsDisallowsScanner(robotsBody, path) {
397
+ const robots = parseRobots(robotsBody);
398
+ for (const group of robots.groups) {
399
+ if (!group.agents.some((agent) => agent.toLowerCase() === ARS_ROBOTS_TOKEN)) continue;
400
+ let best = null;
401
+ for (const value of group.allow) {
402
+ if (!pathMatches(value, path)) continue;
403
+ if (best === null || value.length > best.value.length) best = { field: "allow", value };
404
+ }
405
+ for (const value of group.disallow) {
406
+ if (!pathMatches(value, path)) continue;
407
+ if (best === null || value.length > best.value.length) best = { field: "disallow", value };
408
+ }
409
+ if (best !== null && best.field === "disallow") {
410
+ return `User-agent: ${ARS_ROBOTS_TOKEN} / Disallow: ${best.value}`;
411
+ }
412
+ }
413
+ return null;
414
+ }
415
+
416
+ // src/probe/headers.ts
417
+ var AGENT_ACCEPT = "text/markdown;q=1.0, text/html;q=0.8, text/plain;q=0.5, */*;q=0.1";
418
+ var BROWSER_ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
419
+ var ASSET_ACCEPT = "text/plain,*/*;q=0.5";
420
+
365
421
  // src/score.ts
366
422
  function idiv(numerator, denominator) {
367
423
  if (denominator === 0) return 0;
@@ -373,44 +429,50 @@ function deepFreeze2(value) {
373
429
  return Object.freeze(value);
374
430
  }
375
431
  deepFreeze2({
376
- /** D1.1, 8 = 4 + 2 + 2. */
377
- reachable: { status2xx: 4, withinRedirectLimit: 2, noAcceptConditionalRedirect: 2 },
378
- /** D1.2, 6 = 3 + 1 + 1 + 1. A disallowed assistant audience scores 0 for all four (§3.7). */
379
- robotsPolicy: { assistantAllowed: 3, parsesClean: 1, noOrphanRules: 1, sitemapDeclared: 1 },
432
+ /** D1.1, 11 = 5 + 3 + 3. */
433
+ reachable: { status2xx: 5, withinRedirectLimit: 3, noAcceptConditionalRedirect: 3 },
434
+ /** D1.2, 10 = 6 + 2 + 1 + 1. A disallowed assistant audience scores 0 for all four (§3.7). */
435
+ robotsPolicy: { assistantAllowed: 6, parsesClean: 2, noOrphanRules: 1, sitemapDeclared: 1 },
380
436
  /**
381
- * D1.3, 6. AT-LEAST band over `100 × coreFactsInHtml / coreProfileSize`, plus
437
+ * D1.3, 7. AT-LEAST band over `100 × coreFactsInHtml / coreProfileSize`, plus
382
438
  * the `<noscript>` floor: a page whose facts are all client-rendered but which
383
439
  * ships a non-empty `<noscript>` has told a JS-less caller something, and §3.8
384
440
  * says that earns partial credit.
385
441
  */
386
442
  renderIndependence: {
387
- band: [100, 6, 75, 5, 50, 3, 25, 1],
443
+ band: [100, 7, 75, 5, 50, 3, 25, 1],
388
444
  noscriptFloor: 1
389
445
  },
390
- /** D2.1, 10. All-or-nothing: a machine media type AND a body that is not HTML. */
391
- negotiatedResponse: { full: 10 },
392
- /** D2.2, 4. All-or-nothing. */
393
- declaredAlternates: { full: 4 },
446
+ /** D2.1, 9. All-or-nothing: a machine media type AND a body that is not HTML. */
447
+ negotiatedResponse: { full: 9 },
448
+ /** D2.2, 3. All-or-nothing. */
449
+ declaredAlternates: { full: 3 },
394
450
  /** D2.3, 3. All-or-nothing, and 0 unless D2.1 > 0. */
395
451
  varyAccept: { full: 3 },
396
452
  /** D2.4, 3. All-or-nothing, and 0 unless D2.1 > 0 and a browser capture exists. */
397
453
  substanceParity: { full: 3 },
398
- /** D5.1, 5. Structured data present AND parsing; a partly-broken graph scores 3. */
399
- structuredDataPresent: { clean: 5, partial: 3 },
400
- /** D5.2, 7 = 2 (a recognised type) + 5 (required-property completeness, scaled). */
401
- requiredProperties: { recognisedType: 2, completeness: 5 },
402
- /** D5.3, 3. All-or-nothing. */
403
- textAgreement: { full: 3 },
454
+ /** D5.1, 2. Structured data present AND parsing; a partly-broken graph scores 1. */
455
+ structuredDataPresent: { clean: 2, partial: 1 },
456
+ /** D5.2, 3 = 1 (a recognised type) + 2 (required-property completeness, scaled). */
457
+ requiredProperties: { recognisedType: 1, completeness: 2 },
458
+ /** D5.3, 1. All-or-nothing. */
459
+ textAgreement: { full: 1 },
404
460
  /** D6.1, 4 = 2 + 1 + 1. */
405
461
  canonical: { present: 2, absolute: 1, consistentAcrossProbes: 1 },
406
- /** D6.2, 3 = 2 + 1. */
407
- cacheValidators: { saneCacheControl: 2, validator: 1 },
408
- /** D6.3, 2. `present` alone for a file that exists; `specShaped` for one that parses as llms.txt. */
409
- llmsTxt: { present: 1, specShaped: 2 },
410
- /** D6.4, 2. All-or-nothing. */
411
- sitemap: { full: 2 },
412
- /** D6.5, 4. All-or-nothing over any ONE declared machine endpoint. */
413
- machineEndpoint: { full: 4 }
462
+ /** D6.2, 2 = 1 + 1. */
463
+ cacheValidators: { saneCacheControl: 1, validator: 1 },
464
+ /**
465
+ * D6.3, 1. `specShaped` — an H1 and at least one Markdown link — is the whole
466
+ * point. `present` is 0 in 0.2: at two points 0.1 could pay one for the file
467
+ * existing and one for it being usable, but at one point that split would make
468
+ * "exists" and "usable" score identically, which is a distinction the standard
469
+ * would then be printing a remedy for and paying nothing to fix.
470
+ */
471
+ llmsTxt: { present: 0, specShaped: 1 },
472
+ /** D6.4, 1. All-or-nothing. */
473
+ sitemap: { full: 1 },
474
+ /** D6.5, 2. All-or-nothing over any ONE declared machine endpoint. */
475
+ machineEndpoint: { full: 2 }
414
476
  });
415
477
  var SHA256_K = [
416
478
  1116352408,
@@ -534,7 +596,7 @@ function sha256Hex(message) {
534
596
  for (const word of h) hex += word.toString(16).padStart(8, "0");
535
597
  return hex;
536
598
  }
537
- sha256Hex("ars-0.1-corpus-unfrozen");
599
+ sha256Hex("ars-0.2-corpus-unfrozen");
538
600
  var ALLOW_PRIVATE_HOSTS = /* @__PURE__ */ Symbol("rebilder.ars.probe.allow-private-hosts");
539
601
  var allowsPrivateHosts = (policy) => policy === ALLOW_PRIVATE_HOSTS;
540
602
  var NOT_AN_IP = { family: null, reserved: false, label: "hostname" };
@@ -982,11 +1044,7 @@ function createLimiter(options = {}) {
982
1044
  }
983
1045
 
984
1046
  // src/probe/index.ts
985
- var ARS_USER_AGENT = "rebilder-ars/0.1 (+https://rebilder.com/bots)";
986
- var ARS_ROBOTS_TOKEN = "rebilder-ars";
987
- var AGENT_ACCEPT = "text/markdown;q=1.0, text/html;q=0.8, text/plain;q=0.5, */*;q=0.1";
988
- var BROWSER_ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
989
- var ASSET_ACCEPT = "text/plain,*/*;q=0.5";
1047
+ var ARS_USER_AGENT = "rebilder-ars/0.2 (+https://rebilder.com/bots)";
990
1048
  var AGENT_IDENTITY = {
991
1049
  role: "agent",
992
1050
  userAgent: ARS_USER_AGENT,
@@ -1221,25 +1279,6 @@ async function fetchWithPolicy(startUrl, headers, context) {
1221
1279
  }
1222
1280
  return failed("too-many-redirects", `More than ${policy.maxRedirects - 1} redirects.`);
1223
1281
  }
1224
- function scannerDisallows(robotsBody, path) {
1225
- const robots = parseRobots(robotsBody);
1226
- for (const group of robots.groups) {
1227
- if (!group.agents.some((agent) => agent.toLowerCase() === ARS_ROBOTS_TOKEN)) continue;
1228
- let best = null;
1229
- for (const value of group.allow) {
1230
- if (!pathMatches(value, path)) continue;
1231
- if (best === null || value.length > best.value.length) best = { field: "allow", value };
1232
- }
1233
- for (const value of group.disallow) {
1234
- if (!pathMatches(value, path)) continue;
1235
- if (best === null || value.length > best.value.length) best = { field: "disallow", value };
1236
- }
1237
- if (best !== null && best.field === "disallow") {
1238
- return `User-agent: ${ARS_ROBOTS_TOKEN} / Disallow: ${best.value}`;
1239
- }
1240
- }
1241
- return null;
1242
- }
1243
1282
  function headersFor(identity) {
1244
1283
  return { accept: identity.accept, "user-agent": identity.userAgent };
1245
1284
  }
@@ -1330,7 +1369,7 @@ async function probeWithHostPolicy(target, policy, hostPolicy, options = {}) {
1330
1369
  }
1331
1370
  const robotsBody = robotsTxt.result.ok ? robotsTxt.result.capture.body ?? "" : "";
1332
1371
  const robotsUsable = robotsTxt.result.ok && robotsTxt.result.capture.status < 400;
1333
- const disallowedFor = (path) => vantage === "public" && robotsUsable ? scannerDisallows(robotsBody, path) : null;
1372
+ const disallowedFor = (path) => vantage === "public" && robotsUsable ? robotsDisallowsScanner(robotsBody, path) : null;
1334
1373
  const pageRule = disallowedFor(url.pathname);
1335
1374
  if (pageRule !== null) {
1336
1375
  const detail = `robots.txt disallows the ${ARS_ROBOTS_TOKEN} token (${pageRule})`;