crawlscope 0.10.0 → 0.10.2

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.
Files changed (56) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +29 -0
  3. data/README.md +51 -260
  4. data/UPGRADE.md +76 -0
  5. data/docs/architecture.md +73 -0
  6. data/docs/rails.md +121 -0
  7. data/docs/rules.md +144 -0
  8. data/docs/server-timing.md +59 -0
  9. data/lib/crawlscope/configuration.rb +2 -1
  10. data/lib/crawlscope/crawl.rb +11 -79
  11. data/lib/crawlscope/crawling/fetcher_factory.rb +31 -0
  12. data/lib/crawlscope/crawling/target.rb +45 -0
  13. data/lib/crawlscope/crawling/target_resolver.rb +75 -0
  14. data/lib/crawlscope/documents/canonical.rb +22 -0
  15. data/lib/crawlscope/documents/robots.rb +57 -0
  16. data/lib/crawlscope/page.rb +4 -0
  17. data/lib/crawlscope/reporter.rb +6 -160
  18. data/lib/crawlscope/reporting/issue_presenter.rb +162 -0
  19. data/lib/crawlscope/reporting/url_formatter.rb +29 -0
  20. data/lib/crawlscope/rule_registry.rb +2 -2
  21. data/lib/crawlscope/rules/content_quality.rb +18 -0
  22. data/lib/crawlscope/rules/indexability.rb +9 -14
  23. data/lib/crawlscope/rules/links/canonical_checks.rb +102 -0
  24. data/lib/crawlscope/rules/links/extractor.rb +100 -0
  25. data/lib/crawlscope/rules/links/graph.rb +39 -0
  26. data/lib/crawlscope/rules/links/inbound_checks.rb +124 -0
  27. data/lib/crawlscope/rules/links/outgoing_checks.rb +104 -0
  28. data/lib/crawlscope/rules/links/resolution_check.rb +88 -0
  29. data/lib/crawlscope/rules/links/scope.rb +23 -0
  30. data/lib/crawlscope/rules/links/target_lookup.rb +38 -0
  31. data/lib/crawlscope/rules/links/url_checks.rb +54 -0
  32. data/lib/crawlscope/rules/links.rb +18 -600
  33. data/lib/crawlscope/rules/metadata.rb +2 -2
  34. data/lib/crawlscope/rules/structured_data.rb +26 -77
  35. data/lib/crawlscope/rules/uniqueness.rb +1 -1
  36. data/lib/crawlscope/schemas.rb +10 -2
  37. data/lib/crawlscope/server_timing/reporter.rb +2 -13
  38. data/lib/crawlscope/structured_data/audit.rb +17 -76
  39. data/lib/crawlscope/structured_data/check.rb +2 -0
  40. data/lib/crawlscope/structured_data/document.rb +14 -1
  41. data/lib/crawlscope/structured_data/entry.rb +31 -0
  42. data/lib/crawlscope/structured_data/outcome.rb +11 -0
  43. data/lib/crawlscope/structured_data/report.rb +6 -14
  44. data/lib/crawlscope/structured_data/reporter.rb +6 -11
  45. data/lib/crawlscope/structured_data/validator.rb +64 -0
  46. data/lib/crawlscope/version.rb +1 -1
  47. data/test/crawlscope/cli_test.rb +21 -0
  48. data/test/crawlscope/content_quality_rule_test.rb +51 -0
  49. data/test/crawlscope/links_rule_test.rb +16 -0
  50. data/test/crawlscope/reporter_test.rb +12 -0
  51. data/test/crawlscope/schema_registry_test.rb +22 -0
  52. data/test/crawlscope/structured_data_audit_test.rb +60 -0
  53. data/test/crawlscope/structured_data_report_test.rb +32 -0
  54. data/test/crawlscope/structured_data_rule_test.rb +11 -1
  55. data/test/crawlscope/structured_data_validator_test.rb +24 -0
  56. metadata +26 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: da58b612eb199f881ec2263858feea4bf93e11355ffce7b19921bb266451818e
