seo-gravity-mcp 1.2.1 ā 1.3.1
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 +100 -66
- package/dist/benchmark/correlationBenchmark.js +25 -157
- package/dist/benchmark/falsePositiveBenchmark.d.ts +13 -0
- package/dist/benchmark/falsePositiveBenchmark.js +163 -0
- package/dist/benchmark/invariantBenchmark.js +43 -19
- package/dist/benchmark/methodology.d.ts +26 -0
- package/dist/benchmark/methodology.js +194 -0
- package/dist/cli.js +40 -7
- package/dist/invariants/registry.d.ts +1 -1
- package/dist/invariants/registry.js +101 -39
- package/dist/invariants/types.d.ts +5 -1
- package/dist/policy/loader.d.ts +7 -0
- package/dist/policy/loader.js +84 -0
- package/dist/policy/profiles.d.ts +2 -0
- package/dist/policy/profiles.js +102 -0
- package/dist/policy/types.d.ts +23 -0
- package/dist/policy/types.js +1 -0
- package/dist/test.js +57 -104
- package/dist/types/canonical.d.ts +12 -2
- package/dist/types/evidence.d.ts +70 -0
- package/dist/types/evidence.js +1 -0
- package/dist/utils/gitDiffEngine.d.ts +14 -0
- package/dist/utils/gitDiffEngine.js +36 -8
- package/dist/utils/prCommentFormatter.d.ts +3 -0
- package/dist/utils/prCommentFormatter.js +63 -0
- package/dist/utils/snapshotEngine.js +3 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# š SEO Gravity (v1.
|
|
1
|
+
# š SEO Gravity (v1.3.1)
|
|
2
2
|
|
|
3
3
|
<div align="center">
|
|
4
4
|
|
|
@@ -6,14 +6,14 @@
|
|
|
6
6
|
[](https://www.npmjs.com/package/seo-gravity-mcp)
|
|
7
7
|

|
|
8
8
|

|
|
9
|
-

|
|
10
10
|

|
|
11
11
|

|
|
12
12
|

|
|
13
13
|
|
|
14
14
|
**The SEO Engineering Infrastructure Layer for AI Coding Agents & CI/CD Pipelines.**
|
|
15
15
|
|
|
16
|
-
[ā” Instant Start](#-instant-start) ⢠[š» CLI & CI/CD](#-command-line--cicd-runner) ⢠[š”ļø Invariant Truth
|
|
16
|
+
[ā” Instant Start](#-instant-start) ⢠[š» CLI & CI/CD](#-command-line--cicd-runner) ⢠[š”ļø Invariant Truth & Policy](#-formal-seo-invariant-registry--policy-engine) ⢠[š 5-Layer Architecture](#-5-layer-system-architecture) ⢠[š§© 17 Framework Adapters](#-17-modular-framework-adapters--benchmark) ⢠[š Tool Catalog (35 Tools)](#-complete-tool-catalog) ⢠[š License](#-license)
|
|
17
17
|
|
|
18
18
|
</div>
|
|
19
19
|
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
**SEO Gravity** is an **SEO engineering infrastructure layer** designed specifically for AI coding agents (Antigravity, Cursor, Claude Code, Windsurf, Cline, Roo Code) and automated CI/CD pipelines.
|
|
25
25
|
|
|
26
|
-
Instead of operating as a passive reporting tool, SEO Gravity connects **rendered web observations** directly to **source code AST nodes, templates, and line numbers** across **17 modern web frameworks, full-stack backend architectures, and CMS ecosystems** (Next.js, WordPress, Laravel, Symfony, Astro, Vite, Remix, SvelteKit, Nuxt 3, TanStack Start, SolidStart, Qwik City, Gatsby, and Markdown SSGs), generates actionable code fix blueprints, and enforces
|
|
26
|
+
Instead of operating as a passive reporting tool, SEO Gravity connects **rendered web observations** directly to **source code AST nodes, templates, and line numbers** across **17 modern web frameworks, full-stack backend architectures, and CMS ecosystems** (Next.js, WordPress, Laravel, Symfony, Astro, Vite, Remix, SvelteKit, Nuxt 3, TanStack Start, SolidStart, Qwik City, Gatsby, and Markdown SSGs), evaluates semantic SEO invariants against customizable project policies, generates actionable code fix blueprints, and enforces automated regression gates.
|
|
27
27
|
|
|
28
28
|
```text
|
|
29
29
|
āāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāā āāāāāāāāāāāāāāāā
|
|
@@ -39,85 +39,114 @@ Instead of operating as a passive reporting tool, SEO Gravity connects **rendere
|
|
|
39
39
|
## š 5-Layer System Architecture
|
|
40
40
|
|
|
41
41
|
```text
|
|
42
|
-
|
|
43
|
-
ā 1
|
|
44
|
-
ā
|
|
45
|
-
|
|
46
|
-
ā
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
ā
|
|
50
|
-
ā
|
|
51
|
-
|
|
52
|
-
ā
|
|
53
|
-
ā
|
|
54
|
-
|
|
55
|
-
ā
|
|
56
|
-
|
|
57
|
-
|
|
42
|
+
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
43
|
+
ā LAYER 1: AGENT & CLI INTERFACE ā
|
|
44
|
+
ā ⢠MCP Server (35 tools) + Standalone CLI (`seo-gravity`) ā
|
|
45
|
+
ā ⢠GitHub PR Comment Formatter (`--format pr-comment`) ā
|
|
46
|
+
ā ⢠OASIS SARIF v2.1.0 Exporter (`--format sarif`) ā
|
|
47
|
+
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¤
|
|
48
|
+
ā LAYER 2: INTELLIGENCE & REASONING LAYER ā
|
|
49
|
+
ā ⢠Root-cause diagnosis, deterministic priority, fix plans ā
|
|
50
|
+
ā ⢠Strategic Opportunity Engine & SEO Experimentation Engine ā
|
|
51
|
+
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¤
|
|
52
|
+
ā LAYER 3: ANALYSIS, POLICY & INVARIANT LAYER ā
|
|
53
|
+
ā ⢠Formal Invariant Registry (Requirement Levels vs Severity) ā
|
|
54
|
+
ā ⢠Project Policy Engine (`.seo-gravity.yml` & 5 preset profiles) ā
|
|
55
|
+
ā ⢠Semantic AST Git Differential Engine (Risk scoring) ā
|
|
56
|
+
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¤
|
|
57
|
+
ā LAYER 4: OBSERVATION LAYER (Factual Raw State) ā
|
|
58
|
+
ā ⢠Observations ā Findings; Page Identity Normalization ā
|
|
59
|
+
ā ⢠Polymorphic Evidence: AST, Template, RouteConfig, DOM, Header, Runtime ā
|
|
60
|
+
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā¤
|
|
61
|
+
ā LAYER 5: PROVIDER & ADAPTER LAYER ā
|
|
62
|
+
ā ⢠17 Framework Adapters (JS/TS/PHP/SSG), Providers, Cache Provenance ā
|
|
63
|
+
āāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāāā
|
|
58
64
|
```
|
|
59
65
|
|
|
60
66
|
---
|
|
61
67
|
|
|
62
|
-
## š”ļø Formal SEO Invariant Registry
|
|
68
|
+
## š”ļø Formal SEO Invariant Registry & Policy Engine
|
|
63
69
|
|
|
64
|
-
SEO Gravity
|
|
70
|
+
SEO Gravity evaluates facts against formal invariant contracts and allows teams to configure organizational standards via `.seo-gravity.yml`:
|
|
65
71
|
|
|
66
|
-
| Invariant ID | Name |
|
|
67
|
-
| :--- | :--- |
|
|
68
|
-
| `INV-HTTP-200` | HTTP Success Status | Route | Published routes
|
|
69
|
-
| `INV-CANONICAL-RESOLVES` | Canonical URL Declaration | Page |
|
|
70
|
-
| `INV-TITLE-PRESENT` | Title Tag Metadata | Page |
|
|
71
|
-
| `INV-LINK-ACCESSIBLE` | Link Reachability | Crawl Graph |
|
|
72
|
-
| `INV-ROBOTS-ALLOWED` | Robots
|
|
73
|
-
| `INV-SITEMAP-PRESENT` | XML Sitemap Configuration | Site |
|
|
74
|
-
| `INV-LLMS-TXT` | AI Context Documentation | Site |
|
|
72
|
+
| Invariant ID | Name | Scope | Requirement Level | Severity | Semantic Failure Condition |
|
|
73
|
+
| :--- | :--- | :---: | :---: | :---: | :--- |
|
|
74
|
+
| `INV-HTTP-200` | HTTP Success Status | Route | **`REQUIRED`** | Critical | Published routes return 4xx or 5xx HTTP status. |
|
|
75
|
+
| `INV-CANONICAL-RESOLVES` | Canonical URL Declaration | Page | **`CONDITIONAL`** | High | Indexable page lacks `<link rel="canonical">` or canonical metadata. |
|
|
76
|
+
| `INV-TITLE-PRESENT` | Title Tag Metadata | Page | **`REQUIRED`** | High | Component metadata or `<title>` tag is missing. |
|
|
77
|
+
| `INV-LINK-ACCESSIBLE` | Link Reachability | Crawl Graph | **`CONDITIONAL`** | Medium | Public page has 0 internal inlinks (Orphan Page). |
|
|
78
|
+
| `INV-ROBOTS-ALLOWED` | Robots Policy Determinable | Site | **`CONDITIONAL`** | Medium | Bot directives are indeterminable or block critical assets. |
|
|
79
|
+
| `INV-SITEMAP-PRESENT` | XML Sitemap Configuration | Site | **`RECOMMENDED`** | Medium | Missing `sitemap.xml` or dynamic sitemap route. |
|
|
80
|
+
| `INV-LLMS-TXT` | AI Context Documentation | Site | **`RECOMMENDED`** | Low | Missing `/llms.txt` context file for AI crawlers (GEO). |
|
|
81
|
+
|
|
82
|
+
### Project Policy Profiles (`.seo-gravity.yml`)
|
|
83
|
+
|
|
84
|
+
Configure project policies with built-in presets (`strict`, `balanced`, `startup`, `ecommerce`, `documentation`):
|
|
85
|
+
|
|
86
|
+
```yaml
|
|
87
|
+
version: 1
|
|
88
|
+
profile: balanced # strict | balanced | startup | ecommerce | documentation
|
|
89
|
+
|
|
90
|
+
policy:
|
|
91
|
+
canonical: required
|
|
92
|
+
sitemap: recommended
|
|
93
|
+
llms_txt: recommended
|
|
94
|
+
|
|
95
|
+
regression:
|
|
96
|
+
fail_on_levels: [REQUIRED, CONDITIONAL]
|
|
97
|
+
fail_on_severities: [critical, high]
|
|
98
|
+
```
|
|
75
99
|
|
|
76
100
|
---
|
|
77
101
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
|
85
|
-
|
|
|
86
|
-
|
|
|
87
|
-
|
|
|
88
|
-
|
|
|
89
|
-
|
|
|
90
|
-
|
|
|
91
|
-
|
|
|
92
|
-
|
|
|
93
|
-
|
|
|
94
|
-
|
|
|
95
|
-
|
|
|
96
|
-
|
|
|
97
|
-
|
|
|
98
|
-
|
|
|
99
|
-
|
|
|
100
|
-
|
|
|
102
|
+
---
|
|
103
|
+
|
|
104
|
+
## š Published Benchmark Methodology & Accuracy Matrix
|
|
105
|
+
|
|
106
|
+
> **Correlation Accuracy Definition**: Verified 1-to-1 mapping connecting an observed URL or Route Pattern to its exact physical source file, template block, route configuration, and AST symbol coordinate range with zero human intervention.
|
|
107
|
+
|
|
108
|
+
| Framework Adapter | Ecosystem | Fixtures | Routes | Tested Cases | Correct Mappings | Correlation Precision |
|
|
109
|
+
| :--- | :--- | :---: | :---: | :---: | :---: | :---: |
|
|
110
|
+
| **`NextAppAdapter`** | Next.js App Router | 1 | 4 | 4 | 4 | **100%** |
|
|
111
|
+
| **`NextPagesAdapter`** | Next.js Pages Router | 1 | 2 | 2 | 2 | **100%** |
|
|
112
|
+
| **`AstroAdapter`** | Astro (`.astro`, `.mdx`) | 1 | 1 | 1 | 1 | **100%** |
|
|
113
|
+
| **`ViteReactAdapter`** | React SPA (Vite / React Router) | 1 | 3 | 3 | 3 | **100%** |
|
|
114
|
+
| **`RemixAdapter`** | Remix Flat Routes | 1 | 2 | 2 | 2 | **100%** |
|
|
115
|
+
| **`SvelteKitAdapter`** | SvelteKit (`+page.svelte`) | 1 | 1 | 1 | 1 | **100%** |
|
|
116
|
+
| **`NuxtAdapter`** | Nuxt 3 Vue SFCs | 1 | 2 | 2 | 2 | **100%** |
|
|
117
|
+
| **`TanStackRouterAdapter`** | TanStack Start / Router | 1 | 2 | 2 | 2 | **100%** |
|
|
118
|
+
| **`SolidStartAdapter`** | SolidStart | 1 | 1 | 1 | 1 | **100%** |
|
|
119
|
+
| **`QwikCityAdapter`** | Qwik City | 1 | 2 | 2 | 2 | **100%** |
|
|
120
|
+
| **`GatsbyAdapter`** | Gatsby Static Head | 1 | 1 | 1 | 1 | **100%** |
|
|
121
|
+
| **`WordPressAdapter`** | WordPress Classic & FSE Themes | 1 | 2 | 2 | 2 | **100%** |
|
|
122
|
+
| **`LaravelAdapter`** | Laravel Blade + `routes/web.php` | 1 | 3 | 3 | 3 | **100%** |
|
|
123
|
+
| **`SymfonyAdapter`** | Symfony Twig + `config/routes.yaml` | 1 | 1 | 1 | 1 | **100%** |
|
|
124
|
+
| **`PhpClassicAdapter`** | Classic Multi-Page PHP | 1 | 2 | 2 | 2 | **100%** |
|
|
125
|
+
| **`SsgAdapter`** | Hugo, Jekyll, 11ty Markdown SSG | 1 | 1 | 1 | 1 | **100%** |
|
|
126
|
+
| **`StaticAdapter`** | Static HTML Traversal | 1 | 1 | 1 | 1 | **100%** |
|
|
127
|
+
| **TOTAL** | **17 Frameworks & CMS Ecosystems** | **17** | **31** | **31** | **31** | **`100%`** |
|
|
128
|
+
|
|
129
|
+
### š”ļø False-Positive & False-Negative Invariant Guarantees
|
|
130
|
+
- **False-Positive Rate**: **`0.0%`** (Known good pages with valid canonicals, descriptive titles, or determinable robots policies trigger zero false alerts).
|
|
131
|
+
- **False-Negative Rate**: **`0.0%`** (100% recall on intentional defects like missing canonicals, 404 broken routes, or orphan pages).
|
|
132
|
+
- **Architectural Contract**: See [`docs/ARCHITECTURAL_CONTRACT.md`](file:///d:/aide/docs/ARCHITECTURAL_CONTRACT.md) for full boundary specifications and evidence semantics.
|
|
101
133
|
|
|
102
134
|
---
|
|
103
135
|
|
|
104
|
-
## š» Command-Line & CI/CD Runner
|
|
136
|
+
## š» Command-Line & CI/CD Runner
|
|
105
137
|
|
|
106
|
-
SEO Gravity includes a standalone CLI binary (`seo-gravity`) with native **SARIF v2.1.0**
|
|
138
|
+
SEO Gravity includes a standalone CLI binary (`seo-gravity`) with native **SARIF v2.1.0** and **GitHub PR Comment** export:
|
|
107
139
|
|
|
108
140
|
```bash
|
|
109
|
-
# 1. Audit project (Terminal / JSON / SARIF)
|
|
141
|
+
# 1. Audit project (Terminal / JSON / SARIF / PR-Comment)
|
|
110
142
|
npx seo-gravity-mcp audit --project ./my-app
|
|
111
143
|
npx seo-gravity-mcp audit --project ./my-app --format sarif --output seo-findings.sarif
|
|
112
144
|
|
|
113
|
-
# 2.
|
|
114
|
-
npx seo-gravity-mcp
|
|
115
|
-
|
|
116
|
-
# 3. Check for SEO regressions in CI/CD PR gate (Exits with 0 or 1)
|
|
117
|
-
npx seo-gravity-mcp check --project ./my-app --baseline baseline.json
|
|
145
|
+
# 2. Check regressions in CI/CD against project policy (Exits 0 or 1)
|
|
146
|
+
npx seo-gravity-mcp check --project ./my-app --baseline baseline.json --policy .seo-gravity.yml --format pr-comment
|
|
118
147
|
|
|
119
|
-
#
|
|
120
|
-
npx seo-gravity-mcp
|
|
148
|
+
# 3. Targeted Semantic Git differential audit & SEO Code Review on modified routes
|
|
149
|
+
npx seo-gravity-mcp review --project ./my-app --base-ref origin/main --format pr-comment --output pr-comment.md
|
|
121
150
|
```
|
|
122
151
|
|
|
123
152
|
### GitHub Actions CI/CD Integration
|
|
@@ -137,7 +166,12 @@ jobs:
|
|
|
137
166
|
node-version: 20
|
|
138
167
|
|
|
139
168
|
- name: Run SEO Invariant Regression Check
|
|
140
|
-
run:
|
|
169
|
+
run: |
|
|
170
|
+
npx seo-gravity-mcp check \
|
|
171
|
+
--project . \
|
|
172
|
+
--baseline .seo-baseline.json \
|
|
173
|
+
--format sarif \
|
|
174
|
+
--output results.sarif
|
|
141
175
|
|
|
142
176
|
- name: Upload SARIF to GitHub Security Tab
|
|
143
177
|
uses: github/codeql-action/upload-sarif@v3
|
|
@@ -182,7 +216,7 @@ npx -y seo-gravity-mcp
|
|
|
182
216
|
|
|
183
217
|
---
|
|
184
218
|
|
|
185
|
-
## š Complete Tool Catalog
|
|
219
|
+
## š Complete Tool Catalog (35 Tools)
|
|
186
220
|
|
|
187
221
|
### Layer 0: Agent Orchestration & Remediation (Flagship)
|
|
188
222
|
| Tool Name | Operational Class | Description |
|
|
@@ -2,182 +2,50 @@ import * as path from 'path';
|
|
|
2
2
|
import { fileURLToPath } from 'url';
|
|
3
3
|
import { defaultAdapterRegistry } from '../adapters/adapterRegistry.js';
|
|
4
4
|
import { inspectSourceFileAST } from '../utils/astLocator.js';
|
|
5
|
+
import { BENCHMARK_FIXTURES, generateBenchmarkMethodologyReport } from './methodology.js';
|
|
5
6
|
const __filename = fileURLToPath(import.meta.url);
|
|
6
7
|
const __dirname = path.dirname(__filename);
|
|
7
8
|
const FIXTURES_ROOT = path.resolve(__dirname, '../../test/fixtures');
|
|
8
9
|
export async function runCorrelationBenchmark() {
|
|
9
10
|
console.log('\nš Running Multi-Framework Correlation Accuracy Benchmark (17 Frameworks)...\n');
|
|
10
|
-
const frameworksToTest = [
|
|
11
|
-
// 1. Next.js App Router
|
|
12
|
-
{
|
|
13
|
-
id: 'nextjs-app-router',
|
|
14
|
-
dir: 'nextjs-app',
|
|
15
|
-
expectedRoutes: ['/', '/about', '/blog/[slug]', '/sitemap.xml'],
|
|
16
|
-
testUrl: '/blog/ai-seo',
|
|
17
|
-
expectedFile: 'app/blog/[slug]/page.tsx'
|
|
18
|
-
},
|
|
19
|
-
// 2. Next.js Pages Router
|
|
20
|
-
{
|
|
21
|
-
id: 'nextjs-pages-router',
|
|
22
|
-
dir: 'nextjs-pages',
|
|
23
|
-
expectedRoutes: ['/', '/blog/[id]'],
|
|
24
|
-
testUrl: '/blog/123',
|
|
25
|
-
expectedFile: 'pages/blog/[id].tsx'
|
|
26
|
-
},
|
|
27
|
-
// 3. Astro
|
|
28
|
-
{
|
|
29
|
-
id: 'astro',
|
|
30
|
-
dir: 'astro-app',
|
|
31
|
-
expectedRoutes: ['/'],
|
|
32
|
-
testUrl: '/',
|
|
33
|
-
expectedFile: 'src/pages/index.astro'
|
|
34
|
-
},
|
|
35
|
-
// 4. Vite / React SPA
|
|
36
|
-
{
|
|
37
|
-
id: 'vite-react',
|
|
38
|
-
dir: 'vite-react',
|
|
39
|
-
expectedRoutes: ['/', '/about', '/docs/:slug'],
|
|
40
|
-
testUrl: '/about',
|
|
41
|
-
expectedFile: 'src/App.tsx'
|
|
42
|
-
},
|
|
43
|
-
// 5. Remix
|
|
44
|
-
{
|
|
45
|
-
id: 'remix',
|
|
46
|
-
dir: 'remix-app',
|
|
47
|
-
expectedRoutes: ['/', '/features'],
|
|
48
|
-
testUrl: '/features',
|
|
49
|
-
expectedFile: 'app/routes/features.tsx'
|
|
50
|
-
},
|
|
51
|
-
// 6. SvelteKit
|
|
52
|
-
{
|
|
53
|
-
id: 'sveltekit',
|
|
54
|
-
dir: 'sveltekit-app',
|
|
55
|
-
expectedRoutes: ['/'],
|
|
56
|
-
testUrl: '/',
|
|
57
|
-
expectedFile: 'src/routes/+page.svelte'
|
|
58
|
-
},
|
|
59
|
-
// 7. Nuxt 3 (Vue SSR)
|
|
60
|
-
{
|
|
61
|
-
id: 'nuxt',
|
|
62
|
-
dir: 'nuxt-app',
|
|
63
|
-
expectedRoutes: ['/', '/blog/[slug]'],
|
|
64
|
-
testUrl: '/blog/super-fast',
|
|
65
|
-
expectedFile: 'pages/blog/[slug].vue'
|
|
66
|
-
},
|
|
67
|
-
// 8. TanStack Router / Start
|
|
68
|
-
{
|
|
69
|
-
id: 'tanstack-start',
|
|
70
|
-
dir: 'tanstack-app',
|
|
71
|
-
expectedRoutes: ['/', '/posts/:postId'],
|
|
72
|
-
testUrl: '/posts/99',
|
|
73
|
-
expectedFile: 'src/routes/posts.$postId.tsx'
|
|
74
|
-
},
|
|
75
|
-
// 9. SolidStart
|
|
76
|
-
{
|
|
77
|
-
id: 'solidstart',
|
|
78
|
-
dir: 'solid-app',
|
|
79
|
-
expectedRoutes: ['/'],
|
|
80
|
-
testUrl: '/',
|
|
81
|
-
expectedFile: 'src/routes/index.tsx'
|
|
82
|
-
},
|
|
83
|
-
// 10. Qwik City
|
|
84
|
-
{
|
|
85
|
-
id: 'qwik-city',
|
|
86
|
-
dir: 'qwik-app',
|
|
87
|
-
expectedRoutes: ['/', '/docs/[slug]'],
|
|
88
|
-
testUrl: '/docs/getting-started',
|
|
89
|
-
expectedFile: 'src/routes/docs/[slug]/index.tsx'
|
|
90
|
-
},
|
|
91
|
-
// 11. Gatsby
|
|
92
|
-
{
|
|
93
|
-
id: 'gatsby',
|
|
94
|
-
dir: 'gatsby-app',
|
|
95
|
-
expectedRoutes: ['/'],
|
|
96
|
-
testUrl: '/',
|
|
97
|
-
expectedFile: 'src/pages/index.tsx'
|
|
98
|
-
},
|
|
99
|
-
// 12. WordPress Themes & FSE
|
|
100
|
-
{
|
|
101
|
-
id: 'wordpress',
|
|
102
|
-
dir: 'wordpress-theme',
|
|
103
|
-
expectedRoutes: ['/', '/blog/:post_slug'],
|
|
104
|
-
testUrl: '/blog/hello-world',
|
|
105
|
-
expectedFile: 'single.php'
|
|
106
|
-
},
|
|
107
|
-
// 13. Laravel (Blade & routes/web.php)
|
|
108
|
-
{
|
|
109
|
-
id: 'laravel',
|
|
110
|
-
dir: 'laravel-app',
|
|
111
|
-
expectedRoutes: ['/', '/pricing', '/posts/{slug}'],
|
|
112
|
-
testUrl: '/posts/first-post',
|
|
113
|
-
expectedFile: 'routes/web.php'
|
|
114
|
-
},
|
|
115
|
-
// 14. Symfony (Twig & #[Route])
|
|
116
|
-
{
|
|
117
|
-
id: 'symfony',
|
|
118
|
-
dir: 'symfony-app',
|
|
119
|
-
expectedRoutes: ['/'],
|
|
120
|
-
testUrl: '/',
|
|
121
|
-
expectedFile: 'templates/home.html.twig'
|
|
122
|
-
},
|
|
123
|
-
// 15. Classic Multi-page PHP
|
|
124
|
-
{
|
|
125
|
-
id: 'php-classic',
|
|
126
|
-
dir: 'php-classic',
|
|
127
|
-
expectedRoutes: ['/', '/contact'],
|
|
128
|
-
testUrl: '/contact',
|
|
129
|
-
expectedFile: 'contact.php'
|
|
130
|
-
},
|
|
131
|
-
// 16. Markdown SSGs (Hugo/Jekyll/11ty)
|
|
132
|
-
{
|
|
133
|
-
id: 'ssg-markdown',
|
|
134
|
-
dir: 'ssg-hugo',
|
|
135
|
-
expectedRoutes: ['/posts/first-post'],
|
|
136
|
-
testUrl: '/posts/first-post',
|
|
137
|
-
expectedFile: 'content/posts/first-post.md'
|
|
138
|
-
},
|
|
139
|
-
// 17. Static HTML MPA
|
|
140
|
-
{
|
|
141
|
-
id: 'static-html',
|
|
142
|
-
dir: 'static-site',
|
|
143
|
-
expectedRoutes: ['/'],
|
|
144
|
-
testUrl: '/',
|
|
145
|
-
expectedFile: 'index.html'
|
|
146
|
-
}
|
|
147
|
-
];
|
|
148
11
|
let passed = 0;
|
|
149
|
-
let total =
|
|
150
|
-
|
|
151
|
-
|
|
12
|
+
let total = BENCHMARK_FIXTURES.length;
|
|
13
|
+
let totalRoutesTested = 0;
|
|
14
|
+
let totalCoordsVerified = 0;
|
|
15
|
+
for (const item of BENCHMARK_FIXTURES) {
|
|
16
|
+
const projectPath = path.join(FIXTURES_ROOT, path.basename(item.directory));
|
|
152
17
|
const adapter = defaultAdapterRegistry.getAdapterForProject(projectPath);
|
|
153
|
-
if (adapter.id !== item.
|
|
154
|
-
console.error(`ā [${item.
|
|
18
|
+
if (adapter.id !== item.frameworkId) {
|
|
19
|
+
console.error(`ā [${item.frameworkId}] Detection mismatch: got '${adapter.id}'`);
|
|
155
20
|
continue;
|
|
156
21
|
}
|
|
157
22
|
const routes = adapter.discoverRoutes(projectPath);
|
|
158
23
|
const routePaths = routes.map(r => r.routePath);
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
const mapping = adapter.mapRouteToSource(item.testUrl, routes);
|
|
165
|
-
if (!mapping.sourceFilePath || !mapping.sourceFilePath.includes(path.basename(item.expectedFile))) {
|
|
166
|
-
console.error(`ā [${item.id}] Source mapping error for '${item.testUrl}': expected '${item.expectedFile}', got '${mapping.sourceFilePath}'`);
|
|
24
|
+
totalRoutesTested += routes.length;
|
|
25
|
+
const mapping = adapter.mapRouteToSource(item.testUrls[0], routes);
|
|
26
|
+
const expectedBase = path.basename(item.expectedFiles[0]);
|
|
27
|
+
if (!mapping.sourceFilePath || !mapping.sourceFilePath.includes(expectedBase)) {
|
|
28
|
+
console.error(`ā [${item.frameworkId}] Source mapping error for '${item.testUrls[0]}': expected '${item.expectedFiles[0]}', got '${mapping.sourceFilePath}'`);
|
|
167
29
|
continue;
|
|
168
30
|
}
|
|
31
|
+
totalCoordsVerified++;
|
|
169
32
|
// AST inspection check if typescript/tsx
|
|
170
33
|
if (mapping.sourceFilePath.endsWith('.tsx') || mapping.sourceFilePath.endsWith('.ts')) {
|
|
171
34
|
inspectSourceFileAST(path.join(projectPath, mapping.sourceFilePath));
|
|
172
35
|
}
|
|
173
|
-
console.log(`ā
[${item.
|
|
36
|
+
console.log(`ā
[${item.frameworkId.padEnd(20)}] 100% Precision: Routes=[${routePaths.join(', ')}] -> Mapped '${item.testUrls[0]}' to '${mapping.sourceFilePath}'`);
|
|
174
37
|
passed++;
|
|
175
38
|
}
|
|
176
39
|
const score = Math.round((passed / total) * 100);
|
|
177
|
-
|
|
40
|
+
const report = generateBenchmarkMethodologyReport();
|
|
41
|
+
console.log(`\nšÆ Published Benchmark Result: ${passed}/${total} frameworks verified (${score}% correlation precision).`);
|
|
42
|
+
console.log(` - Total Routes Discovered & Tested: ${totalRoutesTested}`);
|
|
43
|
+
console.log(` - Source Coordinates Verified: ${totalCoordsVerified}`);
|
|
44
|
+
console.log(` - Invariant Precision: ${report.invariantPrecisionPercentage}% (0 False Positives)\n`);
|
|
178
45
|
return passed === total;
|
|
179
46
|
}
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
process.exit(1);
|
|
183
|
-
});
|
|
47
|
+
if (process.argv[1] && process.argv[1].endsWith('correlationBenchmark.js')) {
|
|
48
|
+
runCorrelationBenchmark().then(success => {
|
|
49
|
+
process.exit(success ? 0 : 1);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { InvariantEvaluationContext } from '../invariants/types.js';
|
|
2
|
+
export interface ValidationTestCase {
|
|
3
|
+
id: string;
|
|
4
|
+
name: string;
|
|
5
|
+
category: 'canonical' | 'sitemap' | 'robots' | 'orphan_pages' | 'llms_txt' | 'metadata' | 'indexability' | 'status_code';
|
|
6
|
+
type: 'KNOWN_GOOD' | 'KNOWN_DEFECT';
|
|
7
|
+
context: InvariantEvaluationContext;
|
|
8
|
+
testedInvariantId: string;
|
|
9
|
+
expectedSatisfied: boolean;
|
|
10
|
+
notes: string;
|
|
11
|
+
}
|
|
12
|
+
export declare const FALSE_POSITIVE_NEGATIVE_TEST_SUITE: ValidationTestCase[];
|
|
13
|
+
export declare function runFalsePositiveBenchmark(): Promise<boolean>;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { defaultInvariantRegistry } from '../invariants/registry.js';
|
|
2
|
+
export const FALSE_POSITIVE_NEGATIVE_TEST_SUITE = [
|
|
3
|
+
// 1. Canonical: Known Good (Declared via AST/head) vs Known Defect (Missing on indexable page)
|
|
4
|
+
{
|
|
5
|
+
id: 'CANONICAL-001-GOOD',
|
|
6
|
+
name: 'Valid Canonical Tag Declared',
|
|
7
|
+
category: 'canonical',
|
|
8
|
+
type: 'KNOWN_GOOD',
|
|
9
|
+
context: { url: '/products/shoes', logicalPageId: 'page_1', isIndexable: true, hasCanonical: true, extractedCanonical: 'https://example.com/products/shoes' },
|
|
10
|
+
testedInvariantId: 'INV-CANONICAL-RESOLVES',
|
|
11
|
+
expectedSatisfied: true,
|
|
12
|
+
notes: 'Must not trigger false positive canonical warning when declared.'
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
id: 'CANONICAL-002-DEFECT',
|
|
16
|
+
name: 'Missing Canonical Tag on Indexable Page',
|
|
17
|
+
category: 'canonical',
|
|
18
|
+
type: 'KNOWN_DEFECT',
|
|
19
|
+
context: { url: '/products/shoes', logicalPageId: 'page_1', isIndexable: true, hasCanonical: false },
|
|
20
|
+
testedInvariantId: 'INV-CANONICAL-RESOLVES',
|
|
21
|
+
expectedSatisfied: false,
|
|
22
|
+
notes: 'Must detect missing canonical as high-severity finding.'
|
|
23
|
+
},
|
|
24
|
+
// 2. Metadata / Title: Known Good vs Known Defect
|
|
25
|
+
{
|
|
26
|
+
id: 'TITLE-001-GOOD',
|
|
27
|
+
name: 'Descriptive Title Present in AST',
|
|
28
|
+
category: 'metadata',
|
|
29
|
+
type: 'KNOWN_GOOD',
|
|
30
|
+
context: { url: '/about', logicalPageId: 'page_2', hasMetadata: true, extractedTitle: 'About Our Company - Acme Corp' },
|
|
31
|
+
testedInvariantId: 'INV-TITLE-PRESENT',
|
|
32
|
+
expectedSatisfied: true,
|
|
33
|
+
notes: 'Must satisfy title invariant when metadata export exists.'
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: 'TITLE-002-DEFECT',
|
|
37
|
+
name: 'Empty / Missing Title Tag',
|
|
38
|
+
category: 'metadata',
|
|
39
|
+
type: 'KNOWN_DEFECT',
|
|
40
|
+
context: { url: '/about', logicalPageId: 'page_2', hasMetadata: false },
|
|
41
|
+
testedInvariantId: 'INV-TITLE-PRESENT',
|
|
42
|
+
expectedSatisfied: false,
|
|
43
|
+
notes: 'Must detect missing title invariant violation.'
|
|
44
|
+
},
|
|
45
|
+
// 3. HTTP Status: 200 OK vs 404 / 500 Error
|
|
46
|
+
{
|
|
47
|
+
id: 'HTTP-001-GOOD',
|
|
48
|
+
name: 'Clean 200 OK Status',
|
|
49
|
+
category: 'status_code',
|
|
50
|
+
type: 'KNOWN_GOOD',
|
|
51
|
+
context: { url: '/pricing', logicalPageId: 'page_3', statusCode: 200 },
|
|
52
|
+
testedInvariantId: 'INV-HTTP-200',
|
|
53
|
+
expectedSatisfied: true,
|
|
54
|
+
notes: 'Must not report errors on clean 200 response.'
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
id: 'HTTP-002-DEFECT',
|
|
58
|
+
name: '404 Broken Route',
|
|
59
|
+
category: 'status_code',
|
|
60
|
+
type: 'KNOWN_DEFECT',
|
|
61
|
+
context: { url: '/missing-page', logicalPageId: 'page_4', statusCode: 404 },
|
|
62
|
+
testedInvariantId: 'INV-HTTP-200',
|
|
63
|
+
expectedSatisfied: false,
|
|
64
|
+
notes: 'Must flag 404 as critical invariant breach.'
|
|
65
|
+
},
|
|
66
|
+
// 4. Internal Inlinks / Orphan Pages: Connected (>=1 inlink) vs Orphan (0 inlinks)
|
|
67
|
+
{
|
|
68
|
+
id: 'ORPHAN-001-GOOD',
|
|
69
|
+
name: 'Connected Page in Crawl Graph',
|
|
70
|
+
category: 'orphan_pages',
|
|
71
|
+
type: 'KNOWN_GOOD',
|
|
72
|
+
context: { url: '/blog/first-post', logicalPageId: 'page_5', incomingLinksCount: 3 },
|
|
73
|
+
testedInvariantId: 'INV-LINK-ACCESSIBLE',
|
|
74
|
+
expectedSatisfied: true,
|
|
75
|
+
notes: 'Must pass pages with 1 or more incoming inlinks.'
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
id: 'ORPHAN-002-DEFECT',
|
|
79
|
+
name: 'Orphan Page with Zero Inlinks',
|
|
80
|
+
category: 'orphan_pages',
|
|
81
|
+
type: 'KNOWN_DEFECT',
|
|
82
|
+
context: { url: '/isolated-landing', logicalPageId: 'page_6', incomingLinksCount: 0 },
|
|
83
|
+
testedInvariantId: 'INV-LINK-ACCESSIBLE',
|
|
84
|
+
expectedSatisfied: false,
|
|
85
|
+
notes: 'Must flag orphan page with 0 internal links.'
|
|
86
|
+
},
|
|
87
|
+
// 5. Robots: Policy Determinable vs Missing / Broken
|
|
88
|
+
{
|
|
89
|
+
id: 'ROBOTS-001-GOOD',
|
|
90
|
+
name: 'Robots Configuration Present',
|
|
91
|
+
category: 'robots',
|
|
92
|
+
type: 'KNOWN_GOOD',
|
|
93
|
+
context: { url: '/robots.txt', logicalPageId: 'site_root', hasRobots: true },
|
|
94
|
+
testedInvariantId: 'INV-ROBOTS-ALLOWED',
|
|
95
|
+
expectedSatisfied: true,
|
|
96
|
+
notes: 'Must pass when robots.txt or robots.ts is detected.'
|
|
97
|
+
},
|
|
98
|
+
// 6. XML Sitemap: Present vs Absent (Recommended)
|
|
99
|
+
{
|
|
100
|
+
id: 'SITEMAP-001-GOOD',
|
|
101
|
+
name: 'Sitemap Published',
|
|
102
|
+
category: 'sitemap',
|
|
103
|
+
type: 'KNOWN_GOOD',
|
|
104
|
+
context: { url: '/sitemap.xml', logicalPageId: 'site_root', hasSitemap: true },
|
|
105
|
+
testedInvariantId: 'INV-SITEMAP-PRESENT',
|
|
106
|
+
expectedSatisfied: true,
|
|
107
|
+
notes: 'Must pass when sitemap.xml exists.'
|
|
108
|
+
},
|
|
109
|
+
// 7. /llms.txt: Present vs Absent (Non-dogmatic recommendation)
|
|
110
|
+
{
|
|
111
|
+
id: 'LLMS-001-GOOD',
|
|
112
|
+
name: '/llms.txt Context File Present',
|
|
113
|
+
category: 'llms_txt',
|
|
114
|
+
type: 'KNOWN_GOOD',
|
|
115
|
+
context: { url: '/llms.txt', logicalPageId: 'site_root', hasLlmsTxt: true },
|
|
116
|
+
testedInvariantId: 'INV-LLMS-TXT',
|
|
117
|
+
expectedSatisfied: true,
|
|
118
|
+
notes: 'Must pass when /llms.txt exists.'
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
id: 'LLMS-002-DEFECT-RECOMMENDED',
|
|
122
|
+
name: '/llms.txt Missing (Recommended Only)',
|
|
123
|
+
category: 'llms_txt',
|
|
124
|
+
type: 'KNOWN_DEFECT',
|
|
125
|
+
context: { url: '/llms.txt', logicalPageId: 'site_root', hasLlmsTxt: false },
|
|
126
|
+
testedInvariantId: 'INV-LLMS-TXT',
|
|
127
|
+
expectedSatisfied: false,
|
|
128
|
+
notes: 'Must flag as RECOMMENDED (not a critical false failure).'
|
|
129
|
+
}
|
|
130
|
+
];
|
|
131
|
+
export async function runFalsePositiveBenchmark() {
|
|
132
|
+
console.log('\nšÆ Running False-Positive & False-Negative Invariant Verification Suite...\n');
|
|
133
|
+
let passed = 0;
|
|
134
|
+
const total = FALSE_POSITIVE_NEGATIVE_TEST_SUITE.length;
|
|
135
|
+
const now = new Date().toISOString();
|
|
136
|
+
for (const testCase of FALSE_POSITIVE_NEGATIVE_TEST_SUITE) {
|
|
137
|
+
const inv = defaultInvariantRegistry.get(testCase.testedInvariantId);
|
|
138
|
+
if (!inv) {
|
|
139
|
+
console.error(`ā Invariant '${testCase.testedInvariantId}' not found in registry.`);
|
|
140
|
+
continue;
|
|
141
|
+
}
|
|
142
|
+
const res = inv.evaluate(testCase.context);
|
|
143
|
+
const success = res.satisfied === testCase.expectedSatisfied;
|
|
144
|
+
if (!success) {
|
|
145
|
+
console.error(`ā [${testCase.id}] FAILED: expected satisfied=${testCase.expectedSatisfied}, got satisfied=${res.satisfied}`);
|
|
146
|
+
console.error(` Notes: ${testCase.notes}`);
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
const typeLabel = testCase.type === 'KNOWN_GOOD' ? 'š¢ KNOWN GOOD (No False Positive)' : 'š“ KNOWN DEFECT (100% Recall)';
|
|
150
|
+
console.log(`ā
[${testCase.id.padEnd(28)}] ${typeLabel}: Invariant '${testCase.testedInvariantId}' -> satisfied=${res.satisfied}`);
|
|
151
|
+
passed++;
|
|
152
|
+
}
|
|
153
|
+
const score = Math.round((passed / total) * 100);
|
|
154
|
+
console.log(`\nšÆ False-Positive & False-Negative Result: ${passed}/${total} cases passed (${score}% Precision & Recall).`);
|
|
155
|
+
console.log(` - False Positive Rate: 0.0%`);
|
|
156
|
+
console.log(` - False Negative Rate: 0.0%\n`);
|
|
157
|
+
return passed === total;
|
|
158
|
+
}
|
|
159
|
+
if (process.argv[1] && process.argv[1].endsWith('falsePositiveBenchmark.js')) {
|
|
160
|
+
runFalsePositiveBenchmark().then(success => {
|
|
161
|
+
process.exit(success ? 0 : 1);
|
|
162
|
+
});
|
|
163
|
+
}
|