Skip to content

fix(engine): a page cannot cannibalise itself - #8

Merged
sheik-md-ali merged 1 commit into
mainfrom
fix/cannibalisation-counts-distinct-pages
Sep 6, 2026
Merged

sheik-md-ali merged 1 commit into
mainfrom
fix/cannibalisation-counts-distinct-pages

Conversation

@sheik-md-ali

Copy link
Copy Markdown
Owner

The keywords table told an owner to "fix rapid prototype ai development keyword cannibalization issues". They had no such problem. The stored value was:

["https://www.hitasoft.com/services/rapid-ai-prototyping",
 "https://www.hitasoft.com/services/rapid-ai-prototyping"]

One page, recorded twice.

Cause

Cannibalisation is more than one of your own pages ranking for a single keyword, so they compete with each other.

All three parsers append every matching result to cannibalisationResult, and the same URL can arrive more than once — as an organic result and again as a sitelink or a variant. The gate then asked len(...) > 1, which counts duplicates, so a single page was reported as cannibalising itself.

Fix — both ends count distinct pages

  • The parsers store distinct URLs, order preserved: that is the order the pages ranked in, which is the order a reader expects.
  • The serializer counts distinct too, so rows written before this fix read correctly without a migration — the live row above stops warning immediately.

Why it survived this long

This is a wrong answer, not an error. The feature worked; it was counting the wrong thing. Nothing crashes, no log line appears, and no test catches it by accident — it needs someone to look at a real keyword and know what cannibalisation means. A test now pins both ends.

263 tests pass.

The keywords table told an owner to "fix 'rapid prototype ai
development' keyword cannibalization issues". They had no such problem.
The stored value was:

  ["https://www.hitasoft.com/services/rapid-ai-prototyping",
   "https://www.hitasoft.com/services/rapid-ai-prototyping"]

One page, recorded twice.

Cannibalisation is more than one of YOUR OWN pages ranking for a single
keyword, so they compete with each other. All three parsers append every
matching result to cannibalisationResult, and the same URL can arrive
more than once -- as an organic result and again as a sitelink or a
variant. The gate then asked `len(...) > 1`, which counts duplicates, so
a single page was reported as cannibalising itself.

Both ends now count DISTINCT pages:

  * the parsers store distinct URLs, order preserved -- that is the
    order the pages ranked in, which is the order a reader expects;
  * the serializer counts distinct too, so rows written before this fix
    read correctly without a migration. The live row above stops
    warning immediately.

This is a wrong answer rather than an error, which is the kind no test
catches by accident: the feature worked, it was just counting the wrong
thing. A test now pins both ends.
@sheik-md-ali
sheik-md-ali merged commit fb95aca into main Sep 6, 2026
2 checks passed
@sheik-md-ali
sheik-md-ali deleted the fix/cannibalisation-counts-distinct-pages branch September 6, 2026 16:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant