Repository navigation
feat(robots): the owner can let Contentrain Migrate read the site through robots.txt - #57
Conversation
|
Read-review (ork2), head 2d4d0bb: CHANGES REQUESTED. One MUST, plus ORK's media item. MUST: dropping a Disallow can open more than / and /wp-json/.
Suggested shape (RFC 9309 longest match; on a tie, Allow wins):
Parity test (ork1's suggestion): run the robots.txt Bridge produces through our #679 parser (
The fixtures need to cover Notes (non-blocking):
|
…oads by Allow, so wp-admin stays closed
|
Delta read-review (ork2) @ 5319eb8: the MUST is resolved, read-review OK.
Tests:
The non-blocking items are done too: Remaining for the ONAY: t3's full Docker acceptance, which runs in the lane B slot after t8's S3. |
|
Gate on head 5319eb8, run from
|
|
On hold: the CI acceptance job is red on 5319eb8 (robots.php, wp-admin check). Looking into the environment difference; the local gate above does not stand until that is fixed. |
…O plugin serves for *
… that closes wp-admin
|
ork2 delta read @c331669b: OK. The group ALWAYS adds |
…n after any SEO plugin's filter
….txt that ends without a newline
|
Hold lifted. Head 97a468e, all CI green: acceptance, PHP 7.4/8.3 syntax, metadata, perf small/large. The CI red came from Yoast. It stays active during CI's coverage step and rewrites robots.txt. Fixes:
Local run, own compose project, in CI's order: robots 61/61 with Yoast active and 61/61 without it; parity 10/10 through @migrate/crawler; Plugin Check 0 errors, the same 26 warnings as main. |
An opt-in switch in Tools > Contentrain Bridge: "Let Contentrain Migrate read my pages and media". It is off by default and turned on only by an explicit owner click.
What it does
When on, the robots.txt WordPress serves (the
robots_txtfilter, which runs last) gains one group for theContentrainMigratecrawler:User-agent: *has, minus only the Disallows that close the whole site (any pattern matching/:/,/*,/$);Allow: /wp-json/,Allow: <the site's REST prefix>,Allow: <the uploads path>andAllow: /.Why that keeps wp-admin closed: by RFC 9309 longest match (an Allow wins a tie), those Allows open the REST API and the media under any shorter Disallow (
/wp-,/wp-content/). Every other path such a Disallow closes stays closed, wp-admin included.What else stays as it was:
ContentrainMigrate, nothing is added (/aboutreportsowner_group: true).When WordPress can't change robots.txt:
get_home_path()): the switch stays off. The card shows the exact lines to add by hand, built from that file, and/aboutreportsfile: 'physical'./aboutgetscapabilities: ['robots_allow']androbots: { allow, file: 'virtual' | 'physical', owner_group }. t8's S3 adds'counts'; whoever merges second keeps both.The form is a plain admin-post form (no JS needed), behind
Admin::permitted()(export + manage_options) and its own nonce.readme.txt (WP.org)
No version bump: 0.7.0 follows in a separate PR together with S3.
Tests
tests/robots.php, 41 checks (npm run test:robots; also intests/coverage.sh), each judged by an RFC 9309 verdict (merged groups, longest match, Allow on a tie):/aboutreports off, virtual, no owner group;*group is unchanged; the original bytes come first;Disallow: /,/*,/wp-,/wp-content/, uploads + plugins closed with a Googlebot group,/wp-json/+/private/, and Cloudflare's managed robots.txt (migrate's fixture);/, a post,/wp-json/…/about,/wp-json/wp/v2/postsand an upload, and wp-admin stays closed;*, Googlebot, GPTBot and ClaudeBot have the same verdict on every path as with the switch off./wp-is kept;owner_groupset;tests/robots-parity.mjs(npm run test:robots-parity -- <migrate packages/crawler/dist/index.mjs>) reads the same off/on pairs with Contentrain Migrate's own parser (@migrate/crawler, RFC 9309 group merge since migrate#679). The same three claims hold: Migrate reads, wp-admin is closed, and other agents' verdicts are unchanged.tests/robots.shtakesBRIDGE_TEST_PROJECT(-p) for parallel sessions.Local gate (feat/robots-allow @ 5319eb8, on origin/main 88b5e8e)
tests/robots.sh(WP 7.1, php8.3)tests/robots-parity.mjsthrough migrate main f3cf2a82's crawlernpm testis 12/13. The failinghandoff.test.mjsneedstests/.out/storefrom the full acceptance run; that's pre-existing, and the full acceptance runs in the slot after t8.