On this page:
permit-grant-policy?
permit-constraints-policy?
permit-entitlement-policy?
permit-policy-catalog?
make-permit-grant-policy
make-permit-constraints-policy
make-permit-entitlement-policy
make-permit-policy-catalog
prepare-permit-snapshot
permit-snapshot-request?
permit-snapshot-request-payload-bytes
permit-policy-for-offer

6 Offer-to-Permit policy mapping🔗ℹ

 (require commerce/permit) package: commerce

Server processes explicitly require commerce/permit. This module imports the published permit/issuer snapshot surface; it is not re-exported from the default facade and never accesses a signing key.

procedure

(permit-grant-policy? value) → boolean?

  value : any/c
Recognizes one validated grant policy.

procedure

(permit-constraints-policy? value) → boolean?

  value : any/c
Recognizes one validated constraints policy.

procedure

(permit-entitlement-policy? value) → boolean?

  value : any/c
Recognizes one immutable, versioned entitlement policy.

procedure

(permit-policy-catalog? value) → boolean?

  value : any/c
Recognizes one reviewed policy catalog.

procedure

(make-permit-grant-policy [#:products products 
  #:product-families product-families 
  #:edition edition 
  #:feature-policy feature-policy 
  #:features features 
  #:addons addons 
  #:capabilities capabilities]) 
 → permit-grant-policy?
  products : (or/c hash? #f) = #f
  product-families : (or/c hash? #f) = #f
  edition : (or/c string? #f) = #f
  feature-policy : (or/c 'explicit 'published-through) = #f
  features : (or/c hash? #f) = #f
  addons : (or/c hash? #f) = #f
  capabilities : (or/c hash? #f) = #f
Constructs one reviewed grant policy. Optional Commerce values use #f; the adapter translates absence to Permit null. The smart constructor validates the resulting grant through Permit’s complete entitlement schema.

procedure

(make-permit-constraints-policy 
  [#:use-expires-at use-expires-at 
  #:use-duration-months use-duration-months 
  #:updates-through updates-through 
  #:features-through features-through 
  #:version-min version-min 
  #:version-max version-max 
  #:named-seats named-seats 
  #:device-activations device-activations 
  #:concurrent-seats concurrent-seats 
  #:installation-id installation-id 
  #:activation-required? activation-required?]) 
 → permit-constraints-policy?
  use-expires-at : (or/c string? #f) = #f
  use-duration-months : (or/c exact-positive-integer? #f) = #f
  updates-through : (or/c string? #f) = #f
  features-through : (or/c string? #f) = #f
  version-min : (or/c string? #f) = #f
  version-max : (or/c string? #f) = #f
  named-seats : (or/c exact-nonnegative-integer? #f) = #f
  device-activations : (or/c exact-nonnegative-integer? #f) = #f
  concurrent-seats : (or/c exact-nonnegative-integer? #f) = #f
  installation-id : (or/c string? #f) = #f
  activation-required? : boolean? = #f
Constructs the complete constraints policy and validates timestamps, SemVer bounds, limits, installation binding, and activation shape through Permit. #:use-duration-months opts initial grants into UTC calendar-month expiry derived from authenticated #:paid-at; it is mutually exclusive with fixed #:use-expires-at. Short destination months clamp the day while preserving time of day. Missing payment evidence refuses; the issuer reconciles repeat orders and full refunds against the scoped authenticated journal (ADR-0026); this does not enable checkout.

procedure

(make-permit-entitlement-policy 
  id 
  version 
  #:subject-type subject-type 
  #:grants grants 
  [#:constraints constraints 
  #:withdrawal-mode withdrawal-mode]) 
 → permit-entitlement-policy?
  id : string?
  version : exact-positive-integer?
  subject-type : string?
  grants : permit-grant-policy?
  constraints : permit-constraints-policy? = #f
  withdrawal-mode : symbol? = 'expire-at-issuance
Binds one policy id, audit version, subject type, grants, and optional constraints. Policy ids are immutable revisions; the positive integer version is audit metadata and never selects a mutable latest policy.

procedure

(make-permit-policy-catalog 
  offers 
  policies 
  [#:deleted-offer-ids deleted-offer-ids]) 
 → permit-policy-catalog?
  offers : hash?
  policies : hash?
  deleted-offer-ids : (listof string?) = '()
The catalog contains both active and retained retired Offer definitions. Explicit deletion tombstones are distinct from never-known Offer ids. Every Offer’s product must occur in the explicit product scope of its pinned policy.

procedure

(prepare-permit-snapshot catalog 
  intent 
  #:issuer issuer 
  #:credential-id credential-id 
  #:entitlement-id entitlement-id 
  #:issued-at issued-at 
  [#:previous previous 
  #:use-expires-at use-expires-at 
  #:paid-at paid-at]) 
 → permit-snapshot-request?
  catalog : permit-policy-catalog?
  intent : rights-intent?
  issuer : string?
  credential-id : string?
  entitlement-id : string?
  issued-at : string?
  previous : (or/c hash? #f) = #f
  use-expires-at : (or/c string? #f) = #f
  paid-at : (or/c exact-positive-integer? #f) = #f
For 'grant, creates a complete entitlement at revision 0 and rejects an existing lineage. For 'withdraw, requires the previous complete snapshot, checks issuer, entitlement id, subject, type, and grants, advances its revision, and sets use_expires_at to the new issued_at. This communicates an issuance-expiring successor to connected clients; it does not revoke an old offline credential.

The result exposes policy id/version, action, source idempotency key, the validated complete payload, and permit-snapshot-request-payload-bytes. The payload tree and bytes are immutable copies. Those bytes are Permit’s single serialization and are the only bytes a later signer may sign. Unknown/deleted Offers, invalid policy/catalog/request data, unsupported actions, and missing or conflicting lineage raise typed exn:fail:commerce values. The optional #:use-expires-at overrides the successor’s use_expires_at: a withdrawal for a subscription order expires at the paid-through moment (cancellation at period end), and the 'renew action — a successor over the previous revision of the same lineage — requires it. No outbox mutation, lineage persistence, signing, or delivery happens in this operation.

procedure

(permit-snapshot-request? value) → boolean?

  value : any/c
Recognizes one validated snapshot request.

Returns the immutable validated payload bytes — Permit’s single serialization and the only bytes a later signer may sign.

procedure

(permit-policy-for-offer catalog offer-id)

 → permit-entitlement-policy?
  catalog : permit-policy-catalog?
  offer-id : string?
Resolves the pinned policy for one Offer with the same typed failures as snapshot preparation, so a worker can fail before signing.