Skip to content

fix: localized SEO for national sites, clean query routes, release-only updates - #73

Merged
Ardnived merged 5 commits into
mainfrom
claude/audit-fixes
Nov 1, 2026
Merged

Ardnived merged 5 commits into
mainfrom
claude/audit-fixes

Conversation

@Ardnived

@Ardnived Ardnived commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Fixes from a workspace-wide audit. One commit per behaviour. The owner approved each behaviour change.

What changes

Commit Failure it prevents
fix(seo) a refused regional locale asks again in its bare language WordPress's nl_NL became nl-NL, and SahajCloud accepts only exact codes (nl, de, … plus en-AU, pt-BR). It answered 400, the plugin retried with no locale, and most national sites got English titles, descriptions and crawlable body. The fetch now tries the tag, then its base language, then none. There is still no hard-coded locale list.
fix(routing) the widget's view state is not part of the route ?atlas=/nl/amsterdam?center=4.9,52.3 was sent upstream whole, SahajCloud 404'd the ?, and shared links indexed as the generic root. The route now stops at ?/#. Both add_query_arg calls take rawurlencode_deep, as embedding.md asks.
fix(updates) offer an update only from a release carrying the built zip With a release missing its zip, or a bare tag, Plugin Update Checker installed GitHub's source archive: no translations, with tests and docs shipped to all 13 sites. REQUIRE_RELEASE_ASSETS alone falls through to the latest tag, so a strategy filter keeps only latest_release. The release.yml comment ("a release without the asset delivers nothing") is now true.
fix(updates) read PUC's release constants off the API instance The class literal spelled the vendored minor version, v5p6, four lines under the v5\PucFactory entry point chosen to avoid exactly that, and load-v5p6.php registers no version-free v5\Vcs\Api alias. The next vendor/plugin-update-checker bump would have made both constant reads a Class not found fatal on init, on all 13 sites at once, and pnpm lint checks syntax. The constants sit on the abstract class the instance already extends.
test(updates) assert the filter against PUC's own strategy set The expectation was built from a hand-written array, so it proved array_intersect_key and not the coupling. GitHubApi::getUpdateDetectionStrategies() adds latest_release only on branch master or main. The day that key leaves its set, the filter returns an empty array, PUC chooses no reference, and no site is offered an update again — silently, since no diagnostics check covers updates.

Tests

  • pnpm test:all passes end to end: lint checks 15 files with 0 syntax errors, the measure lane reports 0 failures, the WordPress 6.7 / PHP 7.4 suite reports 432 assertions and 0 failures, and every render cell passes.
  • Each new assertion was watched failing first — the earlier ones against the origin/main code, the two newest against a reintroduced defect.

Sibling PRs (same audit)

🤖 Generated with Claude Code

Ardnived and others added 3 commits October 31, 2026 10:27
`sahaj_atlas_seo_locale()` sends `nl-NL`, `de-DE` and the like, while
SahajCloud lists only exact codes (`nl`, `de`, …, plus `en-AU` and
`pt-BR`). The endpoint answered 400, the one retry asked with no locale
at all, and most national sites got the English root title and
description.

A refused tag is now retried as its bare language first, then with no
locale, so `nl-NL` reaches `nl` and `pt-BR` still matches exactly. The
plugin still keeps no copy of the locale list. The answer is cached in
the same slot as before.

There was no test of this retry. One now proves an nl_NL site asks for
`locale=nl` once `nl-NL` is refused.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The widget nests its own view state in `?atlas=`
(`?atlas=/nl/amsterdam%3Fcenter%3D4.9,52.3`), which `$_GET` decodes to
a route carrying `?center=…`. That route went upstream as-is, and
SahajCloud 404s it, so a shared map link lost its SEO takeover. Only the
part before `?` or `#` is the route now.

`add_query_arg()` encodes nothing, so the route, the key and the other
values reached the script URL and the SEO request raw, where an `&` in a
route would start a parameter of its own. Both now pass through
`rawurlencode_deep()`, as embedding.md asks; it lists
`atlas=%2Fgb%2Flondon` and `atlas=/gb/london` as equivalent. The
assertions that matched a raw `/` now match `%2F`.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
REQUIRE_RELEASE_ASSETS alone made Plugin Update Checker fall through to the
latest tag and install GitHub's source archive anyway, so the strategy filter
keeps only the latest release.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@sydevs-bot

