Skip to content

@adcp/sdk/lint: build-time credential-discipline detection (eslint plugin) #1541

@bokelley

Description

@bokelley

Problem

Surfaced during expert DX review of #1535.

The args.<vendor>_access_token pattern in adopter extractContext implementations is widespread — every v5 adapter we ship reads it, and the pattern recurs in adapter-side fan-out paths because extractContext's args: Record<string, unknown> makes the unsafe read trivial.

Runtime rejection via credentialPolicy: 'authInfo-only' (#1535) catches these at dispatch time, but build-time detection beats runtime detection — adopters see the issue when they write the code, not when a buyer's request hits production.

Proposal

Ship @adcp/sdk/lint (or npx adcp-doctor mode) — a static-analysis tool that scans adopter codebases for the extractContext-credential-read antipattern.

Concrete starting rule set:

  1. no-credential-read-from-args — flag args.<word>_access_token / args.<word>_secret / args.<word>_password / args.context.<word>_access_token reads in any function whose name matches /^extract(Context|Operational)Context$/ or whose declaring object has OperationalPlatform as a type.
  2. require-account-store-resolve-for-credentials — flag any args.access_token read outside a resolveAccount callback or extractContext.
  3. prefer-authinfo-credential-channel — suggestion-level: code that reads from args.<credential> should consider ctx.authInfo.token / ctx.authInfo.credential instead.

Distribution:

  • (a) ESLint plugin (@adcp/sdk/eslint-plugin) — fits adopter CI, low integration cost
  • (b) npx adcp-doctor mode — one-shot scan, useful for adopters not on ESLint

Recommend (a) primary, (b) as wrapper.

Related

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions