PermDock
CLI

cloud

permdock cloud push publishes the catalog, the code policy and the Supabase manifest to a PermDock Cloud project; permdock cloud pull writes the published catalog and manifest back, byte for byte.

permdock cloud push builds the same catalog as collect, with the policy's hostable flags, each permission's code approvals, and each role's on and assignable, and posts it with the code policy and permdock.manifest.json to a PermDock Cloud project. The Cloud reads it to offer only declared roles and plans, to hand out only assignable roles, to let an admin author hosted grants only on hostable permissions, and to serve the hosted AuthZEN endpoint for the published policy (PermDock Cloud).

permdock cloud pull reads what the last push sent and writes permissions.catalog.json and permdock.manifest.json as collect and supabase inspect --out write them, so authorizationProvider({ manifest, catalog }) and every other reader of those files see the same bytes.

A project is one Cloud environment and has the same id, so --project names both.

Usage

permdock cloud push                         # PERMDOCK_CLOUD_KEY, or a login from permdock login --scope catalog:write
permdock cloud push --project preview       # overrides PERMDOCK_CLOUD_ENV, then the key's environment
permdock cloud push --manifest supabase/permdock.manifest.json
permdock cloud push --dry-run --json        # print the fingerprint and summary; no network
permdock cloud pull --project prj_123       # with a login from permdock login
permdock cloud pull                         # in CI with PERMDOCK_CLOUD_TOKEN: the token's one project
printf '%s' "$KEY" | permdock cloud push --key-stdin   # the key from a secret store, not the environment
FlagMeaning
--urlBase URL of the Cloud API; defaults to PERMDOCK_CLOUD_URL, then https://permdock.com/api
--projectThe project id, the same id as its environment. push defaults to PERMDOCK_CLOUD_ENV, then the environment GET /v1/environment names for the credential (a dry run prints "the key's environment"); pull needs it unless PERMDOCK_CLOUD_TOKEN names one project
--key-stdinpush: read PERMDOCK_CLOUD_KEY from stdin
--token-stdinpull: read PERMDOCK_CLOUD_TOKEN from stdin
--manifestpush: the manifest to send (default permdock.manifest.json, sent when present); pull: where to write it
--dry-runpush: build the catalog and print its fingerprint without posting it
--jsondata in the result. push: { fingerprint, permissions, hostable, roles, plans, grants, manifest, environment, status }; pull: { project, version, fingerprint, permdockVersion, catalog, manifest }

Push

The request is POST /v1/environments/:env/catalog with the body { fingerprint, catalog, policy?, manifest?, permdockVersion }. The bearer is PERMDOCK_CLOUD_KEY when it is set, otherwise the stored login, which must hold catalog:write (login).

  • fingerprint is catalogFingerprint(catalog) from permdock and equals the catalog's own fingerprint field (wire formats). The clock, the CLI version and call sites never change it, so two runs over the same contract produce the same value. The Cloud recomputes it and rejects a mismatch.
  • policy is present when permdock.config.ts names one. It is a PushedPolicy, { v: 1, fingerprint, scopes?, grants } (wire formats): fingerprint is the code policy's, scopes its declared scope keys, and each grant has the snapshot grant shape plus limit, validity and the grant's metadata. A grant whose condition is a closure travels as closure: true without its function, and the hosted endpoint denies it, so a permission that depends on a closure should be decided in the application.
  • manifest is permdock.manifest.json or the --manifest file, checked with parseSupabaseManifest before anything is sent. An explicit --manifest that does not exist is a usage error.
  • permdockVersion is the version of the CLI that pushed. cloud pull warns when it differs from its own.

A hosted policy document names the catalog it was authored against in its catalog field (wire formats).

Before it sends anything, push checks the built catalog against the validation rules, with or without --dry-run. A broken catalog prints every issue with its path and exits 1:

permdock cloud push: the catalog has 2 issues
  roles.0.on: role 'admin' is on 'workspace', which is neither a declared scope nor resource
  grants.0.permission: grant 'post.delete' is not a declared permission key

With --json, the error document's reason is invalid_input and data.issues holds the same path: message lines. cloud push --dry-run --json in CI therefore fails on the same catalog the Cloud would refuse.

Pull

cloud pull calls GET /v1/projects/:id/policy (projects API) and then:

  1. Checks the catalog with parseCatalog and the manifest with parseSupabaseManifest.
  2. Writes the catalog to the path collect uses: collect.out, then catalog.out, then permissions.catalog.json.
  3. Writes the manifest to --manifest or permdock.manifest.json. A push without a manifest leaves the file alone and prints a warning.
  4. Reads the catalog file back and requires catalogFingerprint of it to equal the response fingerprint and the catalog's own fingerprint. On a mismatch it restores both files to their previous bytes and exits 1.

The bearer is PERMDOCK_CLOUD_TOKEN when it is set, otherwise the stored login. With the token and no --project, cloud pull reads GET /v1/projects and uses its one project. A project with nothing pushed answers 404 with the https://permdock.com/problems/policy-not-published problem, and cloud pull exits 1.

Exit codes follow the shared contract: 0 pushed, pulled or --dry-run; 1 the catalog broke a validation rule (invalid_input), the Cloud was unreachable (network_error), answered with a non-2xx status, or sent bytes that failed the fingerprint check; 2 no key, token or login, an unreadable definition module or manifest, or the Cloud rejected the credential with 401 or 403 (auth_required, with permdock login in next). In agent mode, cloud push without --dry-run first asks for the person's confirmation (cloud:write).

In CI

- run: pnpm exec permdock collect --check
- run: pnpm exec permdock cloud push
  env:
    PERMDOCK_CLOUD_KEY: ${{ secrets.PERMDOCK_CLOUD_KEY }}

Push after the deploy that ships the code, so hosted grants authored against the new catalog never reach an instance that runs the old policy.

A job that only reads, such as a repository that consumes another team's published policy, pulls with a read-only token:

- run: pnpm exec permdock cloud pull
  env:
    PERMDOCK_CLOUD_TOKEN: ${{ secrets.PERMDOCK_CLOUD_TOKEN }}
- run: pnpm exec permdock rls generate --project production --check
  env:
    PERMDOCK_CLOUD_TOKEN: ${{ secrets.PERMDOCK_CLOUD_TOKEN }}

Side effects

What each command may change; side effects explains each one.

CommandSide effects
permdock cloud pushnetwork, cloud:write
permdock cloud pullnetwork, files

Why

Publishing is a CLI command, not a build hook. createPermDockPlugin and createPermDockUnplugin stay collect-only because a build that needs a secret and the network fails on forks, in preview builds without credentials and in offline CI, and a catalog published mid-build can describe code that never deploys. A command in the deploy step runs once, with the key the deploy already holds.

Keys and tokens are read only from PERMDOCK_CLOUD_KEY and PERMDOCK_CLOUD_TOKEN, never from a flag, so they do not end up in shell history or CI logs. A push sends the catalog, the code grants and the manifest: no subject and no decision. A leaked push key can change what the Cloud publishes for its environment, but it cannot authenticate anyone or decide anything inside the application. PERMDOCK_CLOUD_TOKEN is read-only and pinned to one environment, so a leaked CI token reads one project's policy and nothing else.

cloud pull writes with the same functions as the offline commands instead of copying the response text, and checks the fingerprint after writing, so a file on disk is either the published catalog or the file that was there before.

Last updated on

On this page