sydevs-bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

🤖 no session running

recent dispatches
  • 19:02Z address-review · attempt 1 · session · done
  • 19:02Z address-review · attempt 1 · session
  • 18:52Z review-pr · attempt 1 · session · done
  • 18:52Z review-pr · attempt 1 · session

Written by the sydevs dispatcher. Sessions never edit this comment.

@sydevs-bot sydevs-bot moved this from Awaiting to Working in SYDevelopers Technical Roadmap Oct 31, 2026

@sydevs-bot sydevs-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧐 Adversarial review

Three commits, three behaviours, each with an assertion watched failing first. The diff is the size of the problem, with nothing to cut. Both premises hold upstream: SahajAtlasWeb src/lib/shape/query.ts:13 and path.ts:83 show the widget really does nest view state inside atlas=, and docs/embedding.md:132 states atlas=%2Fgb and atlas=/gb are equivalent, so rawurlencode_deep() is contract-safe and the loader decodes through URLSearchParams. The locale ladder is right to keep no copy of the list: SahajCloud's isValidLocale() is an exact match over 19 codes, nl-NL and pt are both absent, and the bare-language rung is what reaches nl. My one objection is updates.php, whose single non-platform-native line pins the vendored PUC minor version.

Findings

  • should-fix — includes/updates.php:60 pins v5p6 in a literal; a PUC bump makes it a fatal on init. The constants are on $api.
  • consider — tests/run.php:725 asserts against a hand-written array, so a PUC key rename passes while updates stop silently.

What was checked

  • Read whole: updates.php, seo.php, routing.php, embed.php:262-400.
  • Ladder: no new file, function or constant. rawurlencode_deep() and strcspn() are core and PHP, the retry a three-value foreach.
  • Vendor: Puc/v5p6/Vcs/Api.php:11-39, GitHubApi.php:358-374, ReleaseAssetSupport.php:38, load-v5p6.php. No v5\Vcs\Api alias; $branch defaults to master, so latest_release is present today.
  • Consumers: src/loader/config.ts:167-190, literals.ts:40; atlas/seo/index.ts:88-97, lib/locales/index.ts:14-32; tests/atlas-url-contract.json — 21 cases, none nesting a ?.
  • wp_unslash() still precedes the truncation, so /\evil.com stays refused.
  • settings.php:343, the third add_query_arg, takes static admin args only.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

Comment thread includes/updates.php Resolved
Comment thread tests/run.php Resolved
@sydevs-bot sydevs-bot added bot:working Lock: a cloud session is running on this item. Removed when it ends. and removed bot:working Lock: a cloud session is running on this item. Removed when it ends. labels Oct 31, 2026
The class literal spelled the vendored minor version, `v5p6`, four lines
under the `v5\PucFactory` entry point chosen to avoid exactly that, and
`load-v5p6.php` registers no version-free `v5\Vcs\Api` alias. The next
`vendor/plugin-update-checker` bump would have turned both constant reads
into a `Class not found` fatal on `init`, on all thirteen sites at once.
`pnpm lint` checks syntax, so nothing here would have caught it first.

The constants sit on the abstract `Vcs\Api` the instance in hand already
extends, so reading them off `$api` carries no version at all.

Addresses #73 (comment)

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXNHRk6rsXrYsS3a4a
The expectation was built from a hand-written array, so it proved
`array_intersect_key` and not the coupling it was written for.
`GitHubApi::getUpdateDetectionStrategies()` adds `latest_release` only on
branch `master` or `main`. The day that key leaves its set, the filter
returns an empty array, PUC chooses no reference, and no site is offered
an update again — silently, since no diagnostics check covers updates,
while a literal key keeps the assertion green.

The strategies now come from PUC, keyed by the constant rather than its
spelling. The key's presence and the fallbacks beside it are asserted on
their own, so a filter that returns nothing cannot read as a pass.

Both new assertions were watched failing: keeping `STRATEGY_LATEST_TAG`
instead fails the drop assertion, and a branch PUC offers no release for
fails the presence one.

Addresses #73 (comment)

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXNHRk6rsXrYsS3a4a
@sydevs-bot

Copy link
Copy Markdown
Contributor

