ADR 0013 — Ecosystem Bridges by Structural Typing, No Runtime Dependencies
Status: Accepted ★
Context
Section titled “Context”Overrides, grants and plan changes are exactly what @xtandard/audit exists to record; usage
thresholds (“80 % of quota”) and plan changes are natural outbound events for @xtandard/webhooks.
Neither sibling should become a dependency of this package (nor vice versa).
Decision
Section titled “Decision”@xtandard/entitlements/bridges/audit—auditHooks(audit, { tenant? })returnsafterhooks that callaudit.record({ tenant, action: "entitlements.<event>", actor, targets, metadata })for grant/override/subscription/usage-reset events. Theauditparameter is a structural type ({ record(input): Promise<unknown> }), so any compatible recorder works.@xtandard/entitlements/bridges/webhooks—webhooksEvents(webhooks, { application? })returns{ onThreshold, hooks }that callwebhooks.publish(application, { eventType, payload, idempotencyKey })forentitlements.usage.threshold,entitlements.subscription.changed,entitlements.trial.started, … Structural type again ({ publish(app, input): Promise<unknown> }).- Each bridge is tested against the real sibling package as a dev dependency.
Consequences
Section titled “Consequences”- Installing entitlements never pulls audit or webhooks; pairing them is two lines.