@rebilder/agent-readability 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -13
- package/dist/index.cjs +266 -53
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +209 -48
- package/dist/index.d.ts +209 -48
- package/dist/index.js +259 -54
- package/dist/index.js.map +1 -1
- package/dist/probe/index.cjs +106 -67
- package/dist/probe/index.cjs.map +1 -1
- package/dist/probe/index.d.cts +14 -9
- package/dist/probe/index.d.ts +14 -9
- package/dist/probe/index.js +106 -67
- package/dist/probe/index.js.map +1 -1
- package/dist/probe/local.cjs +106 -67
- package/dist/probe/local.cjs.map +1 -1
- package/dist/probe/local.d.cts +1 -1
- package/dist/probe/local.d.ts +1 -1
- package/dist/probe/local.js +106 -67
- package/dist/probe/local.js.map +1 -1
- package/dist/{types-B2FhQ1YC.d.cts → robots-policy-DE8jix-e.d.cts} +62 -9
- package/dist/{types-B2FhQ1YC.d.ts → robots-policy-DE8jix-e.d.ts} +62 -9
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @rebilder/agent-readability
|
|
2
2
|
|
|
3
|
-
The Agent Readability Score (**ARS 0.
|
|
3
|
+
The Agent Readability Score (**ARS 0.2**). **The default export (`.`) is a pure, deterministic function of its inputs and nothing else** — no network, no clock, no randomness, no LLM, and zero runtime dependencies. The guarantee we publish is: _for a given `evidenceHash`, `rulesetHash` and `corpusHash`, `score()` returns a byte-identical `ArsResult` in any conformant implementation, in any language._ A number without all three hashes is not an ARS score. Purity is enforced at **build time** by an ESLint `no-restricted-globals` / `no-restricted-properties` rule over `src/` (`Date`, `Math.random`, `fetch`, `performance`), not by a runtime stub that would only prove our own fixtures behave. The one impure half lives behind a separate entry point, `./probe`, which is server-only and exempt from that rule — and from nothing else.
|
|
4
4
|
|
|
5
5
|
## Contract
|
|
6
6
|
|
|
@@ -19,7 +19,7 @@ import { DEFAULT_RULESET, parseMoneyText, score } from '@rebilder/agent-readabil
|
|
|
19
19
|
const result = score(evidence, DEFAULT_RULESET)
|
|
20
20
|
result.grade // 'A' | 'B' | 'C' | 'D' | 'F' — or null, for the three non-grades
|
|
21
21
|
result.score // 0..100, or null. Integers. No decimals, ever.
|
|
22
|
-
result.dimensions // always
|
|
22
|
+
result.dimensions // always 7, weights always summing to 100
|
|
23
23
|
result.dimensions[0].checks[0].basis // 'measured' | 'heuristic', per check, always
|
|
24
24
|
result.recommendations // ranked, deduplicated: Σ pointsAvailable ≤ 100 − score
|
|
25
25
|
|
|
@@ -35,15 +35,16 @@ ARS scores **format and retrievability**: whether the facts a caller needs _for
|
|
|
35
35
|
> ARS measures format and retrievability. It does not measure whether the facts are true, or whether any assistant cites this page.
|
|
36
36
|
|
|
37
37
|
- **Fixed weights, 100 points, identical for every page kind.** No conditional weights, no redistribution, no heuristic gate over measured points. Redistribution is a gaming vector; a heuristic that can zero measured points makes those points heuristic.
|
|
38
|
-
- **What varies by page kind is the fact set and the byte reference**, never a weight. That is what stops long-form content being
|
|
39
|
-
- **
|
|
38
|
+
- **What varies by page kind is the fact set and the byte reference**, never a weight. That is what stops long-form content being charged against a budget that has nothing to do with it — the defect in every design that used absolute byte bands. It does not make long-form content cost-free: D3.1's density term has no page-kind component, and D7 (below) has none either, so a long article that states no figures pays on both.
|
|
39
|
+
- **D7 evidence density, new in 0.2, 8 points.** D1–D6 grade whether an agent can reach and parse a page. D7 grades whether there was anything on it worth quoting: distinct quantities, labelled `Term: value` pairs, and comparable table rows. Question-shaped headings earn nothing, deliberately — the absorption evidence does not support them.
|
|
40
|
+
- **Measured 63 / heuristic 37**, published, with a spec ceiling of 40 on heuristic weight. The figure is honest because the two comparison checks (D2.4 substance parity, D5.3 structured-data agreement) are _scored checks, not gates_: failing parity loses its own 3 points and raises a `warn`, and does not touch D2's other 15 measured points.
|
|
40
41
|
- **Ordinal, not cardinal.** Bands headline, integers are secondary, no decimals ever.
|
|
41
42
|
- **Three non-grades**, none of which is an F: `opt-out` (a deliberate, well-formed robots disallow — a choice, not a failure), `unscored — blocked`, and `unscored — unreachable / non-2xx / robots-unavailable / robots-disallow-scanner / truncated-evidence`.
|
|
42
43
|
- **Blocking training crawlers while allowing assistants scores identically to a fully open site.** The `training` audience is strictly neutral and can never lower a score.
|
|
43
44
|
|
|
44
45
|
**Conflict-of-interest disclosure**, printed at the top of `/spec/ars`, on every scanner result, and in the CLI `--help`:
|
|
45
46
|
|
|
46
|
-
> ARS is authored by Rebilder, which sells content-negotiation middleware.
|
|
47
|
+
> ARS is authored by Rebilder, which sells content-negotiation middleware. One ARS check — D2.1, content negotiation, worth 9 of 100 — can be satisfied by Rebilder's free gateway, and reaching an A requires it. The full ruleset, thresholds, and conformance corpus are published so this bias is auditable rather than hidden.
|
|
47
48
|
|
|
48
49
|
## Modules in this package
|
|
49
50
|
|
|
@@ -53,7 +54,7 @@ Transcribed from design §3.9. These types are the schema of `expected.json` in
|
|
|
53
54
|
|
|
54
55
|
### `src/ruleset.ts` — `DEFAULT_RULESET`
|
|
55
56
|
|
|
56
|
-
Every number a second implementation needs, and nothing that varies between runs: check weights (
|
|
57
|
+
Every number a second implementation needs, and nothing that varies between runs: check weights (22 checks summing to 100), the §3.6 scoring bands, crawler audience tokens, the D5.2 required-property table, the action lexicon, the A–F grade bands, and the three probe limits that are inputs to the score (2 MiB body cap, 3 redirects, 5 000ms timeout — two implementations with different caps produce different scores, so they are hashed with everything else).
|
|
57
58
|
|
|
58
59
|
`rulesetHash` is the SHA-256 of the RFC 8785 canonical JSON of this object. **Editing a number here is a spec version change, not a code change**: per §3.1, any edit that moves a conformance `expected.json` is at minimum a MINOR, and MINOR means scores stop being comparable and every published surface re-scores in a batch.
|
|
59
60
|
|
|
@@ -81,23 +82,23 @@ Real work, budgeted as such. `@rebilder/render-md`'s `money.ts` only _formats_ a
|
|
|
81
82
|
|
|
82
83
|
### `src/score.ts` — the scoring engine
|
|
83
84
|
|
|
84
|
-
`score(evidence, ruleset = DEFAULT_RULESET) → ArsResult`.
|
|
85
|
+
`score(evidence, ruleset = DEFAULT_RULESET) → ArsResult`. Twenty-two checks, seven dimensions, 100 points, one pure function.
|
|
85
86
|
|
|
86
87
|
**Integer arithmetic only.** Every number is produced by exact integer division (`(n − n % d) / d`, which never rounds, unlike `Math.floor(n / d)` on a double quotient) and half-up rounding via `(n + d/2) / d`. `Math.round`, `0.25 ×` and `0.5 ×` appear nowhere in the scoring path. Two implementations that disagree in the third decimal disagree about grades at the band boundary, and the boundaries are what the product publishes.
|
|
87
88
|
|
|
88
89
|
**Which representation scores what.** D3 (coverage) and D4 (position) score the **agent** representation, because ARS measures what a caller actually receives — a merchant whose Markdown omits `availability` loses coverage even though the HTML declares it. D1.3 (render independence) and D5 (structured data) score the representation that carries a **document**. Corroboration crosses the two: a price stated in the negotiated Markdown _and_ in the HTML's JSON-LD is observed in two sources, which is the only reason a correct gateway install can reach an A.
|
|
89
90
|
|
|
90
|
-
**Two gates, both pointing the safe way.** D2.3 (`Vary: Accept`) and D2.4 (substance parity) score 0 unless D2.1 earned points — a **measured** check gating others. That is what makes the published ceiling provable: no content negotiation loses
|
|
91
|
+
**Two gates, both pointing the safe way.** D2.3 (`Vary: Accept`) and D2.4 (substance parity) score 0 unless D2.1 earned points — a **measured** check gating others. That is what makes the published ceiling provable: no content negotiation loses 9 + 3 + 3 → **max 85 → capped at B**. **An A requires a machine representation, and as of 0.2 it no longer requires structured data**: D5 fell from 15 points to 6, so a page with none can still reach 94. The forbidden direction — a heuristic that can zero measured points — appears nowhere, and fixture `053` re-derives the heuristic-controlled weight (37) from the gate graph to prove it.
|
|
91
92
|
|
|
92
93
|
**Comparison is asymmetric, deliberately.** D2.4 and D5.3 ask whether the value one side would _publish_ (its lowest-offset unqualified observation, the same choice the published fact set makes) appears anywhere among the values the other side _stated_. Requiring the two headline values to be equal produces false accusations on ordinary pages — `tooling/fixtures/demo-pdp-before.html` names a backordered variant above the line that says the product is in stock, and both statements are true. Accepting any shared value lets a real divergence hide behind an incidental match, because "Free shipping over $50" appears in both representations. The asymmetric rule catches the second and not the first, which is the conservative direction: a missed divergence costs a merchant nothing, and a false one is published next to their name.
|
|
93
94
|
|
|
94
|
-
**Gate order for non-grades**, and none of them is an F: `robots-disallow-scanner` (a statement about our own conduct, and only `vantage: 'public'` is gated — an owner consents for their own origin) → `robots-unavailable` → `opt-out` (the site's decision, reported before any failure of ours) → fetch failures → `evidence-incomplete` → `truncated-evidence`. A non-grade still carries all
|
|
95
|
+
**Gate order for non-grades**, and none of them is an F: `robots-disallow-scanner` (a statement about our own conduct, and only `vantage: 'public'` is gated — an owner consents for their own origin) → `robots-unavailable` → `opt-out` (the site's decision, reported before any failure of ours) → fetch failures → `evidence-incomplete` → `truncated-evidence`. A non-grade still carries all seven dimensions with their weights, every check at `earned: 0` with an evidence line naming the reason, and the policy and cost reports — but no sub-scores, because publishing those next to `score: null` would be scoring by another name.
|
|
95
96
|
|
|
96
|
-
**Known limitations of 0.
|
|
97
|
+
**Known limitations of 0.2, stated rather than discovered:**
|
|
97
98
|
|
|
98
|
-
- **D5.2 walks JSON-LD only.** Microdata and RDFa satisfy D5.1 (present and parsing) but are not traversed for required properties, so a microdata-only page scores
|
|
99
|
+
- **D5.2 walks JSON-LD only.** Microdata and RDFa satisfy D5.1 (present and parsing) but are not traversed for required properties, so a microdata-only page scores 2/6 on D5 rather than the full 6.
|
|
99
100
|
- **A declared paywall is flagged, not exempted.** `isAccessibleForFree: false`, HTTP 402 and `WWW-Authenticate` raise the `paywalled` flag; the §3.8 exemption of the gated part from coverage and position needs `hasPart` + `cssSelector` support in the extractor and is not implemented.
|
|
100
|
-
- **`corpusHash` is not yet a corpus digest.** The pure half cannot read the corpus directory, so the value is a pinned constant regenerated at corpus freeze. ARS 0.
|
|
101
|
+
- **`corpusHash` is not yet a corpus digest.** The pure half cannot read the corpus directory, so the value is a pinned constant regenerated at corpus freeze. ARS 0.2 ships as a draft with its corpus still open, so `ARS_CORPUS_HASH` is the SHA-256 of the ASCII string `ars-0.2-corpus-unfrozen` — anyone comparing it against a computed digest of the shipped corpus will find it does not match, which is the correct signal.
|
|
101
102
|
- **`SUBPOINTS` and the classification tables are not covered by `rulesetHash`.** §3.9's `ArsRuleset` has no field for either. They are published (exported, and printed in the spec) and the corpus is what pins them.
|
|
102
103
|
- **SHA-256 is implemented in this file.** `node:crypto` would make the package Node-only and `apps/rebilder-web` imports the root entry point; `crypto.subtle` is async and `score()` is not; a dependency is out by contract. It is checked against the FIPS 180-4 vectors in `tests/score.test.ts`.
|
|
103
104
|
|
|
@@ -163,7 +164,7 @@ writes `expected.json` and `identity.json` from the current implementation **and
|
|
|
163
164
|
|
|
164
165
|
### The golden pair
|
|
165
166
|
|
|
166
|
-
`001-pdp-gateway-md` and `002-pdp-raw-html` carry the **same 91,226-byte HTML body** — the real committed page at `tooling/fixtures/demo-pdp-before.html` — and differ only in what the agent probe receives and in the response headers, which is exactly the one variable §3.3 allows. The same page scores **
|
|
167
|
+
`001-pdp-gateway-md` and `002-pdp-raw-html` carry the **same 91,226-byte HTML body** — the real committed page at `tooling/fixtures/demo-pdp-before.html` — and differ only in what the agent probe receives and in the response headers, which is exactly the one variable §3.3 allows. The same page scores **59 (D)** raw and **93 (A)** with the gateway installed. Four of the seven points 001 still lacks are gaps in `@rebilder/gateway` itself: it declares no `Link: rel="alternate"` (D2.2, 3 points) and no canonical on the Markdown response (D6.1, 1 point). The corpus is where that is visible, and closing it will move `expected.json` — which is a MINOR, and correctly so.
|
|
167
168
|
|
|
168
169
|
### Property fixtures 050–059
|
|
169
170
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
// src/types.ts
|
|
4
|
-
var ARS_SPEC_VERSION = "0.
|
|
4
|
+
var ARS_SPEC_VERSION = "0.2.0";
|
|
5
5
|
|
|
6
6
|
// src/profiles.ts
|
|
7
7
|
var PROFILE_BY_KIND = {
|
|
@@ -66,13 +66,13 @@ function deepFreeze(value) {
|
|
|
66
66
|
return Object.freeze(value);
|
|
67
67
|
}
|
|
68
68
|
var WEIGHTS = {
|
|
69
|
-
// D1 Retrievability —
|
|
70
|
-
"retrievability.reachable":
|
|
71
|
-
"retrievability.robots-policy":
|
|
72
|
-
"retrievability.render-independence":
|
|
73
|
-
// D2 Machine representation —
|
|
74
|
-
"machine-representation.negotiated-response":
|
|
75
|
-
"machine-representation.declared-alternates":
|
|
69
|
+
// D1 Retrievability — 28
|
|
70
|
+
"retrievability.reachable": 11,
|
|
71
|
+
"retrievability.robots-policy": 10,
|
|
72
|
+
"retrievability.render-independence": 7,
|
|
73
|
+
// D2 Machine representation — 18
|
|
74
|
+
"machine-representation.negotiated-response": 9,
|
|
75
|
+
"machine-representation.declared-alternates": 3,
|
|
76
76
|
"machine-representation.vary-accept": 3,
|
|
77
77
|
"machine-representation.substance-parity": 3,
|
|
78
78
|
// D3 Fact coverage — 20
|
|
@@ -81,16 +81,20 @@ var WEIGHTS = {
|
|
|
81
81
|
// D4 Fact position — 10
|
|
82
82
|
"fact-position.first-core-fact-offset": 5,
|
|
83
83
|
"fact-position.front-window": 5,
|
|
84
|
-
// D5 Structured data —
|
|
85
|
-
"structured-data.present":
|
|
86
|
-
"structured-data.required-properties":
|
|
87
|
-
"structured-data.text-agreement":
|
|
88
|
-
// D6 Contract & discovery —
|
|
84
|
+
// D5 Structured data — 6
|
|
85
|
+
"structured-data.present": 2,
|
|
86
|
+
"structured-data.required-properties": 3,
|
|
87
|
+
"structured-data.text-agreement": 1,
|
|
88
|
+
// D6 Contract & discovery — 10
|
|
89
89
|
"contract-discovery.canonical": 4,
|
|
90
|
-
"contract-discovery.cache-validators":
|
|
91
|
-
"contract-discovery.llms-txt":
|
|
92
|
-
"contract-discovery.sitemap":
|
|
93
|
-
"contract-discovery.machine-endpoint":
|
|
90
|
+
"contract-discovery.cache-validators": 2,
|
|
91
|
+
"contract-discovery.llms-txt": 1,
|
|
92
|
+
"contract-discovery.sitemap": 1,
|
|
93
|
+
"contract-discovery.machine-endpoint": 2,
|
|
94
|
+
// D7 Evidence density — 8
|
|
95
|
+
"evidence-density.quantities": 4,
|
|
96
|
+
"evidence-density.definitions": 2,
|
|
97
|
+
"evidence-density.comparisons": 2
|
|
94
98
|
};
|
|
95
99
|
var CHECK_META = {
|
|
96
100
|
"retrievability.reachable": {
|
|
@@ -187,18 +191,34 @@ var CHECK_META = {
|
|
|
187
191
|
dimension: "contract-discovery",
|
|
188
192
|
label: "Declared machine endpoint",
|
|
189
193
|
basis: "measured"
|
|
194
|
+
},
|
|
195
|
+
"evidence-density.quantities": {
|
|
196
|
+
dimension: "evidence-density",
|
|
197
|
+
label: "Quantities an answer can quote",
|
|
198
|
+
basis: "measured"
|
|
199
|
+
},
|
|
200
|
+
"evidence-density.definitions": {
|
|
201
|
+
dimension: "evidence-density",
|
|
202
|
+
label: "Labelled term and value pairs",
|
|
203
|
+
basis: "heuristic"
|
|
204
|
+
},
|
|
205
|
+
"evidence-density.comparisons": {
|
|
206
|
+
dimension: "evidence-density",
|
|
207
|
+
label: "Comparable rows",
|
|
208
|
+
basis: "measured"
|
|
190
209
|
}
|
|
191
210
|
};
|
|
192
211
|
var DIMENSION_META = {
|
|
193
|
-
retrievability: { label: "Retrievability", weight:
|
|
194
|
-
"machine-representation": { label: "Machine representation", weight:
|
|
212
|
+
retrievability: { label: "Retrievability", weight: 28 },
|
|
213
|
+
"machine-representation": { label: "Machine representation", weight: 18 },
|
|
195
214
|
"fact-coverage": { label: "Fact coverage", weight: 20 },
|
|
196
215
|
"fact-position": { label: "Fact position", weight: 10 },
|
|
197
|
-
"structured-data": { label: "Structured data", weight:
|
|
198
|
-
"contract-discovery": { label: "Contract & discovery", weight:
|
|
216
|
+
"structured-data": { label: "Structured data", weight: 6 },
|
|
217
|
+
"contract-discovery": { label: "Contract & discovery", weight: 10 },
|
|
218
|
+
"evidence-density": { label: "Evidence density", weight: 8 }
|
|
199
219
|
};
|
|
200
|
-
var ARS_MEASURED_WEIGHT =
|
|
201
|
-
var ARS_HEURISTIC_WEIGHT =
|
|
220
|
+
var ARS_MEASURED_WEIGHT = 63;
|
|
221
|
+
var ARS_HEURISTIC_WEIGHT = 37;
|
|
202
222
|
var ARS_HEURISTIC_WEIGHT_CEILING = 40;
|
|
203
223
|
var THRESHOLDS = {
|
|
204
224
|
/**
|
|
@@ -230,6 +250,31 @@ var THRESHOLDS = {
|
|
|
230
250
|
* `ratio = 100 × bytes / byteReference[pageKind]`; above the last threshold, 0.
|
|
231
251
|
*/
|
|
232
252
|
"fact-coverage.context-cost": [100, 6, 200, 5, 500, 3, 1500, 1],
|
|
253
|
+
/**
|
|
254
|
+
* D7.1 quantities, 4 pts. AT-LEAST over the count of DISTINCT quantity tokens
|
|
255
|
+
* in the agent's counted text: a currency amount, a percentage, a number
|
|
256
|
+
* carrying a unit, or an ISO date. Distinct, because a price repeated in a
|
|
257
|
+
* header, a buy box and a footer is one fact stated three times, and counting
|
|
258
|
+
* it three times would reward the repetition this score exists to discourage.
|
|
259
|
+
* Saturates at 12 so a specification table cannot outscore a page that simply
|
|
260
|
+
* states its facts.
|
|
261
|
+
*/
|
|
262
|
+
"evidence-density.quantities": [12, 4, 6, 3, 3, 2, 1, 1],
|
|
263
|
+
/**
|
|
264
|
+
* D7.2 definitions, 2 pts. AT-LEAST over the count of `term: value` pairs the
|
|
265
|
+
* agent can read as a labelled fact, counting markdown bold-label lines,
|
|
266
|
+
* list items with a leading label, and HTML definition lists.
|
|
267
|
+
*/
|
|
268
|
+
"evidence-density.definitions": [6, 2, 2, 1],
|
|
269
|
+
/**
|
|
270
|
+
* D7.3 comparisons, 2 pts. AT-LEAST over the number of comparable ROWS: a
|
|
271
|
+
* table with at least two data columns contributes its data-row count, minus
|
|
272
|
+
* the header. One row is not a comparison, so the band starts at two; three
|
|
273
|
+
* options laid side by side is a full comparison and pays out. Calibrated
|
|
274
|
+
* against fixture `060`, where a three-row size table is exactly the shape
|
|
275
|
+
* this check exists to reward, and `063`, where one row is not.
|
|
276
|
+
*/
|
|
277
|
+
"evidence-density.comparisons": [3, 2, 2, 1],
|
|
233
278
|
/** D4.1 first-core-fact byte offset, 5 pts. AT-MOST over the offset in bytes; else 0. */
|
|
234
279
|
"fact-position.first-core-fact-offset": [512, 5, 2048, 4, 8192, 2, 32768, 1],
|
|
235
280
|
/**
|
|
@@ -370,7 +415,7 @@ var BANDS = [
|
|
|
370
415
|
}
|
|
371
416
|
];
|
|
372
417
|
var DEFAULT_RULESET = deepFreeze({
|
|
373
|
-
version: "0.
|
|
418
|
+
version: "0.2.0",
|
|
374
419
|
weights: WEIGHTS,
|
|
375
420
|
thresholds: THRESHOLDS,
|
|
376
421
|
audienceTokens: AUDIENCE_TOKENS,
|
|
@@ -2836,7 +2881,7 @@ var TEMPLATES = [
|
|
|
2836
2881
|
id: "publish-llms-txt",
|
|
2837
2882
|
title: "Publish /llms.txt",
|
|
2838
2883
|
effort: "config",
|
|
2839
|
-
detail: "An H1 title, a short summary, and links to the pages that matter. It is worth
|
|
2884
|
+
detail: "An H1 title, a short summary, and links to the pages that matter. It is worth 1 point of 100, deliberately: content negotiation is the mechanism that measurably improves retrieval, and we have observed no citation lift from llms.txt alone.",
|
|
2840
2885
|
checks: ["contract-discovery.llms-txt"],
|
|
2841
2886
|
unlocks: NO_UNLOCKS
|
|
2842
2887
|
},
|
|
@@ -2855,6 +2900,30 @@ var TEMPLATES = [
|
|
|
2855
2900
|
detail: "A feed, an OpenAPI document, /.well-known/ucp \u2014 anything an agent can call \u2014 declared with a `Link` header or a `<link>`. ARS probes /robots.txt, /llms.txt and /.well-known/ucp and guesses at no other path.",
|
|
2856
2901
|
checks: ["contract-discovery.machine-endpoint"],
|
|
2857
2902
|
unlocks: NO_UNLOCKS
|
|
2903
|
+
},
|
|
2904
|
+
{
|
|
2905
|
+
id: "state-quantities",
|
|
2906
|
+
title: "State the numbers in text",
|
|
2907
|
+
effort: "template",
|
|
2908
|
+
detail: "Price, sizes, weights, hours, fees, lead times, dates \u2014 written out where an agent reads them, not left in an image or implied by a paragraph. An assistant builds a cited answer out of quantities it can lift; distinct ones count, so saying the same price three times is one number.",
|
|
2909
|
+
checks: ["evidence-density.quantities"],
|
|
2910
|
+
unlocks: NO_UNLOCKS
|
|
2911
|
+
},
|
|
2912
|
+
{
|
|
2913
|
+
id: "label-facts",
|
|
2914
|
+
title: "Label each fact with its term",
|
|
2915
|
+
effort: "template",
|
|
2916
|
+
detail: 'A line that reads "Returns: 60 days" travels whole into an answer. The same fact inside a sentence has to be inferred, and an assistant that has to infer it usually leaves it out. Specification lists, definition lists and labelled bullets all count.',
|
|
2917
|
+
checks: ["evidence-density.definitions"],
|
|
2918
|
+
unlocks: NO_UNLOCKS
|
|
2919
|
+
},
|
|
2920
|
+
{
|
|
2921
|
+
id: "add-comparison-rows",
|
|
2922
|
+
title: "Put the options side by side",
|
|
2923
|
+
effort: "template",
|
|
2924
|
+
detail: "Sizes, tiers, models, plans \u2014 one row each, in a table with at least two columns. One row states a fact; two or more let an assistant contrast them, which is the question people actually ask it.",
|
|
2925
|
+
checks: ["evidence-density.comparisons"],
|
|
2926
|
+
unlocks: NO_UNLOCKS
|
|
2858
2927
|
}
|
|
2859
2928
|
];
|
|
2860
2929
|
var EFFORT_ORDER = ["config", "template", "engineering"];
|
|
@@ -2958,44 +3027,50 @@ function deepFreeze2(value) {
|
|
|
2958
3027
|
return Object.freeze(value);
|
|
2959
3028
|
}
|
|
2960
3029
|
var SUBPOINTS = deepFreeze2({
|
|
2961
|
-
/** D1.1,
|
|
2962
|
-
reachable: { status2xx:
|
|
2963
|
-
/** D1.2,
|
|
2964
|
-
robotsPolicy: { assistantAllowed:
|
|
3030
|
+
/** D1.1, 11 = 5 + 3 + 3. */
|
|
3031
|
+
reachable: { status2xx: 5, withinRedirectLimit: 3, noAcceptConditionalRedirect: 3 },
|
|
3032
|
+
/** D1.2, 10 = 6 + 2 + 1 + 1. A disallowed assistant audience scores 0 for all four (§3.7). */
|
|
3033
|
+
robotsPolicy: { assistantAllowed: 6, parsesClean: 2, noOrphanRules: 1, sitemapDeclared: 1 },
|
|
2965
3034
|
/**
|
|
2966
|
-
* D1.3,
|
|
3035
|
+
* D1.3, 7. AT-LEAST band over `100 × coreFactsInHtml / coreProfileSize`, plus
|
|
2967
3036
|
* the `<noscript>` floor: a page whose facts are all client-rendered but which
|
|
2968
3037
|
* ships a non-empty `<noscript>` has told a JS-less caller something, and §3.8
|
|
2969
3038
|
* says that earns partial credit.
|
|
2970
3039
|
*/
|
|
2971
3040
|
renderIndependence: {
|
|
2972
|
-
band: [100,
|
|
3041
|
+
band: [100, 7, 75, 5, 50, 3, 25, 1],
|
|
2973
3042
|
noscriptFloor: 1
|
|
2974
3043
|
},
|
|
2975
|
-
/** D2.1,
|
|
2976
|
-
negotiatedResponse: { full:
|
|
2977
|
-
/** D2.2,
|
|
2978
|
-
declaredAlternates: { full:
|
|
3044
|
+
/** D2.1, 9. All-or-nothing: a machine media type AND a body that is not HTML. */
|
|
3045
|
+
negotiatedResponse: { full: 9 },
|
|
3046
|
+
/** D2.2, 3. All-or-nothing. */
|
|
3047
|
+
declaredAlternates: { full: 3 },
|
|
2979
3048
|
/** D2.3, 3. All-or-nothing, and 0 unless D2.1 > 0. */
|
|
2980
3049
|
varyAccept: { full: 3 },
|
|
2981
3050
|
/** D2.4, 3. All-or-nothing, and 0 unless D2.1 > 0 and a browser capture exists. */
|
|
2982
3051
|
substanceParity: { full: 3 },
|
|
2983
|
-
/** D5.1,
|
|
2984
|
-
structuredDataPresent: { clean:
|
|
2985
|
-
/** D5.2,
|
|
2986
|
-
requiredProperties: { recognisedType:
|
|
2987
|
-
/** D5.3,
|
|
2988
|
-
textAgreement: { full:
|
|
3052
|
+
/** D5.1, 2. Structured data present AND parsing; a partly-broken graph scores 1. */
|
|
3053
|
+
structuredDataPresent: { clean: 2, partial: 1 },
|
|
3054
|
+
/** D5.2, 3 = 1 (a recognised type) + 2 (required-property completeness, scaled). */
|
|
3055
|
+
requiredProperties: { recognisedType: 1, completeness: 2 },
|
|
3056
|
+
/** D5.3, 1. All-or-nothing. */
|
|
3057
|
+
textAgreement: { full: 1 },
|
|
2989
3058
|
/** D6.1, 4 = 2 + 1 + 1. */
|
|
2990
3059
|
canonical: { present: 2, absolute: 1, consistentAcrossProbes: 1 },
|
|
2991
|
-
/** D6.2,
|
|
2992
|
-
cacheValidators: { saneCacheControl:
|
|
2993
|
-
/**
|
|
2994
|
-
|
|
2995
|
-
|
|
2996
|
-
|
|
2997
|
-
|
|
2998
|
-
|
|
3060
|
+
/** D6.2, 2 = 1 + 1. */
|
|
3061
|
+
cacheValidators: { saneCacheControl: 1, validator: 1 },
|
|
3062
|
+
/**
|
|
3063
|
+
* D6.3, 1. `specShaped` — an H1 and at least one Markdown link — is the whole
|
|
3064
|
+
* point. `present` is 0 in 0.2: at two points 0.1 could pay one for the file
|
|
3065
|
+
* existing and one for it being usable, but at one point that split would make
|
|
3066
|
+
* "exists" and "usable" score identically, which is a distinction the standard
|
|
3067
|
+
* would then be printing a remedy for and paying nothing to fix.
|
|
3068
|
+
*/
|
|
3069
|
+
llmsTxt: { present: 0, specShaped: 1 },
|
|
3070
|
+
/** D6.4, 1. All-or-nothing. */
|
|
3071
|
+
sitemap: { full: 1 },
|
|
3072
|
+
/** D6.5, 2. All-or-nothing over any ONE declared machine endpoint. */
|
|
3073
|
+
machineEndpoint: { full: 2 }
|
|
2999
3074
|
});
|
|
3000
3075
|
var SHA256_K = [
|
|
3001
3076
|
1116352408,
|
|
@@ -3181,7 +3256,7 @@ function evidenceHash(evidence) {
|
|
|
3181
3256
|
})
|
|
3182
3257
|
);
|
|
3183
3258
|
}
|
|
3184
|
-
var ARS_CORPUS_HASH = sha256Hex("ars-0.
|
|
3259
|
+
var ARS_CORPUS_HASH = sha256Hex("ars-0.2-corpus-unfrozen");
|
|
3185
3260
|
function parseLinkHeaders(values) {
|
|
3186
3261
|
const out = [];
|
|
3187
3262
|
for (const value of values) {
|
|
@@ -3648,6 +3723,105 @@ function checkContextCost(context) {
|
|
|
3648
3723
|
remedy: earned === full ? void 0 : "Serve a representation sized to the facts. The reference is what a page of this kind reasonably costs, not an absolute budget."
|
|
3649
3724
|
};
|
|
3650
3725
|
}
|
|
3726
|
+
var QUANTITY = new RegExp(
|
|
3727
|
+
[
|
|
3728
|
+
String.raw`[$£€¥]\s?\d[\d,]*(?:\.\d+)?`,
|
|
3729
|
+
String.raw`\d[\d,]*(?:\.\d+)?\s?%`,
|
|
3730
|
+
String.raw`\d[\d,]*(?:\.\d+)?\s?(?:kg|g|lb|lbs|oz|mm|cm|m|km|mi|in|ft|ml|l|kb|mb|gb|tb|hz|w|kw|v|°c|°f|hours?|hrs?|minutes?|mins?|seconds?|secs?|days?|weeks?|months?|years?)\b`,
|
|
3731
|
+
String.raw`\d{4}-\d{2}-\d{2}`
|
|
3732
|
+
].join("|"),
|
|
3733
|
+
"giu"
|
|
3734
|
+
);
|
|
3735
|
+
var DEFINITION_LINE = /^\s*(?:[-*+]\s+)?(?:\*\*)?[A-Za-z][A-Za-z0-9 /&'()-]{1,40}(?:\*\*)?\s*:\s*\S/;
|
|
3736
|
+
var LABELLED_BLOCK_TAGS = /* @__PURE__ */ new Set(["li", "dt", "dd", "p", "td", "th", "div"]);
|
|
3737
|
+
function checkQuantities(context) {
|
|
3738
|
+
const table = context.ruleset.thresholds["evidence-density.quantities"];
|
|
3739
|
+
const seen = /* @__PURE__ */ new Set();
|
|
3740
|
+
for (const match of context.agent.text.matchAll(QUANTITY)) {
|
|
3741
|
+
seen.add(match[0].toLowerCase().replace(/\s+/g, ""));
|
|
3742
|
+
}
|
|
3743
|
+
const count = seen.size;
|
|
3744
|
+
const earned = atLeast(table, count);
|
|
3745
|
+
const full = atLeast(table, Number.MAX_SAFE_INTEGER);
|
|
3746
|
+
return {
|
|
3747
|
+
earned,
|
|
3748
|
+
evidence: [measured("Distinct quantities an answer could quote", `${count}`)],
|
|
3749
|
+
remedy: earned === full ? void 0 : "State the numbers a reader would ask for, in text: price, sizes, hours, fees, dates. A quantity an agent can lift is what a cited answer is built from."
|
|
3750
|
+
};
|
|
3751
|
+
}
|
|
3752
|
+
function labelledSegments(context) {
|
|
3753
|
+
const doc = context.agent.doc;
|
|
3754
|
+
if (doc === null) return context.agent.text.split("\n");
|
|
3755
|
+
const byElement = /* @__PURE__ */ new Map();
|
|
3756
|
+
for (const node of doc.texts) {
|
|
3757
|
+
if (node.excludedBy !== null) continue;
|
|
3758
|
+
if (node.text.trim().length === 0) continue;
|
|
3759
|
+
let at = node.parent;
|
|
3760
|
+
for (let hops = 0; at >= 0 && hops <= MAX_ANCESTOR_HOPS; hops += 1) {
|
|
3761
|
+
const element = doc.elements[at];
|
|
3762
|
+
if (element === void 0) break;
|
|
3763
|
+
if (LABELLED_BLOCK_TAGS.has(element.tag)) {
|
|
3764
|
+
const parts = byElement.get(at);
|
|
3765
|
+
if (parts === void 0) byElement.set(at, [node.text]);
|
|
3766
|
+
else parts.push(node.text);
|
|
3767
|
+
break;
|
|
3768
|
+
}
|
|
3769
|
+
at = element.parent;
|
|
3770
|
+
}
|
|
3771
|
+
}
|
|
3772
|
+
const segments = [];
|
|
3773
|
+
for (const parts of byElement.values()) {
|
|
3774
|
+
segments.push(parts.join(" ").replace(/\s+/g, " ").trim());
|
|
3775
|
+
}
|
|
3776
|
+
return segments;
|
|
3777
|
+
}
|
|
3778
|
+
var MAX_ANCESTOR_HOPS = 256;
|
|
3779
|
+
function checkDefinitions(context) {
|
|
3780
|
+
const table = context.ruleset.thresholds["evidence-density.definitions"];
|
|
3781
|
+
let count = 0;
|
|
3782
|
+
for (const line of labelledSegments(context)) {
|
|
3783
|
+
if (DEFINITION_LINE.test(line)) count += 1;
|
|
3784
|
+
}
|
|
3785
|
+
const earned = atLeast(table, count);
|
|
3786
|
+
const full = atLeast(table, Number.MAX_SAFE_INTEGER);
|
|
3787
|
+
return {
|
|
3788
|
+
earned,
|
|
3789
|
+
evidence: [heuristic("Labelled term and value pairs", `${count}`)],
|
|
3790
|
+
remedy: earned === full ? void 0 : 'Label your facts. A line that reads "Returns: 60 days" is liftable whole; the same fact inside a paragraph has to be inferred.'
|
|
3791
|
+
};
|
|
3792
|
+
}
|
|
3793
|
+
function checkComparisons(context) {
|
|
3794
|
+
const table = context.ruleset.thresholds["evidence-density.comparisons"];
|
|
3795
|
+
let rows = 0;
|
|
3796
|
+
const doc = context.agent.doc;
|
|
3797
|
+
if (doc !== null) {
|
|
3798
|
+
const cellsByRow = /* @__PURE__ */ new Map();
|
|
3799
|
+
for (const element of doc.elements) {
|
|
3800
|
+
if (element.tag !== "td" && element.tag !== "th") continue;
|
|
3801
|
+
const row = doc.elements[element.parent];
|
|
3802
|
+
if (row === void 0 || row.tag !== "tr") continue;
|
|
3803
|
+
cellsByRow.set(element.parent, (cellsByRow.get(element.parent) ?? 0) + 1);
|
|
3804
|
+
}
|
|
3805
|
+
for (const cells of cellsByRow.values()) if (cells >= 2) rows += 1;
|
|
3806
|
+
rows = Math.max(0, rows - 1);
|
|
3807
|
+
} else {
|
|
3808
|
+
let pipeRows = 0;
|
|
3809
|
+
for (const line of context.agent.text.split("\n")) {
|
|
3810
|
+
const trimmed = line.trim();
|
|
3811
|
+
if (!trimmed.startsWith("|") || !trimmed.endsWith("|")) continue;
|
|
3812
|
+
if (/^\|[\s:|-]+\|$/.test(trimmed)) continue;
|
|
3813
|
+
if (trimmed.split("|").length - 2 >= 2) pipeRows += 1;
|
|
3814
|
+
}
|
|
3815
|
+
rows = Math.max(0, pipeRows - 1);
|
|
3816
|
+
}
|
|
3817
|
+
const earned = atLeast(table, rows);
|
|
3818
|
+
const full = atLeast(table, Number.MAX_SAFE_INTEGER);
|
|
3819
|
+
return {
|
|
3820
|
+
earned,
|
|
3821
|
+
evidence: [measured("Comparable rows", `${rows}`)],
|
|
3822
|
+
remedy: earned === full ? void 0 : "Put options side by side in a table with a row each. An assistant comparing two things reaches for rows it can line up."
|
|
3823
|
+
};
|
|
3824
|
+
}
|
|
3651
3825
|
function coreOffsets(context) {
|
|
3652
3826
|
const offsets = [];
|
|
3653
3827
|
for (const fact of context.facts)
|
|
@@ -3893,7 +4067,7 @@ function checkLlmsTxt(context) {
|
|
|
3893
4067
|
return {
|
|
3894
4068
|
earned: 0,
|
|
3895
4069
|
evidence: [measured("/llms.txt", body === null ? "absent or non-2xx" : "empty")],
|
|
3896
|
-
remedy: "Publish /llms.txt: an H1 title, a short summary, and links to the pages that matter. It is worth
|
|
4070
|
+
remedy: "Publish /llms.txt: an H1 title, a short summary, and links to the pages that matter. It is worth 1 point of 100, deliberately."
|
|
3897
4071
|
};
|
|
3898
4072
|
}
|
|
3899
4073
|
const hasTitle = /^#\s+\S/m.test(body);
|
|
@@ -4023,7 +4197,8 @@ var DIMENSION_ORDER = [
|
|
|
4023
4197
|
"fact-coverage",
|
|
4024
4198
|
"fact-position",
|
|
4025
4199
|
"structured-data",
|
|
4026
|
-
"contract-discovery"
|
|
4200
|
+
"contract-discovery",
|
|
4201
|
+
"evidence-density"
|
|
4027
4202
|
];
|
|
4028
4203
|
function buildDimensions(checks) {
|
|
4029
4204
|
return DIMENSION_ORDER.map((id) => {
|
|
@@ -4439,7 +4614,10 @@ function score(evidence, ruleset = DEFAULT_RULESET) {
|
|
|
4439
4614
|
buildCheck(ruleset, "contract-discovery.cache-validators", checkCacheValidators(context)),
|
|
4440
4615
|
buildCheck(ruleset, "contract-discovery.llms-txt", checkLlmsTxt(context)),
|
|
4441
4616
|
buildCheck(ruleset, "contract-discovery.sitemap", checkSitemap(context)),
|
|
4442
|
-
buildCheck(ruleset, "contract-discovery.machine-endpoint", checkMachineEndpoint(context))
|
|
4617
|
+
buildCheck(ruleset, "contract-discovery.machine-endpoint", checkMachineEndpoint(context)),
|
|
4618
|
+
buildCheck(ruleset, "evidence-density.quantities", checkQuantities(context)),
|
|
4619
|
+
buildCheck(ruleset, "evidence-density.definitions", checkDefinitions(context)),
|
|
4620
|
+
buildCheck(ruleset, "evidence-density.comparisons", checkComparisons(context))
|
|
4443
4621
|
];
|
|
4444
4622
|
const dimensions = buildDimensions(checks);
|
|
4445
4623
|
const total = dimensions.reduce((sum, dimension) => sum + dimension.earned, 0);
|
|
@@ -4518,11 +4696,42 @@ function decideScannerToken(robots, path) {
|
|
|
4518
4696
|
return null;
|
|
4519
4697
|
}
|
|
4520
4698
|
|
|
4699
|
+
// src/probe/headers.ts
|
|
4700
|
+
var AGENT_ACCEPT = "text/markdown;q=1.0, text/html;q=0.8, text/plain;q=0.5, */*;q=0.1";
|
|
4701
|
+
var BROWSER_ACCEPT = "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8";
|
|
4702
|
+
var ASSET_ACCEPT = "text/plain,*/*;q=0.5";
|
|
4703
|
+
|
|
4704
|
+
// src/robots-policy.ts
|
|
4705
|
+
var ARS_ROBOTS_TOKEN = "rebilder-ars";
|
|
4706
|
+
function robotsDisallowsScanner(robotsBody, path) {
|
|
4707
|
+
const robots = parseRobots(robotsBody);
|
|
4708
|
+
for (const group of robots.groups) {
|
|
4709
|
+
if (!group.agents.some((agent) => agent.toLowerCase() === ARS_ROBOTS_TOKEN)) continue;
|
|
4710
|
+
let best = null;
|
|
4711
|
+
for (const value of group.allow) {
|
|
4712
|
+
if (!pathMatches(value, path)) continue;
|
|
4713
|
+
if (best === null || value.length > best.value.length) best = { field: "allow", value };
|
|
4714
|
+
}
|
|
4715
|
+
for (const value of group.disallow) {
|
|
4716
|
+
if (!pathMatches(value, path)) continue;
|
|
4717
|
+
if (best === null || value.length > best.value.length) best = { field: "disallow", value };
|
|
4718
|
+
}
|
|
4719
|
+
if (best !== null && best.field === "disallow") {
|
|
4720
|
+
return `User-agent: ${ARS_ROBOTS_TOKEN} / Disallow: ${best.value}`;
|
|
4721
|
+
}
|
|
4722
|
+
}
|
|
4723
|
+
return null;
|
|
4724
|
+
}
|
|
4725
|
+
|
|
4726
|
+
exports.AGENT_ACCEPT = AGENT_ACCEPT;
|
|
4521
4727
|
exports.ARS_CORPUS_HASH = ARS_CORPUS_HASH;
|
|
4522
4728
|
exports.ARS_HEURISTIC_WEIGHT = ARS_HEURISTIC_WEIGHT;
|
|
4523
4729
|
exports.ARS_HEURISTIC_WEIGHT_CEILING = ARS_HEURISTIC_WEIGHT_CEILING;
|
|
4524
4730
|
exports.ARS_MEASURED_WEIGHT = ARS_MEASURED_WEIGHT;
|
|
4731
|
+
exports.ARS_ROBOTS_TOKEN = ARS_ROBOTS_TOKEN;
|
|
4525
4732
|
exports.ARS_SPEC_VERSION = ARS_SPEC_VERSION;
|
|
4733
|
+
exports.ASSET_ACCEPT = ASSET_ACCEPT;
|
|
4734
|
+
exports.BROWSER_ACCEPT = BROWSER_ACCEPT;
|
|
4526
4735
|
exports.CHECK_META = CHECK_META;
|
|
4527
4736
|
exports.DEFAULT_RULESET = DEFAULT_RULESET;
|
|
4528
4737
|
exports.DIMENSION_META = DIMENSION_META;
|
|
@@ -4534,10 +4743,14 @@ exports.classify = classify;
|
|
|
4534
4743
|
exports.evidenceHash = evidenceHash;
|
|
4535
4744
|
exports.minorUnitDigits = minorUnitDigits;
|
|
4536
4745
|
exports.parseMoneyText = parseMoneyText;
|
|
4746
|
+
exports.parseRobots = parseRobots;
|
|
4747
|
+
exports.pathMatches = pathMatches;
|
|
4537
4748
|
exports.profileFor = profileFor;
|
|
4538
4749
|
exports.recommend = recommend;
|
|
4750
|
+
exports.robotsDisallowsScanner = robotsDisallowsScanner;
|
|
4539
4751
|
exports.rulesetHash = rulesetHash;
|
|
4540
4752
|
exports.score = score;
|
|
4541
4753
|
exports.sha256Hex = sha256Hex;
|
|
4754
|
+
exports.utf8Length = utf8Length;
|
|
4542
4755
|
//# sourceMappingURL=index.cjs.map
|
|
4543
4756
|
//# sourceMappingURL=index.cjs.map
|