Both critic threads adopted.

  • updates.php:60 — 7884aa5 reads both constants off $api, so nothing here names the vendored v5p6.
  • tests/run.php:725 — 9637d83 takes the strategies from GitHubApi::getUpdateDetectionStrategies() and keys them on the constant, asserting the key's presence and the fallbacks beside it on their own.

Both new assertions were watched failing: keeping STRATEGY_LATEST_TAG fails the drop assertion, and a branch PUC offers no release for fails the presence one.

pnpm test:all passed end to end here, so the body's note that lint and test:render could not run is gone: lint 15 files 0 errors, measure 0 failures, 432 assertions 0 failures, every render cell.

The security review ran on ^includes/ and found nothing, naming what it read. The base was already current.

🤖 Written by the sydevs autonomous loop — see what this is


Generated by Claude Code

@sydevs-bot sydevs-bot removed the bot:working Lock: a cloud session is running on this item. Removed when it ends. label Oct 31, 2026
@sydevs-bot
sydevs-bot enabled auto-merge October 31, 2026 19:17
@sydevs-bot sydevs-bot moved this from Working to Awaiting in SYDevelopers Technical Roadmap Oct 31, 2026
@Ardnived
Ardnived disabled auto-merge November 1, 2026 18:50
@Ardnived
Ardnived merged commit b374e64 into main Nov 1, 2026
38 of 39 checks passed
@Ardnived
Ardnived deleted the claude/audit-fixes branch November 1, 2026 18:50
@sydevs-bot sydevs-bot moved this from Awaiting to Done in SYDevelopers Technical Roadmap Nov 1, 2026
Ardnived pushed a commit that referenced this pull request Nov 8, 2026
* fix(seo): read a variant locale's language instead of dropping it

`sahaj_atlas_seo_locale()` anchored its pattern at `xx` or `xx-YY`, so a
WordPress locale spelled any other way matched nothing, the SEO request
carried no `locale`, and SahajCloud answered in English. #73 fixed the
regional case by retrying a refused tag as its bare language, but a locale
that never matched never entered that chain.

Real locales this refused: `de_DE_formal`, `nl_NL_formal`, `pt_PT_ao90`,
`de_CH_informal`, and every three-letter language such as `ckb`, `bal` and
`rup_MK`. A site set to "German (Formal)" handed crawlers the English title
and description.

Read the first two subtags and ignore whatever follows them, and let the
language subtag be two or three letters. The retry chain already drops a
refused tag to its bare language and then to no locale, so nothing else
changes and the plugin still keeps no copy of SahajCloud's locale list.

The new `tests/seo.php` group walks all three hops with every locale
refused, and pins that a value with no language subtag still sends none —
the guard the widened pattern needs.

Closes #80

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXvebmSqNbgVwW3jam

* refactor(test): one locale stub and one refusal stub, not four and two

The locale group added a `determine_locale` returner and a `pre_http_request`
refusal stub beside the ones the regional group already had, so the file
carried four one-line locale functions and two copies of the endpoint's 400
shape. Each also needed its own hand-paired add_filter/remove_filter, and an
unmatched one leaks a locale into every group below.

The locale is now a global one filter reads, and the refusal pattern is a third
argument to `sahaj_seo_stub()`, which `sahaj_seo_http_stub()` already owned the
response shape for. Both refusal stubs go.

`sahaj_seo_asked_locale()` replaces the hand-rolled URL probe in six
assertions, so `sahaj_is` can print the locale a failing hop actually asked for
instead of `false`.

Both halves were watched failing: the old pattern still fails four of the new
assertions, and a refusal pattern that matches nothing still fails the
regional group's two.

The production comment moves the locale inventory into the docblock and keeps
only the constraint, the #80 breadcrumb and why the refusal branch stays.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjXvebmSqNbgVwW3jam

* docs(seo): give the locale ⚠ the backtracking why

The first two sentences restated the pattern and the pattern it replaced,
neither of which a fresh reader of this file can see. What was missing is
why the trailing `(?:-|$)` is there at all: without it a two-letter variant
subtag backtracks into the region group and `be_tarask` asks for `be-TA`.

Co-Authored-By: Claude Opus 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Mg9rjYThPkR3z8N5N9mYEL

---------

Co-authored-by: Claude <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Development

Successfully merging this pull request may close these issues.

3 participants