4
- data.tar.gz: bcfa91a8bd74cf5ae670dcc5a1b3e762ad0c6a74037cd82f92b700f8b3a2d7d0
3
+ metadata.gz: 9f1e7d817608a6023e7230e5568408576f375733ff0e466ab0ae9119b72cae8a
4
+ data.tar.gz: 4c645137855354cdb4847e641d78969a2f6014698d142c7a446b5555d4cbfbbb
5
5
  SHA512:
6
- metadata.gz: e3001de98212ddd2dca5f15feec4bf32eb9b3a975bef21c948c15c588c9a6d9f18bd130985fc3a6cfa78d1dfd34c2c5c4e944563ecd27be87cc49819475aed46
7
- data.tar.gz: 784d47ba0dbf3effdbacb53d9211472e044b22da28c2d00e21bbcb8844aa2a1309eba072c0c631412b1dd7bad10f6713ad0adb107f2805df42310b1b31ad7991
6
+ metadata.gz: e341bfed169b466693ec2bf72aec7ca53bc4c3ebabbc5935491ecd523b2edfb594a1bc44e16b3c22499c4a97ac4a1b70c4f0f42012933f652e7ea4bd1248c301
7
+ data.tar.gz: 6421dbc9dc6e15882b08a61f1a73ee23f2cdd02dbfdfc87136be363d65ac844d852065b6ef1041908278008627ecc740f66e979fe9be7ec57cca6fa71f158b90
data/CHANGELOG.md CHANGED
@@ -5,6 +5,35 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.10.2] - 2026-11-15
9
+
10
+
11
+ ### Added
12
+
13
+ - unify validation and reporting responsibilities
14
+
15
+ - enforce required structured data types by URL
16
+
17
+
18
+
19
+
20
+ ### Fixed
21
+
22
+ - accept date-only review publication dates
23
+
24
+
25
+
26
+ ## [0.10.1] - 2026-11-08
27
+
28
+
29
+ ### Documentation
30
+
31
+ - make Ethos Link the canonical documentation home
32
+
33
+ - keep audited technical guidance alongside the code
34
+
35
+
36
+
8
37
  ## [0.10.0] - 2026-11-06
9
38
 
10
39
 
