# Security, release, and observability

## Credentials

- Give a coding agent a `read` + `run` + `draft` token when it must author and
  test drafts. Keep `admin` with the human release operator.
- Supply `WRAPFLOW_URL` and `WRAPFLOW_TOKEN` through environment or the user's
  existing `wf login` configuration.
- Never print, commit, paste into chat, or place an account token in frontend
  code. Do not read unrelated secrets while looking for Wrapflow credentials.
- A visitor JWT is not an account token. Pass it only through the generated
  client's `getToken` callback when the contract declares App-user auth.
- Treat public capability URLs as credentials for the capability they grant.

## Release boundary

Before release:

1. Re-inspect the App, contract, hosting status, and currently live deployment.
2. Regenerate and type-check the client if the compatibility hash changed.
3. For a separately hosted frontend, re-check current registry advisories and
   the exact direct pins, committed lockfile, provenance, reputation, licenses,
   and any explicitly approved lifecycle scripts. Verify that every direct and
   transitive version in the resolved graph satisfies the default seven-day
   registry publish-time cutoff; fail closed or obtain a documented human
   exception when age cannot be established. Do not use mutable tags or
   `latest`.
4. For a Wrapflow-hosted uploaded UI bundle, inspect the exact files and
   same-origin `/_wrapflow/client.mjs` integration. For every frontend path,
   run the applicable contract, unit, build, and browser tests in its actual
   stack; run the package-manager audit when it has a package graph.
5. Check authorization with at least two identities when data is tenant-scoped.
6. Run `node ./node_modules/@wrapflow/cli/wf.mjs app operations fixtures <app-id>` and have the admin operator resolve every
   required fixture target with an explicit clear-or-promote decision.
7. Run `node ./node_modules/@wrapflow/cli/wf.mjs app publish <app-id> > release-preflight.json` before proof. Stop
   at the draft if authority is unavailable, `proofStartAvailable` is not
   `true`, or either an authorized publishing path or a present operator is
   unavailable. Present that operator with the complete `exposure` block, including every
   anonymous and authenticated resource, authentication boundary, Checkout,
   and file capability.
8. Only after that review, start empirical Browser proof for the exact draft
   with `node ./node_modules/@wrapflow/cli/wf.mjs app publish <app-id> --checks --request-id <idempotency-key>` and
   `--reviewed-exposure --reviewed-authority-digest <reviewDigest>`, using
   `reviewDigest` from the exact `release-preflight.json` snapshot the operator
   reviewed. The CLI re-reads authority before every start or retry and refuses
   a missing or changed digest. Never silently substitute a newly fetched
   digest: present the changed snapshot for fresh review. Advanced MCP callers
   first present `get_app_release_authority`, then call `start_app_proof` with
   `{appId, requestKey: "<idempotency-key>", operation: "start", operatorReviewedExposure: true, reviewedAuthorityDigest: "<reviewDigest>"}`
   from that reviewed snapshot. For retries use `operation: "retry"` and
   `retryOfProofId: "<proof-id>"`; the same preflight applies.
   Retain the returned proof and attempt IDs,
   then wait for that exact protected attempt and cleanup to pass.
9. Poll `node ./node_modules/@wrapflow/cli/wf.mjs app publish <app-id> > release-review.json` until that exact proof
   ID is eligible, then review its interactions, proof-runner capability
   boundaries, contract, live pointer, fixture receipts, data-migration plan,
   and current complete exposure. Stop at the draft if authority, proof,
   operator review, or publishing becomes unavailable.
10. Construct the complete `AppReleaseRequestV2` as
   `release-authority.json`: `requestKey`, `slug`, `expectedFrontendRevision`,
   `expectedLiveDeploymentId`, `expectedContract`, `expectedDraftIdentity`,
   `empiricalProofId`, `fixtureDecisionReceipts`, `dataMigrationPlanHash`, and
   `reviewedAuthorityDigest`. Copy `expectedDraftIdentity` from `draftIdentity`
   and `reviewedAuthorityDigest` from `reviewDigest` in that exact reviewed
   `release-review.json` snapshot; do not mix fields from different snapshots.
11. Summarize the frontend and backend change, then obtain explicit human
   approval for that exact request. Generic approval of a hostname is not
   release authority.
12. The admin operator may then run `node ./node_modules/@wrapflow/cli/wf.mjs app publish <app-id> --authority
    release-authority.json` (or advanced MCP `publish` with `appId`, all ten
    request fields, and `operatorReviewedExposure: true`).

`node ./node_modules/@wrapflow/cli/wf.mjs app publish` is intentionally admin-only and compare-and-swaps every
authority anchor in the request. If the review digest, draft identity, revision,
live deployment, contract, proof eligibility, fixture receipts, or migration plan
changed, re-inspect and obtain fresh proof or approval as required instead of
forcing the release.

## Observability

Use App hosting status and the Wrapflow Studio together:

- contract and compatibility hash show what callers compile against;
- frontend revision shows which document was released;
- deployment and backend version manifests show what is live;
- run history, request IDs, stable error codes, and workflow results explain
  runtime behavior;
- App edits remain versioned product changes rather than invisible endpoint
  mutations.

For a Wrapflow-hosted uploaded UI bundle, use `look`, browser journeys,
frontend revision, and App deployment status to observe the exact uploaded
HTML/CSS/JavaScript and its same-origin `/_wrapflow/client.mjs` calls.

For a separately hosted framework app, keep frontend logs, performance, and
deployment telemetry in that host. Correlate failures using Wrapflow request
IDs and App/deployment versions. Do not describe that frontend as
Wrapflow-hosted: its host owns presentation availability and dependency
security. Wrapflow's release owns the backend and App Contract only; it does not
build, deploy, fetch, or observe the separate UI. Its Browser evidence must say
`externalFrontendExercised: false` even when every backend Contract step
passes through the internal proof harness.

## Do not overclaim

- A successful contract fetch is not a full UI test.
- A successful uploaded plain-JavaScript preview does not prove a separately
  hosted React or Angular project.
- A successful scriptless hosted preview does not prove an uploaded UI bundle.
- A generated TypeScript file proves schema generation, not framework behavior.
- Report exactly which app, browser path, auth mode, and host were exercised.
- Treat `entity-lifecycle` as exact, isolated coverage for the named scalar
  entity. It does not prove replace, another entity, or production visitor
  cookie/token issuance; keep and report `partial-entity-mutation-coverage` and
  `no-anonymous-ownership-lifecycle` whenever those boundaries remain.
- Never retain lifecycle record IDs, generated values, ownership capabilities,
  cookies, headers, or request/response bodies as release evidence.
