Skip to content

feat(aem-eds-personalization): add detect-personalization and let personalize build from its inventory - #858

Open
srshrm wants to merge 2 commits into
adobe:mainfrom
srshrm:feat/aem-eds-personalization-detect
Open

srshrm wants to merge 2 commits into
adobe:mainfrom
srshrm:feat/aem-eds-personalization-detect

Conversation

@srshrm

@srshrm srshrm commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator

What and why

New skill detect-personalization. Before a migration to EDS, it finds what a source site personalizes:

  • which regions change, and for which visitor (device, new/returning, UTM param, referrer, geo, segment);
  • where it's decided: server, edge or browser;
  • through what: a vendor (Target, Web SDK/AJO, Optimizely, Dynamic Yield…), the site's own rule engine (for example Milo MEP manifests) or a site script.

The agent drives the workflow from the instructions:

  1. It loads each page as several visitors: curl for the raw HTML and headers, and scripts/probe.mjs in a browser.
  2. It subtracts the noise between two identical loads, then explains every difference.
  3. It writes personalization-detect/personalization-inventory.json. Each region gets its proposed Personalization … Section Metadata rows and the source copy of its variants.
  4. It checks every proposed section with personalize's own section-spec.js. Rows that wait for an owner's value (<…>) are reported, never guessed.

personalize change. It builds from such an inventory only when the project holds one, or the prompt names one. That's one paragraph in Step 2, and the procedure is in the new reference/from-inventory.md:

  • it matches each region to the migrated page's section by text;
  • it uses the captured source copy instead of TODO: in the fragments;
  • it turns open values into the usual grouped choices;
  • it skips vendor-owned, locale and noise regions, with the reason.

Without an inventory, personalize works as it does today.

New script, network access and endpoints:

  • skills/detect-personalization/scripts/probe.mjs (Playwright).
    • Network: it loads the user's source site in headless Chromium, once per visitor, and blocks vendor decision URLs for the authored-default load.
    • Read-only: it clicks nothing but a consent banner's accept button.
    • Stops on a refusal: a 403, 429, 503 or reset connection ends the run, with no retry using another client or user agent.
    • Saved data: cookie names only, never values; identity handles are removed from saved decision responses.
  • The eval fixture evals/detect-personalization/fixtures/serve.mjs listens on 127.0.0.1 only, and stops itself after a TTL.
  • No MCP server, no hook, and no third-party endpoint of our own.

