Skip to content

docs: surface auto-hydration error contract + tighten idempotency principal types - #1126

Merged
bokelley merged 2 commits into
mainfrom
bokelley/preship-final
Apr 30, 2026
Merged

bokelley merged 2 commits into
mainfrom
bokelley/preship-final

Conversation

@bokelley

Copy link
Copy Markdown
Contributor

Summary

Pre-ship cleanup driven by an adopter ranking three asks against the v6.0 RC. #1 was the only blocker — the auto-hydration contract on missing references multiplies across four mutating verbs but only the happy path was in adopter-facing docs. #2 was a polish carry-over from round 12. #3 was a docs question already addressed.

What changed

#1 (BLOCKER) — Auto-hydration error contract surfaced in the migration doc

Framework behavior on a hydration miss has been documented in source JSDoc since the auto-hydration extension landed (from-platform.ts:2076-2135), but adopters reading the skill see only the happy path. The user listed three options the changeset should spell out:

  1. Framework throws typed AdcpError, handler never runs.
  2. Framework leaves field undefined, handler chooses what to do.
  3. Framework calls handler anyway with whatever stale shape it has.

Actual behavior is #2 (silent miss, handler authoritative), with thoughtful rationale: a miss can mean cold start, cache eviction, OR a truly unknown id; the framework can't distinguish without consulting the publisher's DB, which is what the handler already does. Erroring at the framework would force every adopter to manage cache warmth before serving traffic — wrong default for a hint cache.

New "Auto-hydration error contract" block in docs/migration-5.x-to-6.x.md covers:

  • The three possible meanings of a miss
  • Why the framework picks Fix Fly.io deployment timeout issues #2
  • The handler-side existence-check pattern with a typed-error example
  • The __adcp_hydrated__ non-enumerable marker for disambiguation
  • Store-fetch failure semantics (logged + swallowed; handler runs)

#2 (polish) — IdempotencyPrincipalParams.account / .brand now use canonical wire types

Was inline-typed as a flat shape with everything optional. Adopters overriding the default resolveIdempotencyPrincipal to scope by params.account?.account_id (public-token-shared-across-tenants pattern) had to live with the loose shape. Replaced with AccountReference / BrandReference from the generated wire types so the discriminated union is exposed end-to-end. JSDoc updated with the recommended if ('account_id' in params.account) pattern.

#3 (docs) — Migration doc consolidation verified

The cumulative breaking-changes table at docs/migration-5.x-to-6.x.md:22-28 already covers all five round-by-round breaking changes with one-liner search-replace recipes (Account.metadata rename, server-subpath consolidation, createAdcpServer removal, TMeta → TCtxMeta, getMediaBuys required). No edits needed.

Why land before the v6.0.0 release-PR (#1085)

#1085 is open and unmerged. Landing this on main causes the changesets bot to rebase #1085 with the new docs + tighter type baked into 6.0.0 directly. Adopters install clean. No 6.0.1 needed for these asks.

Test plan

  • npm run build clean
  • npm run format:check clean
  • 267/267 server-side tests pass (state-store, decisioning, create-adcp-server, idempotency)
  • IdempotencyPrincipalParams typecheck against AccountReference/BrandReference passes
  • CI green on this PR
  • Verify release-PR chore: release package #1085 auto-rebases with these docs + types

Related

🤖 Generated with Claude Code

bokelley and others added 2 commits April 30, 2026 18:58
…ncipal types

Adopter pre-ship feedback on v6.0 RC, three asks ranked by user.

#1 (BLOCKER): Auto-hydration error contract surfaced in migration doc.
  Framework behavior on a hydration miss was documented in source
  JSDoc since the extension landed (from-platform.ts:2076-2135), but
  adopters reading the skill saw only the happy path. New "Auto-
  hydration error contract" block in migration-5.x-to-6.x.md walks
  the three possible meanings of a miss (cold start, eviction,
  unknown id), explains why the framework does NOT throw
  PRODUCT_NOT_FOUND / MEDIA_BUY_NOT_FOUND (cache is a hint, not
  source-of-truth), shows the handler-side existence-check pattern,
  and describes the __adcp_hydrated__ non-enumerable marker.

#2 (polish): IdempotencyPrincipalParams.account / .brand now use
  canonical AccountReference / BrandReference wire types instead of
  the inline-typed flat shape. Adopters overriding the default to
  scope by account_id or brand.domain (the public-token-shared-
  across-tenants pattern) get autocomplete + narrowing on both
  variants of the discriminated union. JSDoc updated with the
  recommended `if ('account_id' in params.account)` pattern.

#3 (docs): Migration doc consolidation verified. The cumulative
  breaking-changes table at the top of migration-5.x-to-6.x.md
  already covers all five round-by-round breaking changes with
  one-liner search-replace recipes — no edits needed.

267/267 server-side tests pass. format:check clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
…s-link

Two surgical follow-ups to the dx-expert review of PR #1126:

1. Migration-doc handler-side existence-check example used
   `MediaBuyNotFoundError` without showing the import. Adopters
   copy-pasting got `Cannot find name`. Added the import line and
   pointed at the typed-error class catalog (`@adcp/sdk/server/
   decisioning/errors-typed`) so adopters reach for the typed
   classes (which auto-map to wire error codes with `recovery:
   'terminal'`) instead of bare `AdcpError`.

2. `skills/build-seller-agent/SKILL.md:81` mentioned auto-hydration
   in one sentence with no error contract. Added a one-line
   blockquote pointer to the new "Auto-hydration error contract"
   section in the migration doc — adopters reading the seller skill
   first now find the contract on the path they actually take, not
   buried in source JSDoc.

`build-decisioning-platform/SKILL.md` already had the contract
inline at lines 99-109 (CONTRACT comment block) — verified, no
edits needed.

Co-Authored-By: Claude Opus 4.7 (1M context) <[email protected]>
@bokelley
bokelley merged commit 5f56f10 into main Apr 30, 2026
10 checks passed
@bokelley
bokelley deleted the bokelley/preship-final branch April 30, 2026 23:08
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