@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.
- package/CHANGELOG.md +29 -0
- package/README.md +40 -158
- package/dist/index.cjs +266 -55
- package/dist/index.d.cts +206 -56
- package/dist/index.d.ts +206 -56
- package/dist/index.js +259 -54
- package/dist/index.js.map +1 -1
- package/dist/probe/index.cjs +106 -69
- 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 -69
- 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.ts → robots-policy-DE8jix-e.d.cts} +62 -9
- package/dist/{types-B2FhQ1YC.d.cts → robots-policy-DE8jix-e.d.ts} +62 -9
- package/package.json +22 -8
- package/dist/index.cjs.map +0 -1
- package/dist/probe/index.cjs.map +0 -1
- package/dist/probe/local.cjs.map +0 -1
package/dist/probe/local.cjs
CHANGED
|
@@ -427,13 +427,13 @@ function deepFreeze(value) {
|
|
|
427
427
|
return Object.freeze(value);
|
|
428
428
|
}
|
|
429
429
|
var WEIGHTS = {
|
|
430
|
-
// D1 Retrievability —
|
|
431
|
-
"retrievability.reachable":
|
|
432
|
-
"retrievability.robots-policy":
|
|
433
|
-
"retrievability.render-independence":
|
|
434
|
-
// D2 Machine representation —
|
|
435
|
-
"machine-representation.negotiated-response":
|
|
436
|
-
"machine-representation.declared-alternates":
|
|
430
|
+
// D1 Retrievability — 28
|
|
431
|
+
"retrievability.reachable": 11,
|
|
432
|
+
"retrievability.robots-policy": 10,
|
|
433
|
+
"retrievability.render-independence": 7,
|
|
434
|
+
// D2 Machine representation — 18
|
|
435
|
+
"machine-representation.negotiated-response": 9,
|
|
436
|
+
"machine-representation.declared-alternates": 3,
|
|
437
437
|
"machine-representation.vary-accept": 3,
|
|
438
438
|
"machine-representation.substance-parity": 3,
|
|
439
439
|
// D3 Fact coverage — 20
|
|
@@ -442,16 +442,20 @@ var WEIGHTS = {
|
|
|
442
442
|
// D4 Fact position — 10
|
|
443
443
|
"fact-position.first-core-fact-offset": 5,
|
|
444
444
|
"fact-position.front-window": 5,
|
|
445
|
-
// D5 Structured data —
|
|
446
|
-
"structured-data.present":
|
|
447
|
-
"structured-data.required-properties":
|
|
448
|
-
"structured-data.text-agreement":
|
|
449
|
-
// D6 Contract & discovery —
|
|
445
|
+
// D5 Structured data — 6
|
|
446
|
+
"structured-data.present": 2,
|
|
447
|
+
"structured-data.required-properties": 3,
|
|
448
|
+
"structured-data.text-agreement": 1,
|
|
449
|
+
// D6 Contract & discovery — 10
|
|
450
450
|
"contract-discovery.canonical": 4,
|
|
451
|
-
"contract-discovery.cache-validators":
|
|
452
|
-
"contract-discovery.llms-txt":
|
|
453
|
-
"contract-discovery.sitemap":
|
|
454
|
-
"contract-discovery.machine-endpoint":
|
|
451
|
+
"contract-discovery.cache-validators": 2,
|
|
452
|
+
"contract-discovery.llms-txt": 1,
|
|
453
|
+
"contract-discovery.sitemap": 1,
|
|
454
|
+
"contract-discovery.machine-endpoint": 2,
|
|
455
|
+
// D7 Evidence density — 8
|
|
456
|
+
"evidence-density.quantities": 4,
|
|
457
|
+
"evidence-density.definitions": 2,
|
|
458
|
+
"evidence-density.comparisons": 2
|
|
455
459
|
};
|
|
456
460
|
var THRESHOLDS = {
|
|
457
461
|
/**
|
|
@@ -483,6 +487,31 @@ var THRESHOLDS = {
|
|
|
483
487
|
* `ratio = 100 × bytes / byteReference[pageKind]`; above the last threshold, 0.
|
|
484
488
|
*/
|
|
485
489
|
"fact-coverage.context-cost": [100, 6, 200, 5, 500, 3, 1500, 1],
|
|
490
|
+
/**
|
|
491
|
+
* D7.1 quantities, 4 pts. AT-LEAST over the count of DISTINCT quantity tokens
|
|
492
|
+
* in the agent's counted text: a currency amount, a percentage, a number
|
|
493
|
+
* carrying a unit, or an ISO date. Distinct, because a price repeated in a
|
|
494
|
+
* header, a buy box and a footer is one fact stated three times, and counting
|
|
495
|
+
* it three times would reward the repetition this score exists to discourage.
|
|
496
|
+
* Saturates at 12 so a specification table cannot outscore a page that simply
|
|
497
|
+
* states its facts.
|
|
498
|
+
*/
|
|
499
|
+
"evidence-density.quantities": [12, 4, 6, 3, 3, 2, 1, 1],
|
|
500
|
+
/**
|
|
501
|
+
* D7.2 definitions, 2 pts. AT-LEAST over the count of `term: value` pairs the
|
|
502
|
+
* agent can read as a labelled fact, counting markdown bold-label lines,
|
|
503
|
+
* list items with a leading label, and HTML definition lists.
|
|
504
|
+
*/
|
|
505
|
+
"evidence-density.definitions": [6, 2, 2, 1],
|
|
506
|
+
/**
|
|
507
|
+
* D7.3 comparisons, 2 pts. AT-LEAST over the number of comparable ROWS: a
|
|
508
|
+
* table with at least two data columns contributes its data-row count, minus
|
|
509
|
+
* the header. One row is not a comparison, so the band starts at two; three
|
|
510
|
+
* options laid side by side is a full comparison and pays out. Calibrated
|
|
511
|
+
* against fixture `060`, where a three-row size table is exactly the shape
|
|
512
|
+
* this check exists to reward, and `063`, where one row is not.
|
|
513
|
+
*/
|
|
514
|
+
"evidence-density.comparisons": [3, 2, 2, 1],
|
|
486
515
|
/** D4.1 first-core-fact byte offset, 5 pts. AT-MOST over the offset in bytes; else 0. */
|
|
487
516
|
"fact-position.first-core-fact-offset": [512, 5, 2048, 4, 8192, 2, 32768, 1],
|
|
488
517
|
/**
|
|
@@ -623,7 +652,7 @@ var BANDS = [
|
|
|
623
652
|
}
|
|
624
653
|
];
|
|
625
654
|
var DEFAULT_RULESET = deepFreeze({
|
|
626
|
-
version: "0.
|
|
655
|
+
version: "0.2.0",
|
|
627
656
|
weights: WEIGHTS,
|
|
628
657
|
thresholds: THRESHOLDS,
|
|
629
658
|
audienceTokens: AUDIENCE_TOKENS,
|
|
@@ -727,6 +756,33 @@ function pathMatches(pattern, path) {
|
|
|
727
756
|
return true;
|
|
728
757
|
}
|
|
729
758
|
|
|
759
|
+
// src/robots-policy.ts
|
|
760
|
+
var ARS_ROBOTS_TOKEN = "rebilder-ars";
|
|
761
|
+
function robotsDisallowsScanner(robotsBody, path) {
|
|
762
|
+
const robots = parseRobots(robotsBody);
|
|
763
|
+
for (const group of robots.groups) {
|
|
764
|
+
if (!group.agents.some((agent) => agent.toLowerCase() === ARS_ROBOTS_TOKEN)) continue;
|
|
765
|
+
let best = null;
|
|
766
|
+
for (const value of group.allow) {
|
|
767
|
+
if (!pathMatches(value, path)) continue;
|
|
768
|
+
if (best === null || value.length > best.value.length) best = { field: "allow", value };
|
|
769
|
+
}
|
|
770
|
+
for (const value of group.disallow) {
|
|
771
|
+
if (!pathMatches(value, path)) continue;
|
|
772
|
+
if (best === null || value.length > best.value.length) best = { field: "disallow", value };
|
|
773
|
+
}
|
|
774
|
+
if (best !== null && best.field === "disallow") {
|
|
775
|
+
return `User-agent: ${ARS_ROBOTS_TOKEN} / Disallow: ${best.value}`;
|
|
776
|
+
}
|
|
777
|
+
}
|
|
778
|
+
return null;
|
|
779
|
+
}
|
|
780
|
+
|
|
781
|
+
// src/probe/headers.ts
|
|
782
|
+
var AGENT_ACCEPT = "text/markdown;q=1.0, text/html;q=0.8, text/plain;q=0.5, */*;q=0.1";
|
|
783
|
+
var BROWSER_ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
|
|
784
|
+
var ASSET_ACCEPT = "text/plain,*/*;q=0.5";
|
|
785
|
+
|
|
730
786
|
// src/score.ts
|
|
731
787
|
function idiv(numerator, denominator) {
|
|
732
788
|
if (denominator === 0) return 0;
|
|
@@ -738,44 +794,50 @@ function deepFreeze2(value) {
|
|
|
738
794
|
return Object.freeze(value);
|
|
739
795
|
}
|
|
740
796
|
deepFreeze2({
|
|
741
|
-
/** D1.1,
|
|
742
|
-
reachable: { status2xx:
|
|
743
|
-
/** D1.2,
|
|
744
|
-
robotsPolicy: { assistantAllowed:
|
|
797
|
+
/** D1.1, 11 = 5 + 3 + 3. */
|
|
798
|
+
reachable: { status2xx: 5, withinRedirectLimit: 3, noAcceptConditionalRedirect: 3 },
|
|
799
|
+
/** D1.2, 10 = 6 + 2 + 1 + 1. A disallowed assistant audience scores 0 for all four (§3.7). */
|
|
800
|
+
robotsPolicy: { assistantAllowed: 6, parsesClean: 2, noOrphanRules: 1, sitemapDeclared: 1 },
|
|
745
801
|
/**
|
|
746
|
-
* D1.3,
|
|
802
|
+
* D1.3, 7. AT-LEAST band over `100 × coreFactsInHtml / coreProfileSize`, plus
|
|
747
803
|
* the `<noscript>` floor: a page whose facts are all client-rendered but which
|
|
748
804
|
* ships a non-empty `<noscript>` has told a JS-less caller something, and §3.8
|
|
749
805
|
* says that earns partial credit.
|
|
750
806
|
*/
|
|
751
807
|
renderIndependence: {
|
|
752
|
-
band: [100,
|
|
808
|
+
band: [100, 7, 75, 5, 50, 3, 25, 1],
|
|
753
809
|
noscriptFloor: 1
|
|
754
810
|
},
|
|
755
|
-
/** D2.1,
|
|
756
|
-
negotiatedResponse: { full:
|
|
757
|
-
/** D2.2,
|
|
758
|
-
declaredAlternates: { full:
|
|
811
|
+
/** D2.1, 9. All-or-nothing: a machine media type AND a body that is not HTML. */
|
|
812
|
+
negotiatedResponse: { full: 9 },
|
|
813
|
+
/** D2.2, 3. All-or-nothing. */
|
|
814
|
+
declaredAlternates: { full: 3 },
|
|
759
815
|
/** D2.3, 3. All-or-nothing, and 0 unless D2.1 > 0. */
|
|
760
816
|
varyAccept: { full: 3 },
|
|
761
817
|
/** D2.4, 3. All-or-nothing, and 0 unless D2.1 > 0 and a browser capture exists. */
|
|
762
818
|
substanceParity: { full: 3 },
|
|
763
|
-
/** D5.1,
|
|
764
|
-
structuredDataPresent: { clean:
|
|
765
|
-
/** D5.2,
|
|
766
|
-
requiredProperties: { recognisedType:
|
|
767
|
-
/** D5.3,
|
|
768
|
-
textAgreement: { full:
|
|
819
|
+
/** D5.1, 2. Structured data present AND parsing; a partly-broken graph scores 1. */
|
|
820
|
+
structuredDataPresent: { clean: 2, partial: 1 },
|
|
821
|
+
/** D5.2, 3 = 1 (a recognised type) + 2 (required-property completeness, scaled). */
|
|
822
|
+
requiredProperties: { recognisedType: 1, completeness: 2 },
|
|
823
|
+
/** D5.3, 1. All-or-nothing. */
|
|
824
|
+
textAgreement: { full: 1 },
|
|
769
825
|
/** D6.1, 4 = 2 + 1 + 1. */
|
|
770
826
|
canonical: { present: 2, absolute: 1, consistentAcrossProbes: 1 },
|
|
771
|
-
/** D6.2,
|
|
772
|
-
cacheValidators: { saneCacheControl:
|
|
773
|
-
/**
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
827
|
+
/** D6.2, 2 = 1 + 1. */
|
|
828
|
+
cacheValidators: { saneCacheControl: 1, validator: 1 },
|
|
829
|
+
/**
|
|
830
|
+
* D6.3, 1. `specShaped` — an H1 and at least one Markdown link — is the whole
|
|
831
|
+
* point. `present` is 0 in 0.2: at two points 0.1 could pay one for the file
|
|
832
|
+
* existing and one for it being usable, but at one point that split would make
|
|
833
|
+
* "exists" and "usable" score identically, which is a distinction the standard
|
|
834
|
+
* would then be printing a remedy for and paying nothing to fix.
|
|
835
|
+
*/
|
|
836
|
+
llmsTxt: { present: 0, specShaped: 1 },
|
|
837
|
+
/** D6.4, 1. All-or-nothing. */
|
|
838
|
+
sitemap: { full: 1 },
|
|
839
|
+
/** D6.5, 2. All-or-nothing over any ONE declared machine endpoint. */
|
|
840
|
+
machineEndpoint: { full: 2 }
|
|
779
841
|
});
|
|
780
842
|
var SHA256_K = [
|
|
781
843
|
1116352408,
|
|
@@ -899,7 +961,7 @@ function sha256Hex(message) {
|
|
|
899
961
|
for (const word of h) hex += word.toString(16).padStart(8, "0");
|
|
900
962
|
return hex;
|
|
901
963
|
}
|
|
902
|
-
sha256Hex("ars-0.
|
|
964
|
+
sha256Hex("ars-0.2-corpus-unfrozen");
|
|
903
965
|
|
|
904
966
|
// src/probe/limiter.ts
|
|
905
967
|
var ProbeBudgetExceededError = class extends Error {
|
|
@@ -914,11 +976,7 @@ var ProbeBudgetExceededError = class extends Error {
|
|
|
914
976
|
};
|
|
915
977
|
|
|
916
978
|
// src/probe/index.ts
|
|
917
|
-
var ARS_USER_AGENT = "rebilder-ars/0.
|
|
918
|
-
var ARS_ROBOTS_TOKEN = "rebilder-ars";
|
|
919
|
-
var AGENT_ACCEPT = "text/markdown;q=1.0, text/html;q=0.8, text/plain;q=0.5, */*;q=0.1";
|
|
920
|
-
var BROWSER_ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
|
|
921
|
-
var ASSET_ACCEPT = "text/plain,*/*;q=0.5";
|
|
979
|
+
var ARS_USER_AGENT = "rebilder-ars/0.2 (+https://rebilder.com/bots)";
|
|
922
980
|
var AGENT_IDENTITY = {
|
|
923
981
|
role: "agent",
|
|
924
982
|
userAgent: ARS_USER_AGENT,
|
|
@@ -1153,25 +1211,6 @@ async function fetchWithPolicy(startUrl, headers, context) {
|
|
|
1153
1211
|
}
|
|
1154
1212
|
return failed("too-many-redirects", `More than ${policy.maxRedirects - 1} redirects.`);
|
|
1155
1213
|
}
|
|
1156
|
-
function scannerDisallows(robotsBody, path) {
|
|
1157
|
-
const robots = parseRobots(robotsBody);
|
|
1158
|
-
for (const group of robots.groups) {
|
|
1159
|
-
if (!group.agents.some((agent) => agent.toLowerCase() === ARS_ROBOTS_TOKEN)) continue;
|
|
1160
|
-
let best = null;
|
|
1161
|
-
for (const value of group.allow) {
|
|
1162
|
-
if (!pathMatches(value, path)) continue;
|
|
1163
|
-
if (best === null || value.length > best.value.length) best = { field: "allow", value };
|
|
1164
|
-
}
|
|
1165
|
-
for (const value of group.disallow) {
|
|
1166
|
-
if (!pathMatches(value, path)) continue;
|
|
1167
|
-
if (best === null || value.length > best.value.length) best = { field: "disallow", value };
|
|
1168
|
-
}
|
|
1169
|
-
if (best !== null && best.field === "disallow") {
|
|
1170
|
-
return `User-agent: ${ARS_ROBOTS_TOKEN} / Disallow: ${best.value}`;
|
|
1171
|
-
}
|
|
1172
|
-
}
|
|
1173
|
-
return null;
|
|
1174
|
-
}
|
|
1175
1214
|
function headersFor(identity) {
|
|
1176
1215
|
return { accept: identity.accept, "user-agent": identity.userAgent };
|
|
1177
1216
|
}
|
|
@@ -1262,7 +1301,7 @@ async function probeWithHostPolicy(target, policy, hostPolicy, options = {}) {
|
|
|
1262
1301
|
}
|
|
1263
1302
|
const robotsBody = robotsTxt.result.ok ? robotsTxt.result.capture.body ?? "" : "";
|
|
1264
1303
|
const robotsUsable = robotsTxt.result.ok && robotsTxt.result.capture.status < 400;
|
|
1265
|
-
const disallowedFor = (path) => vantage === "public" && robotsUsable ?
|
|
1304
|
+
const disallowedFor = (path) => vantage === "public" && robotsUsable ? robotsDisallowsScanner(robotsBody, path) : null;
|
|
1266
1305
|
const pageRule = disallowedFor(url.pathname);
|
|
1267
1306
|
if (pageRule !== null) {
|
|
1268
1307
|
const detail = `robots.txt disallows the ${ARS_ROBOTS_TOKEN} token (${pageRule})`;
|
|
@@ -1339,5 +1378,3 @@ function probeLocal(target, policy, options = {}) {
|
|
|
1339
1378
|
exports.ALLOW_PRIVATE_FLAG = ALLOW_PRIVATE_FLAG;
|
|
1340
1379
|
exports.localPolicy = localPolicy;
|
|
1341
1380
|
exports.probeLocal = probeLocal;
|
|
1342
|
-
//# sourceMappingURL=local.cjs.map
|
|
1343
|
-
//# sourceMappingURL=local.cjs.map
|
package/dist/probe/local.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Limiter, ProbePolicy, ProbeOptions, ProbeOutcome } from './index.cjs';
|
|
2
|
-
import { c as ArsRuleset } from '../
|
|
2
|
+
import { c as ArsRuleset } from '../robots-policy-DE8jix-e.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* probe/local.ts — `"./probe/local"`. Private hosts and plain http, and NOTHING
|
package/dist/probe/local.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Limiter, ProbePolicy, ProbeOptions, ProbeOutcome } from './index.js';
|
|
2
|
-
import { c as ArsRuleset } from '../
|
|
2
|
+
import { c as ArsRuleset } from '../robots-policy-DE8jix-e.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* probe/local.ts — `"./probe/local"`. Private hosts and plain http, and NOTHING
|
package/dist/probe/local.js
CHANGED
|
@@ -404,13 +404,13 @@ function deepFreeze(value) {
|
|
|
404
404
|
return Object.freeze(value);
|
|
405
405
|
}
|
|
406
406
|
var WEIGHTS = {
|
|
407
|
-
// D1 Retrievability —
|
|
408
|
-
"retrievability.reachable":
|
|
409
|
-
"retrievability.robots-policy":
|
|
410
|
-
"retrievability.render-independence":
|
|
411
|
-
// D2 Machine representation —
|
|
412
|
-
"machine-representation.negotiated-response":
|
|
413
|
-
"machine-representation.declared-alternates":
|
|
407
|
+
// D1 Retrievability — 28
|
|
408
|
+
"retrievability.reachable": 11,
|
|
409
|
+
"retrievability.robots-policy": 10,
|
|
410
|
+
"retrievability.render-independence": 7,
|
|
411
|
+
// D2 Machine representation — 18
|
|
412
|
+
"machine-representation.negotiated-response": 9,
|
|
413
|
+
"machine-representation.declared-alternates": 3,
|
|
414
414
|
"machine-representation.vary-accept": 3,
|
|
415
415
|
"machine-representation.substance-parity": 3,
|
|
416
416
|
// D3 Fact coverage — 20
|
|
@@ -419,16 +419,20 @@ var WEIGHTS = {
|
|
|
419
419
|
// D4 Fact position — 10
|
|
420
420
|
"fact-position.first-core-fact-offset": 5,
|
|
421
421
|
"fact-position.front-window": 5,
|
|
422
|
-
// D5 Structured data —
|
|
423
|
-
"structured-data.present":
|
|
424
|
-
"structured-data.required-properties":
|
|
425
|
-
"structured-data.text-agreement":
|
|
426
|
-
// D6 Contract & discovery —
|
|
422
|
+
// D5 Structured data — 6
|
|
423
|
+
"structured-data.present": 2,
|
|
424
|
+
"structured-data.required-properties": 3,
|
|
425
|
+
"structured-data.text-agreement": 1,
|
|
426
|
+
// D6 Contract & discovery — 10
|
|
427
427
|
"contract-discovery.canonical": 4,
|
|
428
|
-
"contract-discovery.cache-validators":
|
|
429
|
-
"contract-discovery.llms-txt":
|
|
430
|
-
"contract-discovery.sitemap":
|
|
431
|
-
"contract-discovery.machine-endpoint":
|
|
428
|
+
"contract-discovery.cache-validators": 2,
|
|
429
|
+
"contract-discovery.llms-txt": 1,
|
|
430
|
+
"contract-discovery.sitemap": 1,
|
|
431
|
+
"contract-discovery.machine-endpoint": 2,
|
|
432
|
+
// D7 Evidence density — 8
|
|
433
|
+
"evidence-density.quantities": 4,
|
|
434
|
+
"evidence-density.definitions": 2,
|
|
435
|
+
"evidence-density.comparisons": 2
|
|
432
436
|
};
|
|
433
437
|
var THRESHOLDS = {
|
|
434
438
|
/**
|
|
@@ -460,6 +464,31 @@ var THRESHOLDS = {
|
|
|
460
464
|
* `ratio = 100 × bytes / byteReference[pageKind]`; above the last threshold, 0.
|
|
461
465
|
*/
|
|
462
466
|
"fact-coverage.context-cost": [100, 6, 200, 5, 500, 3, 1500, 1],
|
|
467
|
+
/**
|
|
468
|
+
* D7.1 quantities, 4 pts. AT-LEAST over the count of DISTINCT quantity tokens
|
|
469
|
+
* in the agent's counted text: a currency amount, a percentage, a number
|
|
470
|
+
* carrying a unit, or an ISO date. Distinct, because a price repeated in a
|
|
471
|
+
* header, a buy box and a footer is one fact stated three times, and counting
|
|
472
|
+
* it three times would reward the repetition this score exists to discourage.
|
|
473
|
+
* Saturates at 12 so a specification table cannot outscore a page that simply
|
|
474
|
+
* states its facts.
|
|
475
|
+
*/
|
|
476
|
+
"evidence-density.quantities": [12, 4, 6, 3, 3, 2, 1, 1],
|
|
477
|
+
/**
|
|
478
|
+
* D7.2 definitions, 2 pts. AT-LEAST over the count of `term: value` pairs the
|
|
479
|
+
* agent can read as a labelled fact, counting markdown bold-label lines,
|
|
480
|
+
* list items with a leading label, and HTML definition lists.
|
|
481
|
+
*/
|
|
482
|
+
"evidence-density.definitions": [6, 2, 2, 1],
|
|
483
|
+
/**
|
|
484
|
+
* D7.3 comparisons, 2 pts. AT-LEAST over the number of comparable ROWS: a
|
|
485
|
+
* table with at least two data columns contributes its data-row count, minus
|
|
486
|
+
* the header. One row is not a comparison, so the band starts at two; three
|
|
487
|
+
* options laid side by side is a full comparison and pays out. Calibrated
|
|
488
|
+
* against fixture `060`, where a three-row size table is exactly the shape
|
|
489
|
+
* this check exists to reward, and `063`, where one row is not.
|
|
490
|
+
*/
|
|
491
|
+
"evidence-density.comparisons": [3, 2, 2, 1],
|
|
463
492
|
/** D4.1 first-core-fact byte offset, 5 pts. AT-MOST over the offset in bytes; else 0. */
|
|
464
493
|
"fact-position.first-core-fact-offset": [512, 5, 2048, 4, 8192, 2, 32768, 1],
|
|
465
494
|
/**
|
|
@@ -600,7 +629,7 @@ var BANDS = [
|
|
|
600
629
|
}
|
|
601
630
|
];
|
|
602
631
|
var DEFAULT_RULESET = deepFreeze({
|
|
603
|
-
version: "0.
|
|
632
|
+
version: "0.2.0",
|
|
604
633
|
weights: WEIGHTS,
|
|
605
634
|
thresholds: THRESHOLDS,
|
|
606
635
|
audienceTokens: AUDIENCE_TOKENS,
|
|
@@ -704,6 +733,33 @@ function pathMatches(pattern, path) {
|
|
|
704
733
|
return true;
|
|
705
734
|
}
|
|
706
735
|
|
|
736
|
+
// src/robots-policy.ts
|
|
737
|
+
var ARS_ROBOTS_TOKEN = "rebilder-ars";
|
|
738
|
+
function robotsDisallowsScanner(robotsBody, path) {
|
|
739
|
+
const robots = parseRobots(robotsBody);
|
|
740
|
+
for (const group of robots.groups) {
|
|
741
|
+
if (!group.agents.some((agent) => agent.toLowerCase() === ARS_ROBOTS_TOKEN)) continue;
|
|
742
|
+
let best = null;
|
|
743
|
+
for (const value of group.allow) {
|
|
744
|
+
if (!pathMatches(value, path)) continue;
|
|
745
|
+
if (best === null || value.length > best.value.length) best = { field: "allow", value };
|
|
746
|
+
}
|
|
747
|
+
for (const value of group.disallow) {
|
|
748
|
+
if (!pathMatches(value, path)) continue;
|
|
749
|
+
if (best === null || value.length > best.value.length) best = { field: "disallow", value };
|
|
750
|
+
}
|
|
751
|
+
if (best !== null && best.field === "disallow") {
|
|
752
|
+
return `User-agent: ${ARS_ROBOTS_TOKEN} / Disallow: ${best.value}`;
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
return null;
|
|
756
|
+
}
|
|
757
|
+
|
|
758
|
+
// src/probe/headers.ts
|
|
759
|
+
var AGENT_ACCEPT = "text/markdown;q=1.0, text/html;q=0.8, text/plain;q=0.5, */*;q=0.1";
|
|
760
|
+
var BROWSER_ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
|
|
761
|
+
var ASSET_ACCEPT = "text/plain,*/*;q=0.5";
|
|
762
|
+
|
|
707
763
|
// src/score.ts
|
|
708
764
|
function idiv(numerator, denominator) {
|
|
709
765
|
if (denominator === 0) return 0;
|
|
@@ -715,44 +771,50 @@ function deepFreeze2(value) {
|
|
|
715
771
|
return Object.freeze(value);
|
|
716
772
|
}
|
|
717
773
|
deepFreeze2({
|
|
718
|
-
/** D1.1,
|
|
719
|
-
reachable: { status2xx:
|
|
720
|
-
/** D1.2,
|
|
721
|
-
robotsPolicy: { assistantAllowed:
|
|
774
|
+
/** D1.1, 11 = 5 + 3 + 3. */
|
|
775
|
+
reachable: { status2xx: 5, withinRedirectLimit: 3, noAcceptConditionalRedirect: 3 },
|
|
776
|
+
/** D1.2, 10 = 6 + 2 + 1 + 1. A disallowed assistant audience scores 0 for all four (§3.7). */
|
|
777
|
+
robotsPolicy: { assistantAllowed: 6, parsesClean: 2, noOrphanRules: 1, sitemapDeclared: 1 },
|
|
722
778
|
/**
|
|
723
|
-
* D1.3,
|
|
779
|
+
* D1.3, 7. AT-LEAST band over `100 × coreFactsInHtml / coreProfileSize`, plus
|
|
724
780
|
* the `<noscript>` floor: a page whose facts are all client-rendered but which
|
|
725
781
|
* ships a non-empty `<noscript>` has told a JS-less caller something, and §3.8
|
|
726
782
|
* says that earns partial credit.
|
|
727
783
|
*/
|
|
728
784
|
renderIndependence: {
|
|
729
|
-
band: [100,
|
|
785
|
+
band: [100, 7, 75, 5, 50, 3, 25, 1],
|
|
730
786
|
noscriptFloor: 1
|
|
731
787
|
},
|
|
732
|
-
/** D2.1,
|
|
733
|
-
negotiatedResponse: { full:
|
|
734
|
-
/** D2.2,
|
|
735
|
-
declaredAlternates: { full:
|
|
788
|
+
/** D2.1, 9. All-or-nothing: a machine media type AND a body that is not HTML. */
|
|
789
|
+
negotiatedResponse: { full: 9 },
|
|
790
|
+
/** D2.2, 3. All-or-nothing. */
|
|
791
|
+
declaredAlternates: { full: 3 },
|
|
736
792
|
/** D2.3, 3. All-or-nothing, and 0 unless D2.1 > 0. */
|
|
737
793
|
varyAccept: { full: 3 },
|
|
738
794
|
/** D2.4, 3. All-or-nothing, and 0 unless D2.1 > 0 and a browser capture exists. */
|
|
739
795
|
substanceParity: { full: 3 },
|
|
740
|
-
/** D5.1,
|
|
741
|
-
structuredDataPresent: { clean:
|
|
742
|
-
/** D5.2,
|
|
743
|
-
requiredProperties: { recognisedType:
|
|
744
|
-
/** D5.3,
|
|
745
|
-
textAgreement: { full:
|
|
796
|
+
/** D5.1, 2. Structured data present AND parsing; a partly-broken graph scores 1. */
|
|
797
|
+
structuredDataPresent: { clean: 2, partial: 1 },
|
|
798
|
+
/** D5.2, 3 = 1 (a recognised type) + 2 (required-property completeness, scaled). */
|
|
799
|
+
requiredProperties: { recognisedType: 1, completeness: 2 },
|
|
800
|
+
/** D5.3, 1. All-or-nothing. */
|
|
801
|
+
textAgreement: { full: 1 },
|
|
746
802
|
/** D6.1, 4 = 2 + 1 + 1. */
|
|
747
803
|
canonical: { present: 2, absolute: 1, consistentAcrossProbes: 1 },
|
|
748
|
-
/** D6.2,
|
|
749
|
-
cacheValidators: { saneCacheControl:
|
|
750
|
-
/**
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
804
|
+
/** D6.2, 2 = 1 + 1. */
|
|
805
|
+
cacheValidators: { saneCacheControl: 1, validator: 1 },
|
|
806
|
+
/**
|
|
807
|
+
* D6.3, 1. `specShaped` — an H1 and at least one Markdown link — is the whole
|
|
808
|
+
* point. `present` is 0 in 0.2: at two points 0.1 could pay one for the file
|
|
809
|
+
* existing and one for it being usable, but at one point that split would make
|
|
810
|
+
* "exists" and "usable" score identically, which is a distinction the standard
|
|
811
|
+
* would then be printing a remedy for and paying nothing to fix.
|
|
812
|
+
*/
|
|
813
|
+
llmsTxt: { present: 0, specShaped: 1 },
|
|
814
|
+
/** D6.4, 1. All-or-nothing. */
|
|
815
|
+
sitemap: { full: 1 },
|
|
816
|
+
/** D6.5, 2. All-or-nothing over any ONE declared machine endpoint. */
|
|
817
|
+
machineEndpoint: { full: 2 }
|
|
756
818
|
});
|
|
757
819
|
var SHA256_K = [
|
|
758
820
|
1116352408,
|
|
@@ -876,7 +938,7 @@ function sha256Hex(message) {
|
|
|
876
938
|
for (const word of h) hex += word.toString(16).padStart(8, "0");
|
|
877
939
|
return hex;
|
|
878
940
|
}
|
|
879
|
-
sha256Hex("ars-0.
|
|
941
|
+
sha256Hex("ars-0.2-corpus-unfrozen");
|
|
880
942
|
|
|
881
943
|
// src/probe/limiter.ts
|
|
882
944
|
var ProbeBudgetExceededError = class extends Error {
|
|
@@ -891,11 +953,7 @@ var ProbeBudgetExceededError = class extends Error {
|
|
|
891
953
|
};
|
|
892
954
|
|
|
893
955
|
// src/probe/index.ts
|
|
894
|
-
var ARS_USER_AGENT = "rebilder-ars/0.
|
|
895
|
-
var ARS_ROBOTS_TOKEN = "rebilder-ars";
|
|
896
|
-
var AGENT_ACCEPT = "text/markdown;q=1.0, text/html;q=0.8, text/plain;q=0.5, */*;q=0.1";
|
|
897
|
-
var BROWSER_ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
|
|
898
|
-
var ASSET_ACCEPT = "text/plain,*/*;q=0.5";
|
|
956
|
+
var ARS_USER_AGENT = "rebilder-ars/0.2 (+https://rebilder.com/bots)";
|
|
899
957
|
var AGENT_IDENTITY = {
|
|
900
958
|
role: "agent",
|
|
901
959
|
userAgent: ARS_USER_AGENT,
|
|
@@ -1130,25 +1188,6 @@ async function fetchWithPolicy(startUrl, headers, context) {
|
|
|
1130
1188
|
}
|
|
1131
1189
|
return failed("too-many-redirects", `More than ${policy.maxRedirects - 1} redirects.`);
|
|
1132
1190
|
}
|
|
1133
|
-
function scannerDisallows(robotsBody, path) {
|
|
1134
|
-
const robots = parseRobots(robotsBody);
|
|
1135
|
-
for (const group of robots.groups) {
|
|
1136
|
-
if (!group.agents.some((agent) => agent.toLowerCase() === ARS_ROBOTS_TOKEN)) continue;
|
|
1137
|
-
let best = null;
|
|
1138
|
-
for (const value of group.allow) {
|
|
1139
|
-
if (!pathMatches(value, path)) continue;
|
|
1140
|
-
if (best === null || value.length > best.value.length) best = { field: "allow", value };
|
|
1141
|
-
}
|
|
1142
|
-
for (const value of group.disallow) {
|
|
1143
|
-
if (!pathMatches(value, path)) continue;
|
|
1144
|
-
if (best === null || value.length > best.value.length) best = { field: "disallow", value };
|
|
1145
|
-
}
|
|
1146
|
-
if (best !== null && best.field === "disallow") {
|
|
1147
|
-
return `User-agent: ${ARS_ROBOTS_TOKEN} / Disallow: ${best.value}`;
|
|
1148
|
-
}
|
|
1149
|
-
}
|
|
1150
|
-
return null;
|
|
1151
|
-
}
|
|
1152
1191
|
function headersFor(identity) {
|
|
1153
1192
|
return { accept: identity.accept, "user-agent": identity.userAgent };
|
|
1154
1193
|
}
|
|
@@ -1239,7 +1278,7 @@ async function probeWithHostPolicy(target, policy, hostPolicy, options = {}) {
|
|
|
1239
1278
|
}
|
|
1240
1279
|
const robotsBody = robotsTxt.result.ok ? robotsTxt.result.capture.body ?? "" : "";
|
|
1241
1280
|
const robotsUsable = robotsTxt.result.ok && robotsTxt.result.capture.status < 400;
|
|
1242
|
-
const disallowedFor = (path) => vantage === "public" && robotsUsable ?
|
|
1281
|
+
const disallowedFor = (path) => vantage === "public" && robotsUsable ? robotsDisallowsScanner(robotsBody, path) : null;
|
|
1243
1282
|
const pageRule = disallowedFor(url.pathname);
|
|
1244
1283
|
if (pageRule !== null) {
|
|
1245
1284
|
const detail = `robots.txt disallows the ${ARS_ROBOTS_TOKEN} token (${pageRule})`;
|