feat(akamai-client): OAE rule-tree helpers + updateRuleTree dryRun#1825
Conversation
Support the LLM Optimizer "Optimize at Edge" Akamai onboarding in spacecat-api-service:
- defaultRuleHasCaching(ruleTree): whether the property's default rule already has a
Caching behavior. Cache ID Modification requires one in scope; the OAE rule must NOT
add its own when the default provides it (that would override the property's HTML
no-store and make the optimized path cacheable).
- getDefaultOriginSsl(ruleTree): the default rule's origin SSL verification settings,
for mirroring onto the OAE origin and gating onboarding on CUSTOM verification.
- updateRuleTree now accepts an optional { dryRun } to validate a full-tree PUT without
persisting (PAPI still requires an editable version).
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Adds a test asserting dryRun=true is appended to the query when options.dryRun is set, restoring 100% line coverage. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
This PR will trigger a minor release when merged. |
There was a problem hiding this comment.
Hey @ABHA61,
Verdict: Request changes - TypeScript declaration is out of sync with the implementation.
Complexity: MEDIUM - medium diff, single package.
Changes: Adds two rule-tree inspection helpers and a dryRun option to updateRuleTree in the Akamai client (4 files).
Must fix before merge
- [Important] TypeScript declaration missing
optionsparameter onupdateRuleTree-packages/spacecat-shared-akamai-client/src/index.d.ts(details inline) - [Important] Missing test for
getDefaultOriginSslbranch where origin behavior exists withoutoptionskey -packages/spacecat-shared-akamai-client/test/akamai-client.test.js(details inline)
Non-blocking (2): minor issues and suggestions
- nit: No test pinning the negative case (dryRun param absent from query when
options.dryRunis falsy) -test/akamai-client.test.js. The existing tests implicitly cover it via nock query matching, but an explicit case documents the contract. - suggestion: Add a test for
getDefaultOriginSslwith partialoptions(e.g. onlyverificationModeset) to document that the returned object carriesundefinedvalues for missing keys rather than omitting them -test/akamai-client.test.js.
Skill: pr-review | Model: us.anthropic.claude-opus-4-6-v1[1m] | Duration: 12m 31s | Cost: $5.61 | Commit: 98e7a6bd5ccc75b342b3b74a49da07ab67d406cd
If this code review was useful, please react with 👍. Otherwise, react with 👎.
| @@ -12,6 +12,16 @@ | |||
|
|
|||
| export function normalizeDomain(domain: string): string; | |||
|
|
|||
There was a problem hiding this comment.
issue (blocking): The updateRuleTree method signature in this file was not updated to include the new options parameter. The JS implementation now accepts 7 arguments (propertyId, version, contractId, groupId, ruleTree, ruleFormat, options = {}), but the .d.ts still declares 6. TypeScript consumers will get a compile error when passing { dryRun: true }.
The sibling method patchRuleTree already shows the correct pattern. Fix:
updateRuleTree(
propertyId: string,
version: number,
contractId: string,
groupId: string,
ruleTree: object,
ruleFormat?: string,
options?: { dryRun?: boolean },
): Promise<object>;| }); | ||
| }); | ||
|
|
||
| it('returns null when there is no origin behavior or the tree is malformed', () => { |
There was a problem hiding this comment.
issue (blocking): The implementation guards on !origin || !origin.options (two distinct branches), but the tests only cover the !origin case (behaviors: [{ name: 'caching' }]) and the fully-absent-tree case (null). A real PAPI response could return { name: 'origin' } with no options key - that branch is untested.
Given the project enforces 97% branch coverage, add:
it('returns null when origin behavior exists but has no options', () => {
expect(getDefaultOriginSsl({ rules: { behaviors: [{ name: 'origin' }] } })).to.be.null;
});…hout-options
- index.d.ts: add the options?: { dryRun?: boolean } parameter to updateRuleTree
so typed consumers can pass { dryRun: true } (was 6 args, impl accepts 7).
- test: cover getDefaultOriginSsl when the origin behavior has no options key
(distinct from no origin) for the 100% branch gate.
Addresses MysticatBot/Codex review.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Follow-up: completed the |
There was a problem hiding this comment.
Hey @ABHA61,
⚠ Degraded review - no spec document was found for this change (searched the PR links, the touched repos' docs, the architecture/guidelines docs, and linked Jira). This review covers code-level quality but could not validate the change against an agreed design, so confidence is reduced. Add a spec link (PR template section 4) and re-request review for a full-confidence pass.
Verdict: Approve - prior findings addressed, no new concerns across code quality, architecture, security, conventions, or testing.
Complexity: MEDIUM - medium diff, single package.
Changes: Adds two rule-tree inspection helpers (defaultRuleHasCaching, getDefaultOriginSsl) and a dryRun option to updateRuleTree in the Akamai client (4 files).
Previously flagged, now resolved
- TypeScript declaration for
updateRuleTreenow includes theoptionsparameter - Test added for
getDefaultOriginSslwhen origin behavior exists withoutoptionskey
Skill: pr-review | Model: us.anthropic.claude-opus-4-6-v1[1m] | Duration: 0m 3s | Cost: $3.86 | Commit: 97971d13c2276e4b3ad59801d6e00521ca9443b8
If this code review was useful, please react with 👍. Otherwise, react with 👎.
## [@adobe/spacecat-shared-akamai-client-v1.2.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-akamai-client-v1.1.0...@adobe/spacecat-shared-akamai-client-v1.2.0) (2026-07-20) ### Features * **akamai-client:** OAE rule-tree helpers + updateRuleTree dryRun ([#1825](#1825)) ([b043be2](b043be2))
|
🎉 This PR is included in version @adobe/spacecat-shared-akamai-client-v1.2.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
adobe/spacecat-shared#1825 merged and released the client as 1.2.0. Swaps the temporary gist tarball for the published version and regenerates the lockfile — resolving the merge blocker. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…g/scope gates) (#2850) ## What Reworks the Akamai "Optimize at Edge" (BYOCDN) onboarding for **CUSTOM-default** properties. **Rule builder (`llmo-akamai-utils.js`)** - Wildcard the UA match values (`*GPTBot*`) so they match real agent strings, not only an exact `GPTBot`. - Add a Caching behavior (Honor origin Cache-Control + Expires) to the OAE rule **only when the property's default rule has none**; `cacheId` is always present. - Append the managed "Optimize at Edge" wrapper **last** so its origin + cacheId win (Akamai evaluates siblings top-down, last match wins). - OAE origin host comes from `env.EDGE_OPTIMIZE_EDGE_DOMAIN` (dev/stage/live.edgeoptimize.net; defaults to live); `matchSan` (`*.edgeoptimize.net`) covers all three. **Controller (`llmo-akamai.js`)** - deploy/plan: **JSON-Patch → full-tree PUT** (`updateRuleTree`, pinned `ruleFormat`; plan uses the client's `dryRun`). - **Scope gate**: reject a non-CUSTOM default origin (`400`) *before* creating a version (no orphan version). - Optional `baseVersion` (copy from a specific version; rejects `0`); caller email in the activation note. - **Activation resilience**: the PAPI activation POST frequently exceeds the client request timeout on large trees (and a retry then returns `422 already-activated`) — in both cases Akamai has already queued the activation, so `activate` recovers by reporting the in-flight/active activation for the same version+network instead of a false failure. ## Why Validated end-to-end on `tokowaka-aem.stage.adobe.com`: an OAE-rule Caching behavior on a property that (correctly) defaults HTML to `no-store` overrides it and makes the optimized path cacheable, so Akamai replays a stale/passthrough copy to bots (v40 = 0/20 optimized at IAD). Conditional caching + full-tree PUT + the CUSTOM scope gate + append-last ordering fix it — AI bots receive `x-edgeoptimize-request-id` + `no-store`, humans pass through. ## Design High-Level Design: [Optimize at Edge — Akamai BYOCDN Automation (HLD)](https://wiki.corp.adobe.com/spaces/AEMSites/pages/3973412135/Optimize+at+Edge+-+Akamai+BYOCDN+Automation+High-Level+Design) ## Depends on adobe/spacecat-shared#1825 (merged, released as `@adobe/spacecat-shared-akamai-client@1.2.0`) — `defaultRuleHasCaching`, `getDefaultOriginSsl`, `updateRuleTree({ dryRun })`. `package.json` now pins the published `1.2.0`. ## Testing Controller + utils unit tests green, lint clean, OpenAPI updated + valid. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Akash Bhardwaj <akbhardwaj@Akashs-MacBook-Pro.local> Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
# [1.669.0](v1.668.1...v1.669.0) (2026-07-20) ### Features * **llmo-akamai:** CUSTOM-default OAE onboarding (PUT deploy + caching/scope gates) ([#2850](#2850)) ([e67e9c5](e67e9c5)), closes [Hi#Level](https://github.com/Hi/issues/Level) [adobe/spacecat-shared#1825](adobe/spacecat-shared#1825)
What
Adds tree-inspection helpers + a
dryRunoption to@adobe/spacecat-shared-akamai-client, used by the LLM Optimizer "Optimize at Edge" (BYOCDN) Akamai onboarding inspacecat-api-service.defaultRuleHasCaching(ruleTree)— whether the property's default rule already has a Caching behavior. Cache ID Modification requires a Caching behavior in scope; the OAE rule must not add its own when the default provides it (that would override the property's HTML no-store and make the optimized path cacheable — serving stale/passthrough content to AI bots).getDefaultOriginSsl(ruleTree)— the default rule's origin SSL verification settings, for mirroring onto the OAE origin and gating onboarding on CUSTOM ("Choose Your Own") verification.updateRuleTree(..., { dryRun })— validate a full-tree PUT without persisting (PAPI still requires an editable version).Why
The api-service onboarding uses a full-tree PUT and needs to (a) validate before deploy (dryRun), (b) decide whether to add a Caching behavior, and (c) enforce a CUSTOM-default-origin scope gate. These are generic PAPI rule-tree concerns, so they belong in the shared client.
Design
High-Level Design: Optimize at Edge — Akamai BYOCDN Automation (HLD)
Testing
Unit tests for both helpers (present / absent / malformed / origin-without-options trees) and the dry-run query;
npm testgreen, lint clean, 100% coverage.🤖 Generated with Claude Code