How I checked it

  • npm ci && npm run validate && node scripts/check-release-configs.mjs: pass.

    • npm run plugins:check: only the generated manifests are behind plugin.json, which CI rebuilds.
    • node scripts/check-skills.mjs --tokens plugins/aem/edge-delivery-services-personalization: detect-personalization is 3,126 of 5,000 tokens, personalize 4,284 of 5,000 (both have an eval).
  • Tests:

    • detect-personalization: node --test scripts/test/*.test.mjs passes 4 of 4, including a browser run against the fixture site.
    • personalize: npm test passes 515, with 3 skipped (unchanged).
  • Real sites. Fresh agents ran the skill with nothing but the skill to follow. Their feedback is folded in.

    Site Pages Result
    adobe.com /, /creativecloud.html All client-side, through Milo MEP fed by Target and Web SDK. 8 regions; geo rules from the manifests (geo: AE, SA, …, !geo: US); mixed regions as api with target as the alternative. All 6 proposed sections pass the check
    frame.io /, /pricing Edge variants from Next.js middleware (x-matched-path): the hero by device, and pricing by company, which is an owner question
    quickbooks.intuit.com — The bot manager refused curl and headless Chromium. The skill stops and asks for an allowlist, as designed
    • probe.mjs was also run on frame.io. It reproduced the agent's finding: the Web SDK decision fires only on the second page view.
  • personalize from an inventory. A fresh agent ran on the personalize-from-inventory scenario's project:

    • it built 5 of 7 regions, matched by text, with the source copy;
    • it left out the pending <segment> value;
    • it listed the locale and noise regions as not built;
    • the validator, the simulator and lint passed; verify-preview was reported as not run (no aem up).
  • New scenarios: evals/detect-personalization (fixture site with server- and client-side regions, started by setup.sh) and evals/personalize-from-inventory (migrated DA home page plus an inventory).

    • Not yet run with skill-eval.mjs. Run:

      node scripts/skill-eval.mjs --client claude --plugin plugins/aem/edge-delivery-services-personalization --scenario plugins/aem/edge-delivery-services-personalization/evals/<scenario> --auth-home "$HOME" --timeout 1800 --max-turns 80
      

Found by the personalize trial, but outside this PR (a follow-up fix):

  • the --apply-hook import lacks eslint-disable import/no-cycle, so boilerplate lint fails;
  • detect-project reports OneTrust from a code comment;
  • there is no warning when a variant's H1 differs;
  • simulate.mjs prints no PASS/FAIL line.

Checklist

  • The change is to one plugin, or to repository tooling
  • npm run validate passes
  • Paths, commands and skills that the change names exist
  • New scripts, hooks, MCP servers or network endpoints are called out above
  • The human label is set, if a person and not an agent wrote this

🤖 Generated with Claude Code

…sonalize build from its inventory

detect-personalization finds what a source site personalizes before a
migration: the agent loads each page as several visitors (curl for the
server side, scripts/probe.mjs in a browser for the client side), subtracts
noise, explains every difference (criterion, server/edge/client, vendor or
site rule engine) and writes personalization-inventory.json with proposed
Section Metadata rows, checked with personalize's own section-spec.js.

personalize uses that inventory only when the project holds one (new
reference/from-inventory.md); without one it behaves as before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

claude: approved on 6c5b6ba

This is a second-round review of 6c5b6ba. The pull request adds a detect-personalization skill to aem-eds-personalization. It probes a source site with curl and scripts/probe.mjs (Playwright) and writes personalization-inventory.json. It also adds a paragraph to personalize, plus reference/from-inventory.md, so that personalize builds from that inventory when the project has one. Two eval scenarios come with it.

The fork's author has write access, so I reviewed the change itself. I read the code and ran none of it.

The earlier rounds raised two kinds of issue: codex's denial that refusal handling failed open, and three drift comments from claude. All are fixed in the head:

  • Browser probe: every navigation in probe.mjs goes through navigate() and refused() and stops the run with exit 3. That covers the first load, the consent reload and the --second-view reload. The return await stop() keeps the browser from closing in finally before the stop is written.
  • curl pass: fetch() in reference/probing.md returns 1 on a curl error or a 403, 429 or 503, and the visitor sequence is an && chain, so nothing else is requested after a refusal. Cookie values are still redacted from the saved headers.
  • Playwright pin: probe.mjs imports PLAYWRIGHT_CACHE and PLAYWRIGHT_INSTALL from personalize/scripts/lib.mjs. Both exist there, so the plugin has one pin managed by Renovate.
  • Wording: the step reference in vendors.md and the "no detection script" sentence are corrected.

Other checks:

  • The Check command in inventory-contract.md points at personalize's section-spec.js, which exists.
  • from-inventory.md states that the inventory is data and never overrides consent or the instructions.
  • plugin.json changes only its descriptions: no version and no generated manifest.
  • The two setup.sh scripts only start a local server on 127.0.0.1 with a TTL, and clone aem-boilerplate at a pinned commit.
  • The description calls out the new script and its network use.

Nothing new and serious turned up. Per the strict-review rules, there was no baseline probe and no test drive.

- **Record cookie names, never their values.** No values, tokens or personal data in any output.
Delete the curl cookie jars and Playwright storage-state files when the pass is done.
- Playwright is never installed into the site's repository. Install the pinned
`playwright@1.65.0` with `npm i --prefix ~/.cache/aem-eds-personalization/playwright` (a version

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.

claude: This pins playwright@1.65.0, here and again in scripts/probe.mjs:172. The personalize skill in the same plugin installs into the same cache, ~/.cache/aem-eds-personalization/playwright. There the pin is PLAYWRIGHT_VERSION = '1.65.1', in personalize/scripts/lib.mjs, with a renovate: marker so Renovate updates it. The two skills will keep drifting apart, and whichever runs second reinstalls over the other's version. Use one version: for example, have probe.mjs import PLAYWRIGHT_INSTALL from ../../personalize/scripts/lib.mjs, or add the same Renovate marker and the same version here.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 6c5b6ba: probe.mjs now imports PLAYWRIGHT_CACHE and PLAYWRIGHT_INSTALL from personalize/scripts/lib.mjs, so the plugin has one Renovate-managed pin and one shared cache. SKILL.md no longer names a version: it says to run the install command the script prints.


## Reading decisions

Save the decision responses (`reference/probing.md` § Client-side, step 2), and read only the

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.

claude: reference/probing.md § Client-side, step 2: the Client-side section of probing.md has no numbered steps. Point at the <visitor>-decision-<n>.json row of the table there instead.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 6c5b6ba: vendors.md now points at the files scripts/probe.mjs writes, <visitor>-decision-<n>.json, which are described in the table in probing.md § Client-side.

- **server or edge**: the difference is already in the raw HTML `curl` receives;
- **client**: the raw HTML is the same, and the rendered DOM differs.

You drive the whole workflow; there is no detection script. `reference/probing.md` has the

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.

claude: "there is no detection script" contradicts scripts/probe.mjs, which Step 3 tells the agent to run. Say what is meant, for example "no script compares or explains the differences: you do", so an agent doesn't look for a script or skip the probe.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 6c5b6ba: "You drive the whole workflow. scripts/probe.mjs only collects the browser captures; no script compares or explains the differences: you do."

@github-actions

github-actions Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

codex: approved on 6c5b6ba

The change adds source-site personalization detection and an inventory handoff to personalize, consistent with the description. Static review confirms that the previously reported browser and curl refusal paths now stop the probe, with browser regression coverage added. Changed JSON files parse successfully. No fork code, installs, tests, baseline probes or client evals were run, as required by the strict review rules.

await settle(page, wait);
if (spec.consent) {
meta.consentClicked = await acceptConsent(page);
await page.reload({ waitUntil: 'domcontentloaded' }).catch(() => {});

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.

codex: The refusal check covers only the initial page.goto. Both reload paths discard the response and swallow navigation errors, so a 403/429/503 or connection reset on the consent reload or --second-view reload is captured as successful evidence, and the probe continues with another visitor. This bypasses the promised stop-on-refusal guard. Apply the same refusal handling to every navigation and add tests proving that a refused reload stops subsequent visitors.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 6c5b6ba. Every navigation, the first load and both reloads (consent, and --second-view), goes through the same navigate() + refused() check. A 403, 429 or 503, or a navigation error, writes the visitor meta with blocked and refusedAt (load or reload), saves no capture, and stops all later visitors with exit 3. Regression tests: refused() unit cases, and a browser run against the fixture server with --refuse-after 1, where the consent reload gets 429 and the test asserts no capture and no later visitor. While writing that test I found and fixed return stop() inside the try: the finally closed the browser before stop() had finished, so it is now return await stop().

E=personalization-detect/evidence/home; mkdir -p "$E"
fetch() { # fetch <visitor> <url> [curl options…]
local v=$1 u=$2; shift 2
curl -sS -L --compressed --max-time 30 -A "$UA" -H 'Accept-Language: en-US,en;q=0.9' \

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.

codex: This fetch helper never checks the HTTP status or propagates curl failures: curl treats 403/429/503 as success here, and a transport failure is followed by perl and sleep, leaving the function successful. Consequently the supplied sequence continues through other visitors, including a different user agent, after refusal. Make the sequence terminate on refused responses or transport errors before sending another request, matching the skill's stated guard.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Fixed in 6c5b6ba. fetch() now captures %{http_code}. A non-zero curl exit (reset, HTTP/2 error, timeout) or a 403, 429 or 503 prints REFUSED <visitor> … Stop the probe and returns 1. The visitor sequence is an && chain, so nothing after a refusal is requested, including the mobile-UA fetch. I ran the block as written, in bash and in zsh, against the fixture server with --refuse-after 2: the chain stopped at the first 429 with exit 1. Without refusals, all 7 visitors were fetched with exit 0, and cookie values were redacted.

@srshrm srshrm self-assigned this Dec 1, 2026
…fusal and share personalize's Playwright pin

- probe.mjs: the consent and --second-view reloads go through the same refusal check as the
  first load (403/429/503 or a navigation error stops every later visitor); regression test
  with a fixture server that refuses after n page requests
- probing.md: the curl helper checks curl's exit code and the HTTP status, and the visitor
  sequence is an && chain, so a refusal ends it before another request
- probe.mjs installs Playwright with personalize's PLAYWRIGHT_INSTALL (one Renovate-managed pin)
- SKILL.md, vendors.md: no "no detection script" contradiction, no pointer to a missing step

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@srshrm

srshrm commented Dec 1, 2026

Copy link
Copy Markdown
Collaborator Author

Re the codex denial: both refusal paths now fail closed, and both are tested (6c5b6ba).

  • Browser probe: the consent and --second-view reloads get the same refusal check as the first load. A refused reload stops every later visitor; covered by a new test with a fixture server that answers 429 after n page requests.
  • curl pass: fetch() checks the curl exit code and the HTTP status, and the visitor sequence is an && chain, so a refusal ends it before any other request. Run as written in bash and zsh against the refusing fixture server.

The three claude comments (Playwright pin, the missing step reference, the "no detection script" sentence) are fixed in the same commit. Checks: npm run validate, check-release-configs, and the detect-personalization tests 6/6, including both browser runs.

@srshrm
srshrm requested review from hmehta-adobe and ramboz December 1, 2026 07:54

@ramboz ramboz left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Summary

This adds source-site detection and an inventory handoff to the existing DA/EDS personalize flow. The implementation from #577 landed through #702, so this is an incremental follow-up, not a replacement runtime. The direction is useful; I'd address the four capture and stopping cases inline before relying on the probe as migration evidence.

Strengths

  • The producer checks proposed rows with personalize's own grammar. The consumer preserves authored defaults and converts captured copy into the migrated site's blocks instead of publishing source markup.
  • The inventory explicitly cannot override consent, delivery confirmations or checks. Unknown copy stays a scaffold, and skipped regions remain visible in the summary.
  • The reload refusal fixes and shared Playwright pin are present in this head. Those earlier threads are addressed; S3 has a different trigger.

Issues

Should Fix

  • S1 / S2: Cookie values can remain in saved evidence through the curl failure path and supported Dynamic Yield response bodies.
  • S3: Challenge responses outside the three listed HTTP statuses do not stop the probe.
  • S4: The scroll pass has no bound when the page keeps growing.

The inline comments give the input, affected path and a focused regression case for each.

Out of Scope, Worth Tracking

  • Shared runtime ownership and versioning can remain a follow-up, as in the earlier public review. This discovery slice doesn't need to add other AEM authoring models or extract a new execution layer.

Verdict

Ready to merge: With fixes

Reasoning: The remaining defects are in the new probe and its capture recipe. Q1 is a migration-ownership choice, not another runtime defect or a request to widen this PR.

Open questions

Q1 is inline on the vendor experiment mapping: preserve the native owner, or explicitly start a new local experiment?

Reviewed at 6c5b6ba. All 39 changed files and targeted base context were read; no PR code, installs, tests or evals were run. CI reports no failures, but the scenario-eval job is skipped. This is not live Target/OF1 qualification. No independent ticket or specification is linked; the helper's impact scan is not a complete call graph.

Reviewed with GitHub Copilot.

local v=$1 u=$2 code rc; shift 2
code=$(curl -sS -L --compressed --max-time 30 -A "$UA" -H 'Accept-Language: en-US,en;q=0.9' \
-D "$E/$v.headers" -o "$E/$v.html" -w '%{http_code}' "$@" "$u") \
|| { rc=$?; echo "REFUSED $v: curl error $rc. Stop the probe: no other client or user agent" >&2; return 1; }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

S1. Redact saved headers on the curl error path too.

-D can write Set-Cookie before the response body stalls or a followed redirect fails. In either case curl exits nonzero here, so this return skips the redaction on the next line. The saved <visitor>.headers then retains cookie values, contrary to the skill's names-only rule, precisely when the agent is told to stop.

Could we sanitize or remove the partial header file before either return, and clean the cookie jar on failure too? A fixture that sends Set-Cookie and then stalls its body would cover the path without calling a real site.

Perspective: SRE / Reliability, Security

}
} else if (v && typeof v === 'object') {
Object.keys(v).forEach((k) => {
if (/^(ecid|mcid|tntid|tnt_?id|visitorid|marketingcloudvisitorid|identitymap|id5|uuid|sessionid)$/i.test(k)) delete v[k];

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

S2. Remove cookie values from captured Dynamic Yield decisions.

Dynamic Yield is a supported decision source, and its documented Choose response includes cookies: [{ name, value, maxAge }] for _dyid_server and _dyjsession. None of those keys matches this filter. The response handler therefore keeps the visitor/session values and writes them into <visitor>-decision-<n>.json.

Please retain only cookie names, or allowlist the decision fields the inventory needs, before saving the response. A redaction test using that documented response shape would catch this alongside the existing Adobe identity test. This is a saved-evidence privacy issue; I'm not treating these probe-generated identifiers as account credentials.

Perspective: Security, QA / Testing


/** True when a navigation was refused: an error (reset, HTTP/2, timeout) or 403, 429, 503. */
export function refused({ status, error }) {
return !!error || [403, 429, 503].includes(status);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

S3. Stop on challenge responses as well as the three status codes.

The reload fix is in place. The remaining gap is what counts as a refusal: AWS WAF documents 202 with x-amzn-waf-action: challenge, and 405 with x-amzn-waf-action: captcha. Both pass this check. navigate() keeps only the status, so the script can save the interstitial as page evidence and continue with later visitors, including a different user agent. The curl recipe has the same three-code check.

Please carry challenge signals into the refusal result and stop the whole site's pass when they are present. Recognized headers, including Cloudflare's documented cf-mitigated: challenge, are more precise than treating every 202 as a refusal. Cover a challenge on both the initial load and a reload, and the equivalent curl path.

Perspective: SRE / Reliability, Product / Consumer Impact

await page.waitForLoadState('networkidle', { timeout: wait }).catch(() => {});
await sleep(1500);
await page.evaluate(async () => {
for (let y = 0; y < document.body.scrollHeight; y += 800) { window.scrollTo(0, y); await new Promise((r) => { setTimeout(r, 120); }); }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

S4. Bound the scroll pass independently of network idle.

This loop reads the current scrollHeight after every scroll. On an infinite-scroll page, newly appended content keeps moving the end of the loop. --wait only bounds the earlier networkidle wait, and this page.evaluate() has no execution deadline, so one visitor can prevent the run from finishing.

Please cap the scroll distance or iterations and add a wall-clock bound that also stops the page-side loop. Report a capped capture as incomplete. A fixture that appends content near the bottom can verify that the probe still returns and closes its browser.

Perspective: SRE / Reliability, LLM / AI Systems

- Target's `trafficType`, an `experiment` in the activity type, or Optimizely or VWO, whose
activities are experiments unless the audience says otherwise.

That makes the region `split` (personalize's section A/B), or `target` for an Adobe A/B

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Q1. Who owns a detected experiment after migration?

Should observing a vendor A/B activity keep that product as the default owner, or offer a new local experiment only after the owner explicitly chooses the replacement?

This mapping proposes split; plugins/aem/edge-delivery-services-personalization/skills/detect-personalization/reference/inventory-contract.md:75 makes unknown weights even, and plugins/aem/edge-delivery-services-personalization/skills/personalize/reference/from-inventory.md:25 builds medium/high-confidence proposals. Together with the hands-off defaults, an observation can become a new local allocation without a decision to replace the native activity. Seeing two experiences doesn't establish the original traffic weights or assignment continuity.

One option is target, keep-vendor or needs-owner-input until the owner chooses. The other is an explicit new local experiment, with its split supplied and the restart called out. Either fits this inventory workflow; I would keep the observation separate from that ownership choice.

Needs an answer: no

Perspective: Architecture, Product / Consumer Impact

This branch has not been deployed

No deployments
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.

2 participants