Skip to content

contrib: add experimental feature flag pattern for x402 signer policies - #342

Open
arandomogg wants to merge 1 commit into
Vellar-Wallet:devfrom
arandomogg:contrib/issue-284-experimental-signer-policy-flag
Open

contrib: add experimental feature flag pattern for x402 signer policies#342
arandomogg wants to merge 1 commit into
Vellar-Wallet:devfrom
arandomogg:contrib/issue-284-experimental-signer-policy-flag

Conversation

@arandomogg

Copy link
Copy Markdown

Summary

Adds a self-contained reference implementation under contrib/examples/issue-284-experimental-signer-policy-flag/ demonstrating a feature-flag pattern for gating experimental x402 signer policy behavior, so early-adopter consumers can opt in without a hard breaking change for everyone else.

Scoped entirely to contrib/ per CONTRIBUTING.md and contrib/README.md.

The pattern

An experimental signer policy change ships behind a named experimental* boolean on the signer config:

  1. The new behavior lives behind a named experimental* flag.
  2. Omitted / false reproduces today's behavior exactly.
  3. true opts into the new (here, stricter) behavior.
  4. Validation runs at construction, not sign time, so a bad config fails loudly before it can ever sign.

The behavior being gated

Capability rules accept a "*" wildcard for resourceType / action. A wildcard left behind after copy-pasting an example silently widens what a session key will sign, but tightening it by default would break every config that relies on wildcards. So it's gated behind experimentalStrictWildcardCapabilities:

Config Unflagged (default) Flagged (true)
[{ resourceType: usdc, action: "*" }] accepted, signs rejected at construction
[{ resourceType: usdc, action: "transfer" }] accepted, signs accepted, signs (unchanged)
capabilities omitted entirely permits everything permits everything (unchanged)

Files

  • experimental-signer-policy-flag.ts — the flag pattern, capability rule validation/evaluation, and a mock signer that applies the flag at construction. Includes a runnable main() demo.
  • experimental-signer-policy-flag.test.ts — 20 tests.
  • README.md — documents the pattern, a usage example, the behavior table above, and the risks of enabling the flag.

Requirements checklist

  • Experimental flag pattern for opting into new signer policy behavior
  • Default behavior unchanged when the flag is not set
  • Test verifying flagged and unflagged behavior differ as expected
  • Flag and its risks documented (in the example's README, since this PR is scoped to contrib/)

Test plan

npx vitest run contrib/examples/issue-284-experimental-signer-policy-flag

20 tests, all passing. The runnable demo was verified to produce the expected unflagged-accepts / flagged-rejects / explicit-rules-unaffected output.

closes #284

Self-contained reference for issue Vellar-Wallet#284 under contrib/examples. Demonstrates
gating experimental signer policy behavior behind a named experimental* flag
so early adopters can opt in without a breaking change for everyone else.

The gated behavior: capability rules accept a "*" wildcard by default, and a
wildcard left behind after copying an example silently widens what a session
key will sign. Setting experimentalStrictWildcardCapabilities rejects any
wildcard rule at construction, requiring fully explicit rules. Omitted or
false reproduces current behavior exactly.

Includes 20 tests covering rule validation, capability evaluation, and that
flagged and unflagged construction diverge only on wildcard rules, plus a
README documenting the pattern and the risks of enabling the flag.
@vercel

vercel Bot commented Aug 29, 2026

Copy link
Copy Markdown

@arandomogg is attempting to deploy a commit to the david's projects Team on Vercel.

A member of the Team first needs to authorize it.

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