mcp-web-validator 1.3.51 → 1.3.53
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 +41 -0
- package/README.md +64 -4
- package/dist/audit-history.d.ts +9 -0
- package/dist/audit-history.js +27 -0
- package/dist/audit-history.js.map +1 -1
- package/dist/index.js +2508 -2
- package/dist/index.js.map +1 -1
- package/dist/modules/browser-ux/lighthouse-lab-probe.d.ts +21 -0
- package/dist/modules/browser-ux/lighthouse-lab-probe.js +190 -0
- package/dist/modules/browser-ux/lighthouse-lab-probe.js.map +1 -0
- package/dist/modules/browser-ux/lighthouse-lab.d.ts +61 -0
- package/dist/modules/browser-ux/lighthouse-lab.js +98 -0
- package/dist/modules/browser-ux/lighthouse-lab.js.map +1 -0
- package/dist/modules/browser-ux/media-diagnostics.d.ts +41 -0
- package/dist/modules/browser-ux/media-diagnostics.js +183 -0
- package/dist/modules/browser-ux/media-diagnostics.js.map +1 -0
- package/dist/modules/browser-ux/raw-rendered-diff.d.ts +70 -0
- package/dist/modules/browser-ux/raw-rendered-diff.js +262 -0
- package/dist/modules/browser-ux/raw-rendered-diff.js.map +1 -0
- package/dist/modules/browser-ux/raw-rendered-probe.d.ts +17 -0
- package/dist/modules/browser-ux/raw-rendered-probe.js +163 -0
- package/dist/modules/browser-ux/raw-rendered-probe.js.map +1 -0
- package/dist/modules/browser-ux/resource-failures-probe.d.ts +11 -0
- package/dist/modules/browser-ux/resource-failures-probe.js +231 -0
- package/dist/modules/browser-ux/resource-failures-probe.js.map +1 -0
- package/dist/modules/browser-ux/resource-failures.d.ts +79 -0
- package/dist/modules/browser-ux/resource-failures.js +178 -0
- package/dist/modules/browser-ux/resource-failures.js.map +1 -0
- package/dist/modules/browser-ux/viewport-parity-probe.d.ts +5 -0
- package/dist/modules/browser-ux/viewport-parity-probe.js +307 -0
- package/dist/modules/browser-ux/viewport-parity-probe.js.map +1 -0
- package/dist/modules/browser-ux/viewport-parity.d.ts +112 -0
- package/dist/modules/browser-ux/viewport-parity.js +224 -0
- package/dist/modules/browser-ux/viewport-parity.js.map +1 -0
- package/dist/modules/browser-ux/wcag-interactions.d.ts +95 -0
- package/dist/modules/browser-ux/wcag-interactions.js +360 -0
- package/dist/modules/browser-ux/wcag-interactions.js.map +1 -0
- package/dist/modules/change-regression/availability-history-store.d.ts +18 -0
- package/dist/modules/change-regression/availability-history-store.js +168 -0
- package/dist/modules/change-regression/availability-history-store.js.map +1 -0
- package/dist/modules/change-regression/crawler-log-correlation.d.ts +111 -0
- package/dist/modules/change-regression/crawler-log-correlation.js +374 -0
- package/dist/modules/change-regression/crawler-log-correlation.js.map +1 -0
- package/dist/modules/change-regression/google-common-crawler-ip.d.ts +15 -0
- package/dist/modules/change-regression/google-common-crawler-ip.js +129 -0
- package/dist/modules/change-regression/google-common-crawler-ip.js.map +1 -0
- package/dist/modules/change-regression/historical-comparisons.d.ts +120 -0
- package/dist/modules/change-regression/historical-comparisons.js +330 -0
- package/dist/modules/change-regression/historical-comparisons.js.map +1 -0
- package/dist/modules/change-regression/production-change-comparison.d.ts +68 -0
- package/dist/modules/change-regression/production-change-comparison.js +214 -0
- package/dist/modules/change-regression/production-change-comparison.js.map +1 -0
- package/dist/modules/change-regression/regression-alerts.d.ts +73 -0
- package/dist/modules/change-regression/regression-alerts.js +183 -0
- package/dist/modules/change-regression/regression-alerts.js.map +1 -0
- package/dist/modules/change-regression/strict-observation-time.d.ts +7 -0
- package/dist/modules/change-regression/strict-observation-time.js +31 -0
- package/dist/modules/change-regression/strict-observation-time.js.map +1 -0
- package/dist/modules/content-schema/citation-methodology-consistency.d.ts +108 -0
- package/dist/modules/content-schema/citation-methodology-consistency.js +360 -0
- package/dist/modules/content-schema/citation-methodology-consistency.js.map +1 -0
- package/dist/modules/content-schema/competitor-intent-comparison.d.ts +74 -0
- package/dist/modules/content-schema/competitor-intent-comparison.js +185 -0
- package/dist/modules/content-schema/competitor-intent-comparison.js.map +1 -0
- package/dist/modules/content-schema/empty-boilerplate-content.d.ts +36 -0
- package/dist/modules/content-schema/empty-boilerplate-content.js +225 -0
- package/dist/modules/content-schema/empty-boilerplate-content.js.map +1 -0
- package/dist/modules/content-schema/extract-citation-methodology.d.ts +6 -0
- package/dist/modules/content-schema/extract-citation-methodology.js +201 -0
- package/dist/modules/content-schema/extract-citation-methodology.js.map +1 -0
- package/dist/modules/content-schema/extract-competitor-intent.d.ts +2 -0
- package/dist/modules/content-schema/extract-competitor-intent.js +140 -0
- package/dist/modules/content-schema/extract-competitor-intent.js.map +1 -0
- package/dist/modules/content-schema/extract-main-content.d.ts +6 -0
- package/dist/modules/content-schema/extract-main-content.js +33 -0
- package/dist/modules/content-schema/extract-main-content.js.map +1 -0
- package/dist/modules/content-schema/extract-metadata-consistency.d.ts +3 -0
- package/dist/modules/content-schema/extract-metadata-consistency.js +62 -0
- package/dist/modules/content-schema/extract-metadata-consistency.js.map +1 -0
- package/dist/modules/content-schema/extract-product-claims.d.ts +3 -0
- package/dist/modules/content-schema/extract-product-claims.js +58 -0
- package/dist/modules/content-schema/extract-product-claims.js.map +1 -0
- package/dist/modules/content-schema/extract-structured-data.d.ts +3 -0
- package/dist/modules/content-schema/extract-structured-data.js +25 -0
- package/dist/modules/content-schema/extract-structured-data.js.map +1 -0
- package/dist/modules/content-schema/metadata-consistency.d.ts +66 -0
- package/dist/modules/content-schema/metadata-consistency.js +282 -0
- package/dist/modules/content-schema/metadata-consistency.js.map +1 -0
- package/dist/modules/content-schema/product-claims.d.ts +73 -0
- package/dist/modules/content-schema/product-claims.js +195 -0
- package/dist/modules/content-schema/product-claims.js.map +1 -0
- package/dist/modules/content-schema/same-language-duplicates.d.ts +52 -0
- package/dist/modules/content-schema/same-language-duplicates.js +158 -0
- package/dist/modules/content-schema/same-language-duplicates.js.map +1 -0
- package/dist/modules/content-schema/structured-data-validation.d.ts +37 -0
- package/dist/modules/content-schema/structured-data-validation.js +385 -0
- package/dist/modules/content-schema/structured-data-validation.js.map +1 -0
- package/dist/modules/external-metrics/crux-field-probe.d.ts +10 -0
- package/dist/modules/external-metrics/crux-field-probe.js +113 -0
- package/dist/modules/external-metrics/crux-field-probe.js.map +1 -0
- package/dist/modules/external-metrics/crux-field.d.ts +61 -0
- package/dist/modules/external-metrics/crux-field.js +231 -0
- package/dist/modules/external-metrics/crux-field.js.map +1 -0
- package/dist/modules/http-crawl/availability-observations.d.ts +68 -0
- package/dist/modules/http-crawl/availability-observations.js +206 -0
- package/dist/modules/http-crawl/availability-observations.js.map +1 -0
- package/dist/modules/http-crawl/availability-probe.d.ts +8 -0
- package/dist/modules/http-crawl/availability-probe.js +46 -0
- package/dist/modules/http-crawl/availability-probe.js.map +1 -0
- package/dist/modules/http-crawl/crawler-access-probe.d.ts +6 -0
- package/dist/modules/http-crawl/crawler-access-probe.js +79 -0
- package/dist/modules/http-crawl/crawler-access-probe.js.map +1 -0
- package/dist/modules/http-crawl/crawler-access.d.ts +75 -0
- package/dist/modules/http-crawl/crawler-access.js +404 -0
- package/dist/modules/http-crawl/crawler-access.js.map +1 -0
- package/dist/modules/http-crawl/http-delivery-probe.d.ts +3 -0
- package/dist/modules/http-crawl/http-delivery-probe.js +44 -0
- package/dist/modules/http-crawl/http-delivery-probe.js.map +1 -0
- package/dist/modules/http-crawl/http-delivery.d.ts +64 -0
- package/dist/modules/http-crawl/http-delivery.js +269 -0
- package/dist/modules/http-crawl/http-delivery.js.map +1 -0
- package/dist/modules/http-crawl/https-security.d.ts +84 -0
- package/dist/modules/http-crawl/https-security.js +441 -0
- package/dist/modules/http-crawl/https-security.js.map +1 -0
- package/dist/modules/http-crawl/non-html-directives.d.ts +74 -0
- package/dist/modules/http-crawl/non-html-directives.js +353 -0
- package/dist/modules/http-crawl/non-html-directives.js.map +1 -0
- package/dist/modules/http-crawl/redirect-canonical-chains.d.ts +80 -0
- package/dist/modules/http-crawl/redirect-canonical-chains.js +459 -0
- package/dist/modules/http-crawl/redirect-canonical-chains.js.map +1 -0
- package/dist/modules/http-crawl/redirect-canonical-probe.d.ts +6 -0
- package/dist/modules/http-crawl/redirect-canonical-probe.js +83 -0
- package/dist/modules/http-crawl/redirect-canonical-probe.js.map +1 -0
- package/dist/modules/http-crawl/sitemap-inventory-probe.d.ts +8 -0
- package/dist/modules/http-crawl/sitemap-inventory-probe.js +155 -0
- package/dist/modules/http-crawl/sitemap-inventory-probe.js.map +1 -0
- package/dist/modules/http-crawl/sitemap-inventory.d.ts +107 -0
- package/dist/modules/http-crawl/sitemap-inventory.js +557 -0
- package/dist/modules/http-crawl/sitemap-inventory.js.map +1 -0
- package/dist/modules/http-crawl/url-variants.d.ts +86 -0
- package/dist/modules/http-crawl/url-variants.js +379 -0
- package/dist/modules/http-crawl/url-variants.js.map +1 -0
- package/dist/modules/site-architecture/extract-internal-links.d.ts +3 -0
- package/dist/modules/site-architecture/extract-internal-links.js +88 -0
- package/dist/modules/site-architecture/extract-internal-links.js.map +1 -0
- package/dist/modules/site-architecture/extract-multilingual-page.d.ts +2 -0
- package/dist/modules/site-architecture/extract-multilingual-page.js +29 -0
- package/dist/modules/site-architecture/extract-multilingual-page.js.map +1 -0
- package/dist/modules/site-architecture/internal-link-graph-probe.d.ts +7 -0
- package/dist/modules/site-architecture/internal-link-graph-probe.js +116 -0
- package/dist/modules/site-architecture/internal-link-graph-probe.js.map +1 -0
- package/dist/modules/site-architecture/internal-link-graph.d.ts +113 -0
- package/dist/modules/site-architecture/internal-link-graph.js +414 -0
- package/dist/modules/site-architecture/internal-link-graph.js.map +1 -0
- package/dist/modules/site-architecture/internal-link-quality.d.ts +77 -0
- package/dist/modules/site-architecture/internal-link-quality.js +260 -0
- package/dist/modules/site-architecture/internal-link-quality.js.map +1 -0
- package/dist/modules/site-architecture/multilingual-clusters.d.ts +82 -0
- package/dist/modules/site-architecture/multilingual-clusters.js +363 -0
- package/dist/modules/site-architecture/multilingual-clusters.js.map +1 -0
- package/dist/network.d.ts +4 -0
- package/dist/network.js +18 -2
- package/dist/network.js.map +1 -1
- package/dist/presentation.d.ts +53 -0
- package/dist/presentation.js +526 -0
- package/dist/presentation.js.map +1 -1
- package/dist/screenshot.d.ts +2 -1
- package/dist/screenshot.js +4 -2
- package/dist/screenshot.js.map +1 -1
- package/dist/seo-auditor.js +16 -6
- package/dist/seo-auditor.js.map +1 -1
- package/package.json +7 -4
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract-product-claims.js","sourceRoot":"","sources":["../../../src/modules/content-schema/extract-product-claims.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EACL,gBAAgB,EAChB,4BAA4B,EAC5B,uBAAuB,GAExB,MAAM,qBAAqB,CAAC;AAE7B,iFAAiF;AACjF,MAAM,UAAU,oBAAoB,CAAC,IAAY;IAC/C,IAAI,CAAC,IAAI,IAAI,MAAM,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,GAAG,4BAA4B,EAAE,CAAC;QAC5E,MAAM,IAAI,KAAK,CAAC,+DAA+D,CAAC,CAAC;IACnF,CAAC;IACD,MAAM,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC,CAAC,sFAAsF,CAAC,CAAC,MAAM,EAAE,CAAC;IACnG,MAAM,IAAI,GAAG,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,CAAC;IAC/B,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,CAAC;IACpD,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,EAAE,CAAC;IAC9C,SAAS,YAAY,CAAC,IAAY;QAChC,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC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AAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;YAC9D,mCAAmC,CAAC,IAAI,CAAC,CAAC,CAAC;YAC3C,CAAC,sEAAsE,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAClF,mBAAmB,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;YAC9D,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC1B,wBAAwB,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,CAAC;YACnE,kCAAkC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,kBAAkB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC3E,mBAAmB,EAAE,MAAM,CAAC,SAAS,IAAI,KAAK,CAAC,SAAS,IAAI,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,GAAG;YACxF,IAAI,CAAC,MAAM,IAAI,MAAM;KACxB,CAAC;AACJ,CAAC","sourcesContent":["import * as cheerio from \"cheerio\";\nimport {\n isPublicToolName,\n MAX_PRODUCT_CLAIM_HTML_BYTES,\n MAX_PRODUCT_CLAIM_TOOLS,\n type ProductClaimObservation,\n} from \"./product-claims.js\";\n\n/** Static, visible main-content promises only; scripts and nav never execute. */\nexport function observeProductClaims(html: string): ProductClaimObservation {\n if (!html || Buffer.byteLength(html, \"utf8\") > MAX_PRODUCT_CLAIM_HTML_BYTES) {\n throw new Error(\"Landing HTML must be present and at most 250,000 UTF-8 bytes.\");\n }\n const $ = cheerio.load(html);\n $(\"template,script,style,noscript,nav,header,footer,aside,[hidden],[aria-hidden='true']\").remove();\n const main = $(\"main\").first();\n const root = main.length ? main : $(\"body\").first();\n const headings = root.find(\"h2,h3\").toArray();\n function findToolList(term: RegExp) {\n const heading = headings.find((node) => term.test($(node).text().trim()));\n if (!heading) return { found: false, tools: [] as string[], truncated: false };\n const section = $(heading).closest(\"section\");\n const container = section.length ? section : $(heading).parent();\n const all = container.find(\"code,[data-mcp-tool]\").toArray()\n .filter((node) => $(node).closest(\"pre\").length === 0)\n .map((node) => $(node).attr(\"data-mcp-tool\")?.trim() || $(node).text().trim())\n .filter((text) => isPublicToolName(text));\n return {\n found: true,\n tools: [...new Set(all)].slice(0, MAX_PRODUCT_CLAIM_TOOLS),\n truncated: [...new Set(all)].length > MAX_PRODUCT_CLAIM_TOOLS,\n };\n }\n const hosted = findToolList(/(?:public chatgpt capabilities|hosted(?: mcp)? tools|chatgpt tool list)/i);\n const local = findToolList(/(?:local(?: mcp)? capabilities|local(?: mcp)? tools)/i);\n // Use explicit short on-page statements rather than guessing from unrelated\n // marketing/nav/footer content or claiming all sales prose was analyzed.\n const paragraphs = root.find(\"p,li\").toArray().slice(0, 220)\n .map((node) => $(node).text().replace(/\\s+/gu, \" \").trim().toLowerCase())\n .filter((text) => text.length > 0 && text.length <= 2000);\n const body = root.text().replace(/\\s+/gu, \" \").slice(0, 70_000);\n // Cheerio concatenates adjacent block elements without inserted whitespace.\n const siteLimit = /site\\s*batch\\s*up\\s*to\\s*(\\d{1,12})\\s*pages/i.exec(body);\n const number = siteLimit ? Number(siteLimit[1]) : undefined;\n return {\n hasMain: main.length > 0,\n hostedSectionFound: hosted.found,\n localSectionFound: local.found,\n hostedTools: hosted.tools,\n localTools: local.tools,\n ...(number && Number.isSafeInteger(number) ? { siteBatchLimit: number } : {}),\n localScreenshotClaim: paragraphs.some((p) => /\\blocal\\b/.test(p) &&\n /(?:screenshots?|screen captures?)/.test(p) &&\n !/(?:local[^\\n]{0,80}(?:cannot|does not|doesn't)[^\\n]{0,80}screenshot)/.test(p)),\n hostedReadOnlyClaim: paragraphs.some((p) => /\\bhosted\\b/.test(p) &&\n /\\bread.only\\b/.test(p)),\n hostedNoScreenshotsClaim: paragraphs.some((p) => /\\bhosted\\b/.test(p) &&\n /(?:cannot|does not|doesn't|no)\\b/.test(p) && /\\bscreenshots?\\b/.test(p)),\n extractionTruncated: hosted.truncated || local.truncated || root.find(\"p,li\").length > 220 ||\n body.length >= 70_000,\n };\n}\n"]}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import * as cheerio from "cheerio";
|
|
2
|
+
import { MAX_SUPPORTED_SCHEMA_HTML_BYTES, MAX_SUPPORTED_SCHEMA_SCRIPTS, reviewSupportedJsonLd, } from "./structured-data-validation.js";
|
|
3
|
+
/** Extract only inert, explicitly typed JSON-LD; never fetch referenced URLs. */
|
|
4
|
+
export function reviewSupportedSchemaHtml(html) {
|
|
5
|
+
if (!html || new TextEncoder().encode(html).byteLength > MAX_SUPPORTED_SCHEMA_HTML_BYTES) {
|
|
6
|
+
throw new Error("Static HTML must be present and at most 250,000 UTF-8 bytes.");
|
|
7
|
+
}
|
|
8
|
+
const $ = cheerio.load(html);
|
|
9
|
+
const scripts = $("script[type]").filter((_, element) => {
|
|
10
|
+
const type = ($(element).attr("type") ?? "").split(";", 1)[0].trim().toLowerCase();
|
|
11
|
+
if (type !== "application/ld+json")
|
|
12
|
+
return false;
|
|
13
|
+
let node = element;
|
|
14
|
+
while (node) {
|
|
15
|
+
if (node.name?.toLowerCase() === "template")
|
|
16
|
+
return false;
|
|
17
|
+
node = (node.parent ?? null);
|
|
18
|
+
}
|
|
19
|
+
return true;
|
|
20
|
+
});
|
|
21
|
+
const sample = scripts.toArray().slice(0, MAX_SUPPORTED_SCHEMA_SCRIPTS)
|
|
22
|
+
.map((element) => $(element).html() ?? "");
|
|
23
|
+
return reviewSupportedJsonLd(sample, scripts.length);
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=extract-structured-data.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"extract-structured-data.js","sourceRoot":"","sources":["../../../src/modules/content-schema/extract-structured-data.ts"],"names":[],"mappings":"AAAA,OAAO,KA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AE,IAAI,EAAE,CAAC,CAAC;IAC7C,OAAO,qBAAqB,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;AACvD,CAAC","sourcesContent":["import * as cheerio from \"cheerio\";\nimport {\n MAX_SUPPORTED_SCHEMA_HTML_BYTES, MAX_SUPPORTED_SCHEMA_SCRIPTS,\n reviewSupportedJsonLd, type SupportedSchemaReview,\n} from \"./structured-data-validation.js\";\n\n/** Extract only inert, explicitly typed JSON-LD; never fetch referenced URLs. */\nexport function reviewSupportedSchemaHtml(html: string): SupportedSchemaReview {\n if (!html || new TextEncoder().encode(html).byteLength > MAX_SUPPORTED_SCHEMA_HTML_BYTES) {\n throw new Error(\"Static HTML must be present and at most 250,000 UTF-8 bytes.\");\n }\n const $ = cheerio.load(html);\n const scripts = $(\"script[type]\").filter((_, element) => {\n const type = ($(element).attr(\"type\") ?? \"\").split(\";\", 1)[0].trim().toLowerCase();\n if (type !== \"application/ld+json\") return false;\n let node: { name?: string; parent?: unknown } | null = element;\n while (node) {\n if (node.name?.toLowerCase() === \"template\") return false;\n node = (node.parent ?? null) as typeof node;\n }\n return true;\n });\n const sample = scripts.toArray().slice(0, MAX_SUPPORTED_SCHEMA_SCRIPTS)\n .map((element) => $(element).html() ?? \"\");\n return reviewSupportedJsonLd(sample, scripts.length);\n}\n"]}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* P1-09: bounded, evidence-only metadata consistency review.
|
|
3
|
+
*
|
|
4
|
+
* No document fetch, canonical selection, social preview rendering, browser
|
|
5
|
+
* execution, or inference of Google search outcomes. Raw values are ephemeral.
|
|
6
|
+
*/
|
|
7
|
+
export declare const MAX_METADATA_PAGES = 8;
|
|
8
|
+
export declare const MAX_METADATA_HTML_BYTES = 180000;
|
|
9
|
+
export declare const MAX_METADATA_TOTAL_BYTES = 900000;
|
|
10
|
+
export declare const MAX_METADATA_VALUES = 12;
|
|
11
|
+
export declare const MAX_METADATA_FINDINGS = 12;
|
|
12
|
+
export declare const METADATA_FIELDS: readonly ["title", "description", "canonical", "og:title", "og:description", "og:url", "twitter:title", "twitter:description", "robots", "googlebot"];
|
|
13
|
+
export type MetadataField = typeof METADATA_FIELDS[number];
|
|
14
|
+
export type MetadataFindingCode = "duplicate_declaration" | "conflicting_declaration" | "unresolved_canonical" | "conflicting_robots_directives" | "title_social_difference" | "description_social_difference" | "canonical_social_url_difference" | "duplicate_title_across_pages" | "duplicate_description_across_pages" | "truncated_metadata_sample";
|
|
15
|
+
export type MetadataIssue = {
|
|
16
|
+
code: MetadataFindingCode;
|
|
17
|
+
severity: "warning" | "info";
|
|
18
|
+
confidence: "observed" | "review";
|
|
19
|
+
source_page: number;
|
|
20
|
+
field: MetadataField;
|
|
21
|
+
count: number;
|
|
22
|
+
related_pages?: number[];
|
|
23
|
+
message: string;
|
|
24
|
+
};
|
|
25
|
+
export interface MetadataObservation {
|
|
26
|
+
url: string;
|
|
27
|
+
values: Record<MetadataField, string[]>;
|
|
28
|
+
base_href?: string;
|
|
29
|
+
excluded_canonicals: number;
|
|
30
|
+
extraction_limited: boolean;
|
|
31
|
+
}
|
|
32
|
+
export type MetadataPageReview = {
|
|
33
|
+
page: number;
|
|
34
|
+
fields_present: number;
|
|
35
|
+
title_declarations: number;
|
|
36
|
+
description_declarations: number;
|
|
37
|
+
canonical_declarations: number;
|
|
38
|
+
robots_declarations: number;
|
|
39
|
+
duplicate_fields: number;
|
|
40
|
+
conflicting_fields: number;
|
|
41
|
+
unresolved_canonicals: number;
|
|
42
|
+
cross_field_review_leads: number;
|
|
43
|
+
extraction_limited: boolean;
|
|
44
|
+
};
|
|
45
|
+
export type MetadataReview = {
|
|
46
|
+
scope: "caller_supplied_same_origin_metadata_only";
|
|
47
|
+
pages_sampled: number;
|
|
48
|
+
origin: string;
|
|
49
|
+
duplicate_declaration_fields: number;
|
|
50
|
+
conflicting_declaration_fields: number;
|
|
51
|
+
unresolved_canonical_references: number;
|
|
52
|
+
explicit_robots_conflicts: number;
|
|
53
|
+
cross_field_review_leads: number;
|
|
54
|
+
duplicate_title_groups: number;
|
|
55
|
+
duplicate_description_groups: number;
|
|
56
|
+
excluded_annotated_canonicals: number;
|
|
57
|
+
pages: MetadataPageReview[];
|
|
58
|
+
coverage_limited: true;
|
|
59
|
+
limitations: string[];
|
|
60
|
+
total_findings: number;
|
|
61
|
+
findings: MetadataIssue[];
|
|
62
|
+
findings_truncated: boolean;
|
|
63
|
+
};
|
|
64
|
+
export declare function safeMetadataLabel(raw: string): string | undefined;
|
|
65
|
+
export declare function emptyMetadataReview(): MetadataReview;
|
|
66
|
+
export declare function analyzeMetadataConsistency(observations: readonly MetadataObservation[]): MetadataReview;
|
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* P1-09: bounded, evidence-only metadata consistency review.
|
|
3
|
+
*
|
|
4
|
+
* No document fetch, canonical selection, social preview rendering, browser
|
|
5
|
+
* execution, or inference of Google search outcomes. Raw values are ephemeral.
|
|
6
|
+
*/
|
|
7
|
+
export const MAX_METADATA_PAGES = 8;
|
|
8
|
+
export const MAX_METADATA_HTML_BYTES = 180_000;
|
|
9
|
+
export const MAX_METADATA_TOTAL_BYTES = 900_000;
|
|
10
|
+
export const MAX_METADATA_VALUES = 12;
|
|
11
|
+
export const MAX_METADATA_FINDINGS = 12;
|
|
12
|
+
export const METADATA_FIELDS = [
|
|
13
|
+
"title", "description", "canonical", "og:title", "og:description", "og:url",
|
|
14
|
+
"twitter:title", "twitter:description", "robots", "googlebot",
|
|
15
|
+
];
|
|
16
|
+
export function safeMetadataLabel(raw) {
|
|
17
|
+
if (!raw || raw.length > 512)
|
|
18
|
+
return undefined;
|
|
19
|
+
try {
|
|
20
|
+
const url = new URL(raw);
|
|
21
|
+
if (!["http:", "https:"].includes(url.protocol) || !url.hostname || url.username ||
|
|
22
|
+
url.password || url.search || url.hash || url.port || url.hostname.length > 180)
|
|
23
|
+
return;
|
|
24
|
+
return url.href;
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
function normalizedText(value) {
|
|
31
|
+
return value.normalize("NFKC").replace(/\s+/gu, " ").trim().toLocaleLowerCase("en");
|
|
32
|
+
}
|
|
33
|
+
function normalizedUrl(value, base) {
|
|
34
|
+
if (!value || value.length > 1024)
|
|
35
|
+
return undefined;
|
|
36
|
+
try {
|
|
37
|
+
const url = new URL(value, base);
|
|
38
|
+
if (!["http:", "https:"].includes(url.protocol) || !url.hostname ||
|
|
39
|
+
url.username || url.password || url.hash)
|
|
40
|
+
return undefined;
|
|
41
|
+
return url.href;
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
function robotsTokens(raw) {
|
|
48
|
+
return raw.toLocaleLowerCase("en").split(",")
|
|
49
|
+
.map((piece) => piece.trim().replace(/\s*:\s*/gu, ":").replace(/\s+/gu, " "))
|
|
50
|
+
.filter(Boolean)
|
|
51
|
+
.flatMap((piece) => piece === "none" ? ["noindex", "nofollow"]
|
|
52
|
+
: piece === "all" ? ["index", "follow"] : [piece]);
|
|
53
|
+
}
|
|
54
|
+
function robotsParts(raw) {
|
|
55
|
+
return new Set(robotsTokens(raw).map((token) => token.split(/[:\s]/u)[0]));
|
|
56
|
+
}
|
|
57
|
+
function normalizedRobots(raw) {
|
|
58
|
+
return [...new Set(robotsTokens(raw))].sort().join(",");
|
|
59
|
+
}
|
|
60
|
+
function robotsDeclarationConflict(rawValues) {
|
|
61
|
+
const tokens = new Set(rawValues.flatMap(robotsTokens));
|
|
62
|
+
const parts = new Set([...tokens].map((token) => token.split(/[:\s]/u)[0]));
|
|
63
|
+
if ((parts.has("index") && parts.has("noindex")) ||
|
|
64
|
+
(parts.has("follow") && parts.has("nofollow")))
|
|
65
|
+
return true;
|
|
66
|
+
const byDirective = new Map();
|
|
67
|
+
for (const token of tokens) {
|
|
68
|
+
const key = token.split(/[:\s]/u)[0];
|
|
69
|
+
const existing = byDirective.get(key);
|
|
70
|
+
if (existing && existing !== token)
|
|
71
|
+
return true;
|
|
72
|
+
byDirective.set(key, token);
|
|
73
|
+
}
|
|
74
|
+
return false;
|
|
75
|
+
}
|
|
76
|
+
export function emptyMetadataReview() {
|
|
77
|
+
return {
|
|
78
|
+
scope: "caller_supplied_same_origin_metadata_only",
|
|
79
|
+
pages_sampled: 0, origin: "", duplicate_declaration_fields: 0,
|
|
80
|
+
conflicting_declaration_fields: 0, unresolved_canonical_references: 0,
|
|
81
|
+
explicit_robots_conflicts: 0, cross_field_review_leads: 0,
|
|
82
|
+
duplicate_title_groups: 0, duplicate_description_groups: 0,
|
|
83
|
+
excluded_annotated_canonicals: 0, pages: [], coverage_limited: true,
|
|
84
|
+
limitations: ["The supplied metadata sample could not be compared within its limits."],
|
|
85
|
+
total_findings: 0, findings: [], findings_truncated: false,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
export function analyzeMetadataConsistency(observations) {
|
|
89
|
+
if (!observations.length || observations.length > MAX_METADATA_PAGES) {
|
|
90
|
+
throw new Error("Supply one to eight metadata observations.");
|
|
91
|
+
}
|
|
92
|
+
const pages = observations.map((observation) => safeMetadataLabel(observation.url));
|
|
93
|
+
if (pages.some((url) => !url) || new Set(pages).size !== pages.length) {
|
|
94
|
+
throw new Error("Page labels must be distinct safe HTTP(S) URLs.");
|
|
95
|
+
}
|
|
96
|
+
const origin = new URL(pages[0]).origin;
|
|
97
|
+
if (pages.some((url) => new URL(url).origin !== origin)) {
|
|
98
|
+
throw new Error("All supplied page URLs must share one exact origin.");
|
|
99
|
+
}
|
|
100
|
+
const findings = [];
|
|
101
|
+
const pageSummaries = [];
|
|
102
|
+
const identities = [];
|
|
103
|
+
let duplicates = 0, conflicts = 0, unresolved = 0, robotsConflicts = 0;
|
|
104
|
+
let crossField = 0, excluded = 0;
|
|
105
|
+
let extractionLimited = false;
|
|
106
|
+
function add(code, severity, page, field, count, message, confidence = "review", related_pages) {
|
|
107
|
+
findings.push({
|
|
108
|
+
code, severity, confidence, source_page: page, field, count, message,
|
|
109
|
+
...(related_pages?.length ? { related_pages: related_pages.slice(0, MAX_METADATA_PAGES - 1) } : {}),
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
for (const [i, sample] of observations.entries()) {
|
|
113
|
+
const page = i + 1;
|
|
114
|
+
const input = sample.values;
|
|
115
|
+
const stats = {
|
|
116
|
+
page, fields_present: 0,
|
|
117
|
+
title_declarations: input.title.length,
|
|
118
|
+
description_declarations: input.description.length,
|
|
119
|
+
canonical_declarations: input.canonical.length,
|
|
120
|
+
robots_declarations: input.robots.length + input.googlebot.length,
|
|
121
|
+
duplicate_fields: 0, conflicting_fields: 0,
|
|
122
|
+
unresolved_canonicals: 0, cross_field_review_leads: 0,
|
|
123
|
+
extraction_limited: sample.extraction_limited,
|
|
124
|
+
};
|
|
125
|
+
excluded += sample.excluded_canonicals;
|
|
126
|
+
let base = pages[i];
|
|
127
|
+
if (sample.base_href) {
|
|
128
|
+
const resolved = normalizedUrl(sample.base_href, base);
|
|
129
|
+
// Relative canonicals with an unresolvable <base> are never compared
|
|
130
|
+
// against the document URL as if the override did not exist.
|
|
131
|
+
base = resolved ?? "";
|
|
132
|
+
if (!resolved)
|
|
133
|
+
extractionLimited = true;
|
|
134
|
+
}
|
|
135
|
+
const canonicalTargets = [];
|
|
136
|
+
for (const raw of input.canonical.slice(0, MAX_METADATA_VALUES)) {
|
|
137
|
+
const parsed = base ? normalizedUrl(raw, base) : undefined;
|
|
138
|
+
if (parsed)
|
|
139
|
+
canonicalTargets.push(parsed);
|
|
140
|
+
else {
|
|
141
|
+
unresolved += 1;
|
|
142
|
+
stats.unresolved_canonicals += 1;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
if (stats.unresolved_canonicals)
|
|
146
|
+
add("unresolved_canonical", "info", page, "canonical", stats.unresolved_canonicals, "An explicit canonical preference could not be compared safely; invalid, fragment-bearing, credentialed or unresolved URLs remain unverified.");
|
|
147
|
+
const norm = {};
|
|
148
|
+
for (const field of METADATA_FIELDS) {
|
|
149
|
+
const original = input[field].slice(0, MAX_METADATA_VALUES);
|
|
150
|
+
if (original.length)
|
|
151
|
+
stats.fields_present += 1;
|
|
152
|
+
const values = field === "canonical" ? canonicalTargets
|
|
153
|
+
: field === "og:url" ? original.map((value) => normalizedUrl(value, pages[i]) ?? "").filter(Boolean)
|
|
154
|
+
: field === "robots" || field === "googlebot" ? original.map(normalizedRobots)
|
|
155
|
+
: original.map(normalizedText);
|
|
156
|
+
norm[field] = values;
|
|
157
|
+
if (values.length < 2)
|
|
158
|
+
continue;
|
|
159
|
+
const distinct = new Set(values);
|
|
160
|
+
if (distinct.size > 1) {
|
|
161
|
+
// Complementary robots declarations (e.g. separate noindex and
|
|
162
|
+
// nofollow tags) are not contradictory just because text differs.
|
|
163
|
+
if ((field === "robots" || field === "googlebot") &&
|
|
164
|
+
!robotsDeclarationConflict(original))
|
|
165
|
+
continue;
|
|
166
|
+
conflicts += 1;
|
|
167
|
+
stats.conflicting_fields += 1;
|
|
168
|
+
add("conflicting_declaration", "warning", page, field, values.length, "Multiple nonidentical declarations for the same metadata field were observed in the supplied HTML; review which value is intended.", "observed");
|
|
169
|
+
}
|
|
170
|
+
else {
|
|
171
|
+
duplicates += 1;
|
|
172
|
+
stats.duplicate_fields += 1;
|
|
173
|
+
add("duplicate_declaration", "info", page, field, values.length, "The same metadata field is declared repeatedly with equivalent normalized values; this may be redundant but is not necessarily an SEO error.", "observed");
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
const allRobots = input.robots.map(robotsParts);
|
|
177
|
+
const allGooglebot = input.googlebot.map(robotsParts);
|
|
178
|
+
const generic = new Set(allRobots.flatMap((v) => [...v]));
|
|
179
|
+
const specific = new Set(allGooglebot.flatMap((v) => [...v]));
|
|
180
|
+
// Check all declarations for each agent, not just contradictions within
|
|
181
|
+
// a single comma-delimited meta tag.
|
|
182
|
+
const contradicts = (parts) => (parts.has("index") && parts.has("noindex")) ||
|
|
183
|
+
(parts.has("follow") && parts.has("nofollow"));
|
|
184
|
+
const contradictions = contradicts(generic) || contradicts(specific);
|
|
185
|
+
// Generic directives can apply to Googlebot, but a more restrictive
|
|
186
|
+
// directive or agent-specific instruction may intentionally override.
|
|
187
|
+
const crossAgent = (generic.has("index") && specific.has("noindex")) ||
|
|
188
|
+
(generic.has("noindex") && specific.has("index")) ||
|
|
189
|
+
(generic.has("follow") && specific.has("nofollow")) ||
|
|
190
|
+
(generic.has("nofollow") && specific.has("follow"));
|
|
191
|
+
if (contradictions || crossAgent) {
|
|
192
|
+
robotsConflicts += 1;
|
|
193
|
+
add("conflicting_robots_directives", "info", page, "robots", 1, "Potentially incompatible explicit robots directives were found; agent specificity and most-restrictive behavior need review.");
|
|
194
|
+
}
|
|
195
|
+
function compare(fieldA, fieldB, message, code) {
|
|
196
|
+
const left = norm[fieldA] ?? [];
|
|
197
|
+
const right = norm[fieldB] ?? [];
|
|
198
|
+
// Conflicting multi-valued metadata has its own finding and does not
|
|
199
|
+
// authorize selecting a first value for a secondary comparison.
|
|
200
|
+
if (left.length !== 1 || right.length !== 1 || !left[0] || !right[0])
|
|
201
|
+
return;
|
|
202
|
+
if (left[0] !== right[0]) {
|
|
203
|
+
crossField += 1;
|
|
204
|
+
stats.cross_field_review_leads += 1;
|
|
205
|
+
add(code, "info", page, fieldB, 1, message);
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
compare("title", "og:title", "The title and Open Graph title differ as normalized text; social titles can intentionally differ from search titles.", "title_social_difference");
|
|
209
|
+
compare("description", "og:description", "The meta description and Open Graph description differ; social and search snippets can legitimately be tailored.", "description_social_difference");
|
|
210
|
+
compare(input["og:title"].length ? "og:title" : "title", "twitter:title", "The Twitter title differs from the available Open Graph or page title; social presentation can intentionally differ.", "title_social_difference");
|
|
211
|
+
compare(input["og:description"].length ? "og:description" : "description", "twitter:description", "The Twitter description differs from the available Open Graph or meta description; social presentation can intentionally differ.", "description_social_difference");
|
|
212
|
+
// An invalid second declaration does not make the remaining canonical
|
|
213
|
+
// an unambiguous preference. Do not silently select a "surviving" value.
|
|
214
|
+
const unambiguousCanonical = input.canonical.length === 1 && canonicalTargets.length === 1
|
|
215
|
+
? canonicalTargets[0] : undefined;
|
|
216
|
+
const ogUrl = input["og:url"].length === 1 ? normalizedUrl(input["og:url"][0], pages[i]) : undefined;
|
|
217
|
+
if (unambiguousCanonical && ogUrl && unambiguousCanonical !== ogUrl) {
|
|
218
|
+
crossField += 1;
|
|
219
|
+
stats.cross_field_review_leads += 1;
|
|
220
|
+
add("canonical_social_url_difference", "info", page, "og:url", 1, "The declared canonical preference and Open Graph URL point to different URLs; social URL selection and Google canonicalization are separate mechanisms.");
|
|
221
|
+
}
|
|
222
|
+
identities.push(unambiguousCanonical ?? pages[i]);
|
|
223
|
+
if (sample.extraction_limited || input.canonical.length > MAX_METADATA_VALUES) {
|
|
224
|
+
extractionLimited = true;
|
|
225
|
+
add("truncated_metadata_sample", "info", page, "title", 1, "The static metadata declaration sample reached an extraction cap; further values are unverified.");
|
|
226
|
+
}
|
|
227
|
+
pageSummaries.push(stats);
|
|
228
|
+
}
|
|
229
|
+
function duplicatesAcross(field, code) {
|
|
230
|
+
const groups = new Map();
|
|
231
|
+
for (const [i, sample] of observations.entries()) {
|
|
232
|
+
const raw = sample.values[field];
|
|
233
|
+
if (raw.length !== 1)
|
|
234
|
+
continue;
|
|
235
|
+
const value = normalizedText(raw[0]);
|
|
236
|
+
if (!value)
|
|
237
|
+
continue;
|
|
238
|
+
const pages = groups.get(value) ?? [];
|
|
239
|
+
pages.push(i);
|
|
240
|
+
groups.set(value, pages);
|
|
241
|
+
}
|
|
242
|
+
let count = 0;
|
|
243
|
+
for (const group of groups.values()) {
|
|
244
|
+
if (group.length < 2 || new Set(group.map((index) => identities[index])).size < 2)
|
|
245
|
+
continue;
|
|
246
|
+
count += 1;
|
|
247
|
+
add(code, "info", group[0] + 1, field, group.length, "Different sampled pages with distinct declared canonical preferences or URL labels share equivalent metadata text; this can be intentional for variants and is only a review lead.", "review", group.slice(1).map((value) => value + 1));
|
|
248
|
+
}
|
|
249
|
+
return count;
|
|
250
|
+
}
|
|
251
|
+
const duplicateTitleGroups = duplicatesAcross("title", "duplicate_title_across_pages");
|
|
252
|
+
const duplicateDescriptionGroups = duplicatesAcross("description", "duplicate_description_across_pages");
|
|
253
|
+
const rank = { warning: 0, info: 1 };
|
|
254
|
+
findings.sort((a, b) => rank[a.severity] - rank[b.severity] ||
|
|
255
|
+
a.source_page - b.source_page || a.code.localeCompare(b.code) || a.field.localeCompare(b.field));
|
|
256
|
+
return {
|
|
257
|
+
scope: "caller_supplied_same_origin_metadata_only",
|
|
258
|
+
pages_sampled: observations.length,
|
|
259
|
+
origin,
|
|
260
|
+
duplicate_declaration_fields: duplicates,
|
|
261
|
+
conflicting_declaration_fields: conflicts,
|
|
262
|
+
unresolved_canonical_references: unresolved,
|
|
263
|
+
explicit_robots_conflicts: robotsConflicts,
|
|
264
|
+
cross_field_review_leads: crossField,
|
|
265
|
+
duplicate_title_groups: duplicateTitleGroups,
|
|
266
|
+
duplicate_description_groups: duplicateDescriptionGroups,
|
|
267
|
+
excluded_annotated_canonicals: excluded,
|
|
268
|
+
pages: pageSummaries,
|
|
269
|
+
coverage_limited: true,
|
|
270
|
+
limitations: [
|
|
271
|
+
"Only caller-supplied same-origin static HTML metadata was compared; no web requests, redirects, HTTP headers, rendered content, Google-selected canonicals, search results, or indexing data were inspected.",
|
|
272
|
+
"Conflicting declarations are on-page evidence; differences between search and social metadata, repeated titles/descriptions, and robots hints are contextual review leads, not automatic SEO violations.",
|
|
273
|
+
"Canonical preferences are hints, not verified selected canonicals. Canonical chains/cycles and live indexability remain the existing independent graph/status tools' responsibility.",
|
|
274
|
+
...(extractionLimited || excluded
|
|
275
|
+
? ["Some declarations were excluded or capped, including annotated canonicals; omitted metadata is unverified."] : []),
|
|
276
|
+
],
|
|
277
|
+
total_findings: findings.length,
|
|
278
|
+
findings: findings.slice(0, MAX_METADATA_FINDINGS),
|
|
279
|
+
findings_truncated: findings.length > MAX_METADATA_FINDINGS,
|
|
280
|
+
};
|
|
281
|
+
}
|
|
282
|
+
//# sourceMappingURL=metadata-consistency.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"metadata-consistency.js","sourceRoot":"","sources":["../../../src/modules/content-schema/metadata-consistency.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AACpC,MAAM,CAAC,MAAM,uBAAuB,GAAG,OAAO,CAAC;AAC/C,MAAM,CAAC,MAAM,wBAAwB,GAAG,OAAO,CAAC;AAChD,MAAM,CAAC,MAAM,mBAAmB,GAAG,EAAE,CAAC;AACtC,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAExC,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,UAAU,EAAE,gBAAgB,EAAE,QAAQ;IAC3E,eAAe,EAAE,qBAAqB,EAAE,QAAQ,EAAE,WAAW;CACrD,CAAC;AA0DX,MAAM,UAAU,iBAAiB,CAAC,GAAW;IAC3C,IAAI,CAAC,GAAG,IAAI,GAAG,CAAC,MAAM,GAAG,GAAG;QAAE,OAAO,SAAS,CAAC;IAC/C,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QACzB,IAAI,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,QAAQ;YAC9E,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,QAAQ,CAA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a,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;IACnG,OAAO;QACL,KAAK,EAAE,2CAA2C;QAClD,aAAa,EAAE,YAAY,CAAC,MAAM;QAClC,MAAM;QACN,4BAA4B,EAAE,UAAU;QACxC,8BAA8B,EAAE,SAAS;QACzC,+BAA+B,EAAE,UAAU;QAC3C,yBAAyB,EAAE,eAAe;QAC1C,wBAAwB,EAAE,UAAU;QACpC,sBAAsB,EAAE,oBAAoB;QAC5C,4BAA4B,EAAE,0BAA0B;QACxD,6BAA6B,EAAE,QAAQ;QACvC,KAAK,EAAE,aAAa;QACpB,gBAAgB,EAAE,IAAI;QACtB,WAAW,EAAE;YACX,8MAA8M;YAC9M,0MAA0M;YAC1M,sLAAsL;YACtL,GAAG,CAAC,iBAAiB,IAAI,QAAQ;gBAC/B,CAAC,CAAC,CAAC,4GAA4G,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SACzH;QACD,cAAc,EAAE,QAAQ,CAAC,MAAM;QAC/B,QAAQ,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,qBAAqB,CAAC;QAClD,kBAAkB,EAAE,QAAQ,CAAC,MAAM,GAAG,qBAAqB;KAC5D,CAAC;AACJ,CAAC","sourcesContent":["/**\n * P1-09: bounded, evidence-only metadata consistency review.\n *\n * No document fetch, canonical selection, social preview rendering, browser\n * execution, or inference of Google search outcomes. Raw values are ephemeral.\n */\nexport const MAX_METADATA_PAGES = 8;\nexport const MAX_METADATA_HTML_BYTES = 180_000;\nexport const MAX_METADATA_TOTAL_BYTES = 900_000;\nexport const MAX_METADATA_VALUES = 12;\nexport const MAX_METADATA_FINDINGS = 12;\n\nexport const METADATA_FIELDS = [\n \"title\", \"description\", \"canonical\", \"og:title\", \"og:description\", \"og:url\",\n \"twitter:title\", \"twitter:description\", \"robots\", \"googlebot\",\n] as const;\nexport type MetadataField = typeof METADATA_FIELDS[number];\nexport type MetadataFindingCode =\n | \"duplicate_declaration\" | \"conflicting_declaration\" | \"unresolved_canonical\"\n | \"conflicting_robots_directives\" | \"title_social_difference\"\n | \"description_social_difference\" | \"canonical_social_url_difference\"\n | \"duplicate_title_across_pages\" | \"duplicate_description_across_pages\"\n | \"truncated_metadata_sample\";\nexport type MetadataIssue = {\n code: MetadataFindingCode;\n severity: \"warning\" | \"info\";\n confidence: \"observed\" | \"review\";\n source_page: number;\n field: MetadataField;\n count: number;\n related_pages?: number[];\n message: string;\n};\nexport interface MetadataObservation {\n url: string;\n values: Record<MetadataField, string[]>;\n base_href?: string;\n excluded_canonicals: number;\n extraction_limited: boolean;\n}\nexport type MetadataPageReview = {\n page: number;\n fields_present: number;\n title_declarations: number;\n description_declarations: number;\n canonical_declarations: number;\n robots_declarations: number;\n duplicate_fields: number;\n conflicting_fields: number;\n unresolved_canonicals: number;\n cross_field_review_leads: number;\n extraction_limited: boolean;\n};\nexport type MetadataReview = {\n scope: \"caller_supplied_same_origin_metadata_only\";\n pages_sampled: number;\n origin: string;\n duplicate_declaration_fields: number;\n conflicting_declaration_fields: number;\n unresolved_canonical_references: number;\n explicit_robots_conflicts: number;\n cross_field_review_leads: number;\n duplicate_title_groups: number;\n duplicate_description_groups: number;\n excluded_annotated_canonicals: number;\n pages: MetadataPageReview[];\n coverage_limited: true;\n limitations: string[];\n total_findings: number;\n findings: MetadataIssue[];\n findings_truncated: boolean;\n};\n\nexport function safeMetadataLabel(raw: string): string | undefined {\n if (!raw || raw.length > 512) return undefined;\n try {\n const url = new URL(raw);\n if (![\"http:\", \"https:\"].includes(url.protocol) || !url.hostname || url.username ||\n url.password || url.search || url.hash || url.port || url.hostname.length > 180) return;\n return url.href;\n } catch {\n return undefined;\n }\n}\nfunction normalizedText(value: string): string {\n return value.normalize(\"NFKC\").replace(/\\s+/gu, \" \").trim().toLocaleLowerCase(\"en\");\n}\nfunction normalizedUrl(value: string, base: string): string | undefined {\n if (!value || value.length > 1024) return undefined;\n try {\n const url = new URL(value, base);\n if (![\"http:\", \"https:\"].includes(url.protocol) || !url.hostname ||\n url.username || url.password || url.hash) return undefined;\n return url.href;\n } catch {\n return undefined;\n }\n}\nfunction robotsTokens(raw: string): string[] {\n return raw.toLocaleLowerCase(\"en\").split(\",\")\n .map((piece) => piece.trim().replace(/\\s*:\\s*/gu, \":\").replace(/\\s+/gu, \" \"))\n .filter(Boolean)\n .flatMap((piece) => piece === \"none\" ? [\"noindex\", \"nofollow\"]\n : piece === \"all\" ? [\"index\", \"follow\"] : [piece]);\n}\nfunction robotsParts(raw: string): Set<string> {\n return new Set(robotsTokens(raw).map((token) => token.split(/[:\\s]/u)[0]));\n}\nfunction normalizedRobots(raw: string): string {\n return [...new Set(robotsTokens(raw))].sort().join(\",\");\n}\nfunction robotsDeclarationConflict(rawValues: readonly string[]): boolean {\n const tokens = new Set(rawValues.flatMap(robotsTokens));\n const parts = new Set([...tokens].map((token) => token.split(/[:\\s]/u)[0]));\n if ((parts.has(\"index\") && parts.has(\"noindex\")) ||\n (parts.has(\"follow\") && parts.has(\"nofollow\"))) return true;\n const byDirective = new Map<string, string>();\n for (const token of tokens) {\n const key = token.split(/[:\\s]/u)[0];\n const existing = byDirective.get(key);\n if (existing && existing !== token) return true;\n byDirective.set(key, token);\n }\n return false;\n}\n\nexport function emptyMetadataReview(): MetadataReview {\n return {\n scope: \"caller_supplied_same_origin_metadata_only\",\n pages_sampled: 0, origin: \"\", duplicate_declaration_fields: 0,\n conflicting_declaration_fields: 0, unresolved_canonical_references: 0,\n explicit_robots_conflicts: 0, cross_field_review_leads: 0,\n duplicate_title_groups: 0, duplicate_description_groups: 0,\n excluded_annotated_canonicals: 0, pages: [], coverage_limited: true,\n limitations: [\"The supplied metadata sample could not be compared within its limits.\"],\n total_findings: 0, findings: [], findings_truncated: false,\n };\n}\n\nexport function analyzeMetadataConsistency(observations: readonly MetadataObservation[]): MetadataReview {\n if (!observations.length || observations.length > MAX_METADATA_PAGES) {\n throw new Error(\"Supply one to eight metadata observations.\");\n }\n const pages = observations.map((observation) => safeMetadataLabel(observation.url));\n if (pages.some((url) => !url) || new Set(pages).size !== pages.length) {\n throw new Error(\"Page labels must be distinct safe HTTP(S) URLs.\");\n }\n const origin = new URL(pages[0]!).origin;\n if (pages.some((url) => new URL(url!).origin !== origin)) {\n throw new Error(\"All supplied page URLs must share one exact origin.\");\n }\n const findings: MetadataIssue[] = [];\n const pageSummaries: MetadataPageReview[] = [];\n const identities: string[] = [];\n let duplicates = 0, conflicts = 0, unresolved = 0, robotsConflicts = 0;\n let crossField = 0, excluded = 0;\n let extractionLimited = false;\n\n function add(code: MetadataFindingCode, severity: MetadataIssue[\"severity\"],\n page: number, field: MetadataField, count: number, message: string,\n confidence: MetadataIssue[\"confidence\"] = \"review\", related_pages?: number[]) {\n findings.push({\n code, severity, confidence, source_page: page, field, count, message,\n ...(related_pages?.length ? { related_pages: related_pages.slice(0, MAX_METADATA_PAGES - 1) } : {}),\n });\n }\n for (const [i, sample] of observations.entries()) {\n const page = i + 1;\n const input = sample.values;\n const stats: MetadataPageReview = {\n page, fields_present: 0,\n title_declarations: input.title.length,\n description_declarations: input.description.length,\n canonical_declarations: input.canonical.length,\n robots_declarations: input.robots.length + input.googlebot.length,\n duplicate_fields: 0, conflicting_fields: 0,\n unresolved_canonicals: 0, cross_field_review_leads: 0,\n extraction_limited: sample.extraction_limited,\n };\n excluded += sample.excluded_canonicals;\n let base = pages[i]!;\n if (sample.base_href) {\n const resolved = normalizedUrl(sample.base_href, base);\n // Relative canonicals with an unresolvable <base> are never compared\n // against the document URL as if the override did not exist.\n base = resolved ?? \"\";\n if (!resolved) extractionLimited = true;\n }\n const canonicalTargets: string[] = [];\n for (const raw of input.canonical.slice(0, MAX_METADATA_VALUES)) {\n const parsed = base ? normalizedUrl(raw, base) : undefined;\n if (parsed) canonicalTargets.push(parsed);\n else {\n unresolved += 1;\n stats.unresolved_canonicals += 1;\n }\n }\n if (stats.unresolved_canonicals) add(\"unresolved_canonical\", \"info\", page,\n \"canonical\", stats.unresolved_canonicals,\n \"An explicit canonical preference could not be compared safely; invalid, fragment-bearing, credentialed or unresolved URLs remain unverified.\");\n\n const norm: Partial<Record<MetadataField, string[]>> = {};\n for (const field of METADATA_FIELDS) {\n const original = input[field].slice(0, MAX_METADATA_VALUES);\n if (original.length) stats.fields_present += 1;\n const values = field === \"canonical\" ? canonicalTargets\n : field === \"og:url\" ? original.map((value) => normalizedUrl(value, pages[i]!) ?? \"\").filter(Boolean)\n : field === \"robots\" || field === \"googlebot\" ? original.map(normalizedRobots)\n : original.map(normalizedText);\n norm[field] = values;\n if (values.length < 2) continue;\n const distinct = new Set(values);\n if (distinct.size > 1) {\n // Complementary robots declarations (e.g. separate noindex and\n // nofollow tags) are not contradictory just because text differs.\n if ((field === \"robots\" || field === \"googlebot\") &&\n !robotsDeclarationConflict(original)) continue;\n conflicts += 1;\n stats.conflicting_fields += 1;\n add(\"conflicting_declaration\", \"warning\", page, field, values.length,\n \"Multiple nonidentical declarations for the same metadata field were observed in the supplied HTML; review which value is intended.\", \"observed\");\n } else {\n duplicates += 1;\n stats.duplicate_fields += 1;\n add(\"duplicate_declaration\", \"info\", page, field, values.length,\n \"The same metadata field is declared repeatedly with equivalent normalized values; this may be redundant but is not necessarily an SEO error.\", \"observed\");\n }\n }\n const allRobots = input.robots.map(robotsParts);\n const allGooglebot = input.googlebot.map(robotsParts);\n const generic = new Set(allRobots.flatMap((v) => [...v]));\n const specific = new Set(allGooglebot.flatMap((v) => [...v]));\n // Check all declarations for each agent, not just contradictions within\n // a single comma-delimited meta tag.\n const contradicts = (parts: Set<string>) =>\n (parts.has(\"index\") && parts.has(\"noindex\")) ||\n (parts.has(\"follow\") && parts.has(\"nofollow\"));\n const contradictions = contradicts(generic) || contradicts(specific);\n // Generic directives can apply to Googlebot, but a more restrictive\n // directive or agent-specific instruction may intentionally override.\n const crossAgent = (generic.has(\"index\") && specific.has(\"noindex\")) ||\n (generic.has(\"noindex\") && specific.has(\"index\")) ||\n (generic.has(\"follow\") && specific.has(\"nofollow\")) ||\n (generic.has(\"nofollow\") && specific.has(\"follow\"));\n if (contradictions || crossAgent) {\n robotsConflicts += 1;\n add(\"conflicting_robots_directives\", \"info\", page, \"robots\", 1,\n \"Potentially incompatible explicit robots directives were found; agent specificity and most-restrictive behavior need review.\");\n }\n function compare(fieldA: MetadataField, fieldB: MetadataField, message: string,\n code: MetadataFindingCode) {\n const left = norm[fieldA] ?? [];\n const right = norm[fieldB] ?? [];\n // Conflicting multi-valued metadata has its own finding and does not\n // authorize selecting a first value for a secondary comparison.\n if (left.length !== 1 || right.length !== 1 || !left[0] || !right[0]) return;\n if (left[0] !== right[0]) {\n crossField += 1;\n stats.cross_field_review_leads += 1;\n add(code, \"info\", page, fieldB, 1, message);\n }\n }\n compare(\"title\", \"og:title\",\n \"The title and Open Graph title differ as normalized text; social titles can intentionally differ from search titles.\",\n \"title_social_difference\");\n compare(\"description\", \"og:description\",\n \"The meta description and Open Graph description differ; social and search snippets can legitimately be tailored.\",\n \"description_social_difference\");\n compare(input[\"og:title\"].length ? \"og:title\" : \"title\", \"twitter:title\",\n \"The Twitter title differs from the available Open Graph or page title; social presentation can intentionally differ.\",\n \"title_social_difference\");\n compare(input[\"og:description\"].length ? \"og:description\" : \"description\", \"twitter:description\",\n \"The Twitter description differs from the available Open Graph or meta description; social presentation can intentionally differ.\",\n \"description_social_difference\");\n // An invalid second declaration does not make the remaining canonical\n // an unambiguous preference. Do not silently select a \"surviving\" value.\n const unambiguousCanonical = input.canonical.length === 1 && canonicalTargets.length === 1\n ? canonicalTargets[0] : undefined;\n const ogUrl = input[\"og:url\"].length === 1 ? normalizedUrl(input[\"og:url\"][0], pages[i]!) : undefined;\n if (unambiguousCanonical && ogUrl && unambiguousCanonical !== ogUrl) {\n crossField += 1;\n stats.cross_field_review_leads += 1;\n add(\"canonical_social_url_difference\", \"info\", page, \"og:url\", 1,\n \"The declared canonical preference and Open Graph URL point to different URLs; social URL selection and Google canonicalization are separate mechanisms.\");\n }\n identities.push(unambiguousCanonical ?? pages[i]!);\n if (sample.extraction_limited || input.canonical.length > MAX_METADATA_VALUES) {\n extractionLimited = true;\n add(\"truncated_metadata_sample\", \"info\", page, \"title\", 1,\n \"The static metadata declaration sample reached an extraction cap; further values are unverified.\");\n }\n pageSummaries.push(stats);\n }\n\n function duplicatesAcross(field: \"title\" | \"description\", code: MetadataFindingCode): number {\n const groups = new Map<string, number[]>();\n for (const [i, sample] of observations.entries()) {\n const raw = sample.values[field];\n if (raw.length !== 1) continue;\n const value = normalizedText(raw[0]);\n if (!value) continue;\n const pages = groups.get(value) ?? [];\n pages.push(i);\n groups.set(value, pages);\n }\n let count = 0;\n for (const group of groups.values()) {\n if (group.length < 2 || new Set(group.map((index) => identities[index])).size < 2) continue;\n count += 1;\n add(code, \"info\", group[0] + 1, field, group.length,\n \"Different sampled pages with distinct declared canonical preferences or URL labels share equivalent metadata text; this can be intentional for variants and is only a review lead.\",\n \"review\", group.slice(1).map((value) => value + 1));\n }\n return count;\n }\n const duplicateTitleGroups = duplicatesAcross(\"title\", \"duplicate_title_across_pages\");\n const duplicateDescriptionGroups = duplicatesAcross(\"description\", \"duplicate_description_across_pages\");\n const rank = { warning: 0, info: 1 };\n findings.sort((a, b) => rank[a.severity] - rank[b.severity] ||\n a.source_page - b.source_page || a.code.localeCompare(b.code) || a.field.localeCompare(b.field));\n return {\n scope: \"caller_supplied_same_origin_metadata_only\",\n pages_sampled: observations.length,\n origin,\n duplicate_declaration_fields: duplicates,\n conflicting_declaration_fields: conflicts,\n unresolved_canonical_references: unresolved,\n explicit_robots_conflicts: robotsConflicts,\n cross_field_review_leads: crossField,\n duplicate_title_groups: duplicateTitleGroups,\n duplicate_description_groups: duplicateDescriptionGroups,\n excluded_annotated_canonicals: excluded,\n pages: pageSummaries,\n coverage_limited: true,\n limitations: [\n \"Only caller-supplied same-origin static HTML metadata was compared; no web requests, redirects, HTTP headers, rendered content, Google-selected canonicals, search results, or indexing data were inspected.\",\n \"Conflicting declarations are on-page evidence; differences between search and social metadata, repeated titles/descriptions, and robots hints are contextual review leads, not automatic SEO violations.\",\n \"Canonical preferences are hints, not verified selected canonicals. Canonical chains/cycles and live indexability remain the existing independent graph/status tools' responsibility.\",\n ...(extractionLimited || excluded\n ? [\"Some declarations were excluded or capped, including annotated canonicals; omitted metadata is unverified.\"] : []),\n ],\n total_findings: findings.length,\n findings: findings.slice(0, MAX_METADATA_FINDINGS),\n findings_truncated: findings.length > MAX_METADATA_FINDINGS,\n };\n}\n"]}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* P1-04: explicit first-party landing-page promises versus the MCP runtime's
|
|
3
|
+
* actual registered tool metadata. This intentionally does not claim that a
|
|
4
|
+
* listed tool has succeeded on a particular URL or that prose can be judged
|
|
5
|
+
* semantically from a few keywords.
|
|
6
|
+
*/
|
|
7
|
+
export type ProductSurface = "hosted" | "local";
|
|
8
|
+
export interface ToolCatalogEvidence {
|
|
9
|
+
name: string;
|
|
10
|
+
readOnlyHint?: boolean;
|
|
11
|
+
maxPages?: number;
|
|
12
|
+
maxLinks?: number;
|
|
13
|
+
}
|
|
14
|
+
export interface ProductClaimObservation {
|
|
15
|
+
hasMain: boolean;
|
|
16
|
+
hostedSectionFound: boolean;
|
|
17
|
+
localSectionFound: boolean;
|
|
18
|
+
hostedTools: string[];
|
|
19
|
+
localTools: string[];
|
|
20
|
+
siteBatchLimit?: number;
|
|
21
|
+
localScreenshotClaim: boolean;
|
|
22
|
+
hostedReadOnlyClaim: boolean;
|
|
23
|
+
hostedNoScreenshotsClaim: boolean;
|
|
24
|
+
extractionTruncated: boolean;
|
|
25
|
+
}
|
|
26
|
+
export type ProductClaimCode = "product.tool_missing" | "product.site_batch_overclaim" | "product.site_batch_limit_unknown" | "product.local_screenshot_unverified" | "product.hosted_screenshot_conflict" | "product.read_only_conflict" | "product.read_only_unverified";
|
|
27
|
+
export interface ProductClaimFinding {
|
|
28
|
+
code: ProductClaimCode;
|
|
29
|
+
severity: "warning" | "info";
|
|
30
|
+
verdict: "contradicted" | "unverifiable";
|
|
31
|
+
claim: string;
|
|
32
|
+
message: string;
|
|
33
|
+
evidence_tool?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface ProductClaimResult {
|
|
36
|
+
scope: "landing_html_vs_registered_mcp_metadata";
|
|
37
|
+
surface: ProductSurface;
|
|
38
|
+
catalog_available: boolean;
|
|
39
|
+
registered_tools: number;
|
|
40
|
+
tool_claims_checked: number;
|
|
41
|
+
checked_claims: number;
|
|
42
|
+
consistent_claims: number;
|
|
43
|
+
contradicted_claims: number;
|
|
44
|
+
unverified_claims: number;
|
|
45
|
+
advertised_tools: Array<{
|
|
46
|
+
name: string;
|
|
47
|
+
registered: boolean;
|
|
48
|
+
}>;
|
|
49
|
+
site_batch_limit?: {
|
|
50
|
+
advertised: number;
|
|
51
|
+
registered?: number;
|
|
52
|
+
};
|
|
53
|
+
coverage_limited: boolean;
|
|
54
|
+
limitations: string[];
|
|
55
|
+
total_findings: number;
|
|
56
|
+
findings: ProductClaimFinding[];
|
|
57
|
+
findings_truncated: boolean;
|
|
58
|
+
}
|
|
59
|
+
export declare const MAX_PRODUCT_CLAIM_HTML_BYTES = 250000;
|
|
60
|
+
export declare const MAX_PRODUCT_CLAIM_TOOLS = 20;
|
|
61
|
+
export declare const MAX_PRODUCT_CLAIM_FINDINGS = 10;
|
|
62
|
+
export declare function isPublicToolName(value: string): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Take a snapshot of the SDK's runtime registration map. The Zod-to-JSON
|
|
65
|
+
* converter is supplied by each runtime, avoiding dependencies in this core.
|
|
66
|
+
* Missing metadata stays unknown; it must never become a fabricated limit.
|
|
67
|
+
*/
|
|
68
|
+
export declare function registeredToolEvidence(registrations: unknown, toJsonSchema: (schema: unknown) => unknown): ToolCatalogEvidence[];
|
|
69
|
+
/**
|
|
70
|
+
* This check establishes registry consistency only. Do not invent tool
|
|
71
|
+
* behavior, credentials, live health, data-access rights, or page quality.
|
|
72
|
+
*/
|
|
73
|
+
export declare function compareProductClaims(observation: ProductClaimObservation, registered: readonly ToolCatalogEvidence[], surface: ProductSurface): ProductClaimResult;
|