data/README.md CHANGED
@@ -3,13 +3,13 @@
3
3
  [![Gem Version](https://badge.fury.io/rb/crawlscope.svg)](https://badge.fury.io/rb/crawlscope)
4
4
  [![Commit messages](https://github.com/ethos-link/crawlscope/actions/workflows/commitlint.yml/badge.svg)](https://github.com/ethos-link/crawlscope/actions/workflows/commitlint.yml)
5
5
 
6
- `crawlscope` is a small Ruby gem for sitemap-driven SEO validation.
6
+ `crawlscope` audits sitemap URLs for indexability, metadata, structured data and internal links.
7
7
 
8
8
  It is built by [Ethos Link](https://www.ethos-link.com) and used in production by [Reviato](https://www.reviato.com).
9
9
 
10
10
  It is designed for Rails apps and plain Ruby scripts that want:
11
11
 
12
- - deterministic sitemap crawling
12
+ - sitemap-driven crawling
13
13
  - structured validation issues instead of free-form strings
14
14
  - app-configurable rule and schema registries
15
15
  - first-party rake tasks instead of a large DSL
@@ -30,6 +30,16 @@ The default rule set includes:
30
30
  - content-quality checks
31
31
  - internal-link checks
32
32
 
33
+ ## Documentation
34
+
35
+ This README and the linked repository guides describe the checked-out code.
36
+ The [Ethos Link project page](https://www.ethos-link.com/opensource/crawlscope)
37
+ provides the canonical public project guide, overview and resources.
38
+
39
+ - [Rails integration and tasks](docs/rails.md)
40
+ - [Rule catalogue and schema registries](docs/rules.md)
41
+ - [Server timing and diagnostic headers](docs/server-timing.md)
42
+
33
43
  ## Installation
34
44
 
35
45
  Crawlscope requires Ruby 4.0 or newer. Rails is optional; the CLI and Ruby
@@ -63,7 +73,7 @@ If you want browser rendering, also add:
63
73
  gem "ferrum"
64
74
  ```
65
75
 
66
- `crawlscope` only loads Ferrum when you run in browser mode.
76
+ `crawlscope` only loads Ferrum when you run in browser mode. Install a compatible Chrome or Chromium executable as well.
67
77
 
68
78
  ## CLI Usage
69
79
 
@@ -163,277 +173,46 @@ puts result.issues.to_a.map(&:message)
163
173
  `result.ok?` returns `false` when an error is present. Warnings and notices
164
174
  remain available through `result.issues` without making the result fail.
165
175
 
166
- ## Server Timing
167
-
168
- Crawlscope parses the
169
- [`Server-Timing`](https://www.w3.org/TR/server-timing/) response header for both
170
- HTTP and browser-rendered crawls. Each page exposes its parsed header through
171
- `page.server_timing`:
172
-
173
- ```ruby
174
- page.server_timing.each do |metric|
175
- puts [metric.name, metric.duration, metric.description].compact.join(": ")
176
- end
177
- ```
178
-
179
- The validation report adds a `Server Timing` section only when at least one page
180
- publishes the header. It includes:
181
-
182
- - header coverage and the number of pages publishing durations
183
- - sample and page counts with average, p50, p95, and maximum per metric
184
- - non-duration signals, including cache status and routing descriptions
185
- - the ten pages with the largest individual metric
186
- - the number of malformed entries ignored during parsing
187
-
188
- `dur` values are reported as milliseconds, as recommended by the specification.
189
- Crawlscope does not add durations together because metrics such as `total`,
190
- `app`, and `db` may overlap. A page's worst-offender entry is its largest
191
- individual metric instead.
192
-
193
- The current HTTP and browser transports expose response headers, not response
194
- trailers. Metrics published only in a `Server-Timing` trailer are therefore not
195
- available to Crawlscope.
176
+ ## Rails integration
196
177
 
197
- Rails 8 applications can enable `ActionDispatch::ServerTiming` with:
178
+ Add `gem "crawlscope", require: false` to the host application's Gemfile, run
179
+ `bundle install`, then install the task/configuration integration:
198
180
 
199
- ```ruby
200
- config.server_timing = true
201
- ```
202
-
203
- Applications that expose timing only to authenticated diagnostics can set
204
- `config.profile_token`. When this value is present, Crawlscope sends it as
205
- `X-Profile-Token` on same-origin sitemap, HTTP, and browser document requests.
206
- The header survives same-origin redirects but is removed before a cross-origin
207
- redirect, and browser subresources never receive it. Keep the token in the host
208
- application's secret store rather than a URL, command argument, report, or
209
- checked-in configuration.
210
-
211
- `CRAWLSCOPE_PROFILE_TOKEN` is the portable default for Rails, the standalone
212
- CLI, Rake tasks, and plain Ruby callers. Rails applications may instead assign
213
- `config.profile_token` from encrypted credentials when that is their established
214
- secret-management boundary; explicit configuration takes precedence over the
215
- environment.
216
-
217
- New Rails applications enable it in development by default; production remains
218
- opt-in. Rails publishes the Active Support notification names observed during
219
- each request and sums repeated events with the same name. The exact metrics
220
- therefore depend on the application and request, but commonly include controller,
221
- view, database, and cache instrumentation. Crawlscope accepts Rails' dotted
222
- metric names and reports each metric independently.
223
-
224
- ## Rails Usage
225
-
226
- Install Rails 8 in the host application; Crawlscope does not install Railties.
227
- For a process that loads Crawlscope before Rails, require `crawlscope/rails`
228
- after Rails is available. The Ruby and CLI entry points remain independent of Rails.
229
-
230
- Run the install generator after adding the gem:
231
-
232
- ```bash
181
+ ```sh
233
182
  bin/rails generate crawlscope:install
183
+ bin/rails crawlscope:validate
234
184
  ```
235
185
 
236
- The generator creates `config/initializers/crawlscope.rb` with an idempotent
237
- `CrawlscopeConfiguration.apply` loader and adds conditional `crawlscope/tasks`
238
- loading to the application's `Rakefile`. This preserves `bin/rails --tasks` and
239
- the `crawlscope:*` tasks without loading Crawlscope during normal Rails boot.
240
-
241
- Customize the `Crawlscope.configure` block inside the generated initializer:
242
-
243
- ```ruby
244
- Crawlscope.configure do |config|
245
- config.base_url = -> { ENV.fetch("CRAWLSCOPE_BASE_URL", "http://localhost:3000") }
246
- config.sitemap_path = lambda {
247
- ENV.fetch("SITEMAP", "#{config.base_url.to_s.chomp("/")}/sitemap.xml")
248
- }
249
- config.site_name = ENV.fetch("CRAWLSCOPE_SITE_NAME", "Application")
250
- end
251
- ```
252
-
253
- Runtime callers must apply the generated configuration before using
254
- Crawlscope:
186
+ Edit the generated `Crawlscope.configure` block to set `base_url`,
187
+ `sitemap_path` and any custom rule/schema registries. Tasks load and apply it
188
+ automatically. From runtime application code, apply the generated loader and
189
+ execute the crawl explicitly:
255
190
 
256
191
  ```ruby
257
192
  CrawlscopeConfiguration.apply
258
- Crawlscope.configuration.audit
259
- ```
260
-
261
- Rake tasks apply it automatically because `crawlscope/tasks` loads the gem
262
- before Rails evaluates the initializer. Each Rake entry point passes the shared
263
- `Crawlscope.configuration` object to the CLI, so configured base URLs, sitemap
264
- paths, registries, and runtime settings are preserved unless a task argument or
265
- environment override replaces them.
266
-
267
- Then run:
268
-
269
- ```bash
270
- bin/rails crawlscope:validate
271
- ```
272
-
273
- Available environment overrides:
274
-
275
- - `URL`
276
- - `SITEMAP`
277
- - `CRAWLSCOPE_PROFILE_TOKEN`
278
- - `RULES=metadata,links`
279
- - `JS=1` or `RENDERER=browser`
280
- - `TIMEOUT=30`
281
- - `NETWORK_IDLE_TIMEOUT=10`
282
- - `CONCURRENCY=5`
283
- - `FETCH_EXECUTOR=threaded` or `FETCH_EXECUTOR=async`
284
-
285
- Available tasks:
286
-
287
- ```bash
288
- bin/rails crawlscope:validate
289
- bin/rails crawlscope:validate:indexability
290
- bin/rails crawlscope:validate:metadata
291
- bin/rails crawlscope:validate:structured_data
292
- bin/rails crawlscope:validate:uniqueness
293
- bin/rails crawlscope:validate:content_quality
294
- bin/rails crawlscope:validate:links
295
- bin/rails crawlscope:validate:ldjson
296
- ```
297
-
298
- The same validation surface is also available in the gem repository itself through plain `rake`:
299
-
300
- ```bash
301
- bundle exec rake crawlscope:validate URL=https://example.com
302
- bundle exec rake 'crawlscope:validate[https://example.com]'
303
- bundle exec rake crawlscope:validate:metadata URL=https://example.com
304
- bundle exec rake 'crawlscope:validate:metadata[https://example.com]'
305
- bundle exec rake crawlscope:validate:ldjson URL=https://example.com/article
306
- bundle exec rake 'crawlscope:validate:ldjson[https://example.com/article]'
307
- ```
308
-
309
- `crawlscope:validate` runs all default sitemap rules: indexability, metadata,
310
- structured data, uniqueness, content quality, and links. `URL` is the site
311
- base. Without `SITEMAP`, Crawlscope uses the configured sitemap URL, then fetches
312
- `/sitemap.xml` from `URL` over HTTP. With `SITEMAP`, Crawlscope uses `URL` as
313
- the site base and validates URLs from that sitemap. `SITEMAP` may be a full URL
314
- or an explicitly selected local file path.
315
-
316
- Plain `rake` does not pass `--url` style flags to tasks. Use `URL=...` or the
317
- task-argument form above instead.
318
-
319
- `FETCH_EXECUTOR=async` is the default for HTTP crawling. It uses Ruby's fiber
320
- scheduler and Async::HTTP through Faraday, preserving the same `CONCURRENCY`
321
- bound. Use `FETCH_EXECUTOR=threaded` or `--fetch-executor threaded` for the
322
- thread-pool executor. Browser rendering uses the threaded executor by default
323
- because async fetch execution is only supported with HTTP rendering.
324
-
325
- `crawlscope:validate:ldjson` is separate because it directly checks the URL or semicolon-separated URLs in `URL`; it does not crawl the sitemap. Without `URL`, it checks the configured base URL, falling back to `http://localhost:3000`.
326
-
327
- ### Structured Data URL Audit
328
-
329
- For one-off structured-data checks:
330
-
331
- ```bash
332
- bin/rails crawlscope:validate:ldjson URL=https://example.com/article
333
- bin/rails crawlscope:validate:ldjson URL='https://example.com/a;https://example.com/b' SUMMARY=1
334
- bin/rails crawlscope:validate:ldjson URL=https://example.com/article REPORT_PATH=tmp/structured-data.json
193
+ result = Crawlscope.configuration.audit.call
335
194
  ```
336
195
 
337
- Optional flags:
338
-
339
- - `DEBUG=1`: print detected items
340
- - `SUMMARY=1`: print grouped failures
341
- - `REPORT_PATH=...`: write a JSON report. Treat this as trusted operator input; Crawlscope writes to the path the task process can access.
342
- - `JS=1` or `RENDERER=browser`: render with Ferrum
343
-
344
- ## Rules
345
-
346
- Built-in rules:
347
-
348
- - `indexability`
349
- - `metadata`
350
- - `structured_data`
351
- - `uniqueness`
352
- - `content_quality`
353
- - `links`
354
-
355
- ### Indexability
356
-
357
- Checks:
358
-
359
- - page-level meta robots `noindex`
360
- - `X-Robots-Tag: noindex`
361
-
362
- ### Metadata
363
-
364
- Checks:
365
-
366
- - missing `<h1>`
367
- - missing `<title>`
368
- - title length
369
- - repeated site name in the title
370
- - missing meta description
371
- - meta description length
372
- - missing canonical link
373
- - canonical mismatch
374
-
375
- ### Structured Data
196
+ See [Rails integration](docs/rails.md) for lazy loading, all tasks,
197
+ environment overrides and structured-data URL audits.
376
198
 
377
- Checks:
199
+ ## Configuration and limits
378
200
 
379
- - malformed JSON-LD
380
- - missing required fields for supported schema types
381
- - schema validation failures from the configured registry
382
- - direct URL structured-data audits through `crawlscope:validate:ldjson`
201
+ The shared configuration defaults to HTTP rendering, the async fetch executor,
202
+ 10 concurrent requests and a 20-second request timeout. Browser rendering uses
203
+ the threaded executor with at most four concurrent browser fetches. Configure
204
+ `concurrency`, `timeout_seconds`, `renderer`, `fetch_executor`, `rule_registry`
205
+ and `schema_registry` through `Crawlscope.configure` when using that shared
206
+ configuration; direct `Crawlscope::Crawl.new` callers pass their own options.
383
207
 
384
- ### Uniqueness
208
+ Use [rule and schema registries](docs/rules.md) to select or extend checks.
209
+ Near-duplicate scanning is limited to 250 HTML pages by default; exact duplicate
210
+ checks still run for larger crawls. Validation describes observed responses and
211
+ configured rules; it does not establish Google rich-result eligibility or
212
+ search ranking.
385
213
 
386
- Checks:
387
-
388
- - duplicate titles
389
- - duplicate meta descriptions
390
- - duplicate content fingerprints
391
- - near-duplicate visible content for up to 250 HTML pages
392
-
393
- For larger crawls, exact duplicate checks still run and Crawlscope reports
394
- `near_duplicate_scan_skipped`. Configure `Rules::Uniqueness` with
395
- `max_near_duplicate_pages:` in a custom rule registry to change the limit.
396
-
397
- ### Content Quality
398
-
399
- Checks:
400
-
401
- - thin visible text
402
- - low visible-text-to-HTML ratio
403
- - low unique-token ratio
404
-
405
- ### Links
406
-
407
- Checks:
408
-
409
- - broken internal links
410
- - unresolved internal links
411
- - low inbound anchor-link counts
412
-
413
- ## Schema Registry
414
-
415
- `crawlscope` ships with a default schema registry for common types such as:
416
-
417
- - `Article`
418
- - `FAQPage`
419
- - `Organization`
420
- - `Product`
421
- - `Review`
422
- - `SoftwareApplication`
423
- - `WebApplication`
424
- - `WebSite`
425
-
426
- The default schema definitions live in `Crawlscope::Schemas`; `Crawlscope::SchemaRegistry` owns registration and validation.
427
-
428
- Host apps can replace or extend the registry:
429
-
430
- ```ruby
431
- Crawlscope.configure do |config|
432
- config.schema_registry = -> { MyApp::StructuredData::SchemaRegistry.new }
433
- end
434
- ```
435
-
436
- That makes `crawlscope` useful as the audit engine while the app remains the owner of stricter product-specific schema rules.
214
+ [Server timing](docs/server-timing.md) covers response timings, diagnostic
215
+ profile tokens and the limits of those measurements.
437
216
 
438
217
  ## Contributing
439
218
 
@@ -463,3 +242,15 @@ bundle exec rake verify
463
242
  Tests use controlled local fixtures and need no service account.
464
243
  Release preparation, publication, registry setup and recovery are documented
465
244
  in the [Gemkit release guide](https://github.com/ethos-link/ethos-gemkit#releasing-a-gem).
245
+
246
+ ## About Ethos Link
247
+
248
+ [Ethos Link](https://www.ethos-link.com) is a software company founded by
249
+ [Paulo Fidalgo](https://www.fidalgo.pt). This gem is part of the open-source
250
+ tooling we publish alongside our business products:
251
+
252
+ - [Reviato](https://www.reviato.com): collect private customer feedback and analyse public reviews.
253
+ - [Nuntio](https://www.nuntiohq.com): prepare, review and schedule social posts.
254
+ - [EthosPlaces](https://www.ethos.place): find places, opening hours and contact details.
255
+
256
+ Explore our [open-source projects](https://www.ethos-link.com/opensource).
data/UPGRADE.md CHANGED
@@ -37,6 +37,82 @@ in the README; the shared workflow does not inherit another gem's permission.
37
37
 
38
38
  ## Next Release
39
39
 
40
+ ### Review publication dates
41
+
42
+ Standalone and nested reviews now accept a date (`2026-09-16`) or timestamp for
43
+ `datePublished`, matching [Schema.org's Date or DateTime contract](https://schema.org/datePublished).
44
+ Invalid calendar dates still fail validation. Hosts no longer need to invent a
45
+ time to validate a review whose source publishes only its date.
46
+
47
+ ### Required structured-data types
48
+
49
+ Set `config.required_structured_data_types` to a callback accepting a URL and
50
+ returning the types that page must contain. Separate strings require all types;
51
+ nested arrays accept alternatives, such as `[["Article", "BlogPosting",
52
+ "NewsArticle"]]`. The default remains no additional type requirements.
53
+ See [the rule configuration](docs/rules.md#required-types-by-url) for examples.
54
+
55
+ The default sitemap rule and direct URL audits apply the same requirements.
56
+ Custom rule registries must pass the callback through `required_types:` when
57
+ constructing their structured-data rule. Custom configuration objects supplied
58
+ to `Run` or `StructuredData::Check` can expose `required_structured_data_types`
59
+ to opt in. Existing objects without that optional setting retain their behavior.
60
+
61
+ ### Shared audit outcomes and internal architecture
62
+
63
+ Direct structured-data audits now fail when an HTML page has no structured data
64
+ or contains a JSON-LD or microdata item missing `@type`. Detailed output,
65
+ summaries, and CLI/Rake exit status agree on these failures. Summary categories
66
+ also include failures on successful responses other than HTTP 200 and browser
67
+ responses without a status. Non-HTML responses remain successful skips.
68
+
69
+ Hosts using `validate_json_ld` or `crawlscope ldjson` must add the missing markup
70
+ or type to pass validation. Summary URL rows now retain the full URL, including
71
+ the host and query string; update text parsers that expected path-only rows.
72
+ The JSON report retains its existing shape and includes missing-type errors in
73
+ `validation_errors`.
74
+
75
+ JobPosting count checks are now opt-in and scoped to a host-supplied path
76
+ pattern. Crawlscope no longer assumes `/careers/...` identifies job detail
77
+ pages or that multiple JobPosting items are invalid on other pages. Hosts that
78
+ need exactly one JobPosting on job detail pages can replace the default rule:
79
+
80
+ ```ruby
81
+ Crawlscope.configure do |config|
82
+ config.rule_registry = -> {
83
+ registry = Crawlscope::RuleRegistry.default(site_name: config.site_name)
84
+ rules = registry.rules.map do |rule|
85
+ if rule.code == :structured_data
86
+ Crawlscope::Rules::StructuredData.new(job_posting_path: %r{/careers/[^/]+/?\z})
87
+ else
88
+ rule
89
+ end
90
+ end
91
+ Crawlscope::RuleRegistry.new(rules: rules, default_codes: registry.default_codes)
92
+ }
93
+ end
94
+ ```
95
+
96
+ Use your application's actual job path pattern. The former
97
+ `Rules::StructuredData::CAREER_DETAIL_PATH` constant is removed; pass the pattern
98
+ directly when constructing the rule.
99
+
100
+ Existing `Crawl`, `Reporter`, rule entry points, issue fields, and
101
+ `StructuredData::Audit::Page` / `Outcome` constructors remain available.
102
+ Internal responsibilities now live under `Crawling`, `Documents`, `Reporting`,
103
+ and `Rules::Links`; see [architecture](docs/architecture.md) for extension points.
104
+
105
+ ### Images missing alt attributes
106
+
107
+ The default `content_quality` rule now emits one `missing_image_alt` warning per
108
+ HTML page containing `<img>` elements without an `alt` attribute. Empty
109
+ `alt=""` attributes remain valid for decorative images. Details include `count`
110
+ and `image_sources`; text reports list the affected image sources.
111
+
112
+ No host configuration changes are required. Applications that count warnings or
113
+ fail crawls on warnings should expect this additional check. Add appropriate alt
114
+ text to informative images or `alt=""` to decorative images to resolve warnings.
115
+
40
116
  ### Query links retain their own URL identity
41
117
 
42
118
  URL normalization now preserves query strings and still removes fragments.
@@ -0,0 +1,73 @@
1
+ # Architecture
2
+
3
+ Crawlscope separates fetching, document interpretation, audit policy, and
4
+ presentation. Public entry points remain small coordinators. The directories
5
+ below contain the collaborators they use:
6
+
7
+ ```text
8
+ lib/crawlscope/
9
+ crawling/
10
+ fetcher_factory.rb HTTP/browser construction and browser load errors
11
+ target_resolver.rb URL normalization, page reuse, and target caching
12
+ target.rb Resolved target status and indexability
13
+ documents/
14
+ canonical.rb Canonical href extraction and URL resolution
15
+ robots.rb Shared robots directive interpretation
16
+ reporting/
17
+ issue_presenter.rb Issue headings, rows, evidence, and measurements
18
+ url_formatter.rb URL display that preserves origin and query identity
19
+ rules/
20
+ links.rb Public links rule; assembles one invocation
21
+ links/
22
+ extractor.rb Internal anchor extraction
23
+ scope.rb Shared link inclusion policy
24
+ target_lookup.rb Per-invocation target lookup and batch resolution
25
+ resolution_check.rb Broken and redirected link checks
26
+ graph.rb Inbound counts and source URLs
27
+ inbound_checks.rb Incoming-link policies
28
+ outgoing_checks.rb Outgoing-link and discovered sitemap policies
29
+ canonical_checks.rb Canonical target status and inbound-link policies
30
+ url_checks.rb URL hygiene
31
+ structured_data/
32
+ document.rb JSON-LD and microdata extraction
33
+ validator.rb Shared parse, type-presence, and schema validation
34
+ entry.rb Per-URL outcome and failure classification
35
+ outcome.rb Overall success derived from entries
36
+ audit.rb Fetches direct URLs and adapts validation findings
37
+ report.rb Summary selection and JSON serialization
38
+ ```
39
+
40
+ `Configuration` selects rules and runtime settings. `Run` invokes an audit and
41
+ its reporter. `Crawl` coordinates sitemap expansion, fetching, response checks,
42
+ and rule execution; `Crawling::TargetResolver` supplies rules with cached target
43
+ resolution through the existing `Context` protocol.
44
+
45
+ The links rule creates its collaborators for each call. A reused rule instance
46
+ does not retain a previous crawl's resolver or target cache. `Graph` indexes
47
+ resolved incoming links once, excludes self-links and noindex targets, and
48
+ retains full URL identity. Inbound and canonical checks ask the same graph for
49
+ counts instead of maintaining separate counting algorithms. Path inclusion
50
+ policy lives in `Scope`.
51
+
52
+ Both structured-data entry points use `StructuredData::Validator`. It returns
53
+ items and findings without writing output or choosing command exit status.
54
+ `Rules::StructuredData` translates findings into the sitemap audit's existing
55
+ warning issues. `StructuredData::Audit` translates them into direct-URL entries.
56
+ Host path requirements belong in explicit rule configuration.
57
+
58
+ `StructuredData::Entry` owns failure classification: fetch failure, missing
59
+ markup, validation failure, or success. `Outcome#ok?` and summary categories use
60
+ that classification. The legacy `Audit::Page` and `Audit::Outcome` constants are
61
+ aliases, preserving their constructors and fields.
62
+
63
+ `Reporter` owns text layout and ordering; `Reporting::IssuePresenter` formats
64
+ one issue without performing I/O. `Reporting::UrlFormatter` is shared by crawl
65
+ and timing reports. Structured-data errors use the same `ErrorFormatter` in
66
+ both audit reports. Existing `Issue#message` values remain available to API
67
+ consumers; presenters use structured evidence for richer text rows.
68
+
69
+ When adding a check, put document interpretation in a shared document object,
70
+ policy in a rule, and text formatting in a presenter. Keep network access behind
71
+ the fetcher and resolver interfaces. Add behavior tests at the public rule or
72
+ command boundary; use direct collaborator tests for policies that need their
73
+ own examples. Run `bundle exec rake verify` before handing off changes.