Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ jobs:
- name: Install dependencies
run: pnpm install --frozen-lockfile

- name: Audit runtime and development dependencies
run: pnpm security:audit

- name: Validate generated Worker types
run: pnpm --filter @commercekit/sandbox-ccv2 types:check

Expand Down
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ The CCv2 Worker uses:
- Vitest with Cloudflare's Workers runtime integration
- ESLint and Prettier for code quality

API documentation, the service catalog, and the interactive playground will live on
`commercekit.tools`. This repository does not contain a frontend. The production API hostname is
`ccv2.sandbox.commercekit.tools`.
The [service catalog](https://commercekit.tools/sandbox),
[CCv2 documentation](https://commercekit.tools/docs/sandbox/ccv2),
[API reference](https://commercekit.tools/sandbox/ccv2/api), and
[interactive playground](https://commercekit.tools/sandbox/ccv2/playground) are hosted on
`commercekit.tools`. This repository owns the API Worker at `ccv2.sandbox.commercekit.tools`.

## Requirements

Expand Down Expand Up @@ -77,6 +79,7 @@ CCV2_CONFIRM_PRODUCTION=1 pnpm smoke:production

```bash
pnpm types:ccv2
pnpm security:audit
pnpm lint
pnpm format:check
pnpm typecheck
Expand All @@ -88,6 +91,10 @@ pnpm run ci
`pnpm build:check` builds the Worker through a Wrangler deployment dry-run. It does not deploy or
require Cloudflare credentials.

`pnpm security:audit` includes development dependencies and fails on moderate or higher
advisories. It runs in both `pnpm run ci` and GitHub CI. Development tooling is part of this
check even when it is absent from the deployed Worker.

GitHub Actions runs validation only. Production deployment uses Cloudflare Workers Builds, with
`apps/ccv2` as the root directory. Required runtime secrets and the pre-merge checklist are in
[`apps/ccv2/docs/cloudflare-deployment.md`](apps/ccv2/docs/cloudflare-deployment.md).
Expand Down
2 changes: 1 addition & 1 deletion apps/ccv2/docs/api-coverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ state-aware handler and test coverage rather than a catch-all response.
| Certificates | 4 | 4 | 4 | Metadata is synthetic; private keys are never returned |
| Role assignments | 5 | 5 | 5 | Users and roles are synthetic |
| **Management API total** | **52** | **52** | **52 route/contract parity; representative behavior per family** | See limitations below |
| CommerceKit control and OAuth | 10 | 10 | 10 | Independently versioned sandbox surface |
| CommerceKit control and OAuth | 11 | 11 | 11 | Includes isolated cleanup-fixture seeding |
| SCIM extension | — | 0 | 0 | No verified contract selected |

## Scope decisions
Expand Down
62 changes: 47 additions & 15 deletions apps/ccv2/docs/production-readiness.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# CCv2 production readiness

Assessment date: **2026-10-15**. The reviewed SAP reference is Management API
**2.0.12**. Results apply to this feature branch; the deployed production Worker
continues to run the last merged `main` build until this PR is reviewed and
merged through Cloudflare Workers Builds.
Assessment refreshed **2026-11-18**, against merged API source
`4af998a4783ffa54dd5d7835bfc0dcc4dd382e14`. The reviewed SAP reference remains
Management API **2.0.12**. The contract and Worker-runtime assessments below describe
repository checks; production observations and their limits are recorded separately.

| Area | Assessment | Evidence and gaps |
| -------------------------- | ------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Management API contract | Verified with gaps | 52 methods, paths, IDs, statuses, media types, and named schemas pass the static gate; representative responses pass runtime schema checks. Low-severity simulation limits are in `contract-audit.md`. |
| Sandbox Control API | Verified | Ten operations, typed OpenAPI, separate control error shape, run lifecycle tests. |
| Sandbox Control API | Verified | Eleven operations, including isolated cleanup-fixture seeding, typed OpenAPI, separate control errors and run lifecycle tests. |
| OAuth/JWT | Verified | RS256 signature, algorithm, `kid`, issuer, audience, expiry, subject/run binding, current-run validation, and public-only JWKS tested. |
| Run isolation | Verified | Independent credentials, control-token scope, access-token scope, correlation mismatch, state redaction, and multi-run resources tested. |
| Durable Object persistence | Verified | SQLite migrations, eviction recovery, serialized creation/polling, monotonic identifiers, reset, deletion, alarms, and parallel quota enforcement tested. |
Expand All @@ -17,10 +17,43 @@ merged through Cloudflare Workers Builds.
| Extended Cloud Portal APIs | Verified with gaps | Every family has behavior tests and typed representative response validation. Physical infrastructure effects are simulated; scheduled ordering supports two fields. |
| Security | Verified | Request limits, malformed inputs, token negatives, cross-token misuse, secret redaction, error sanitization, and constant-time verifier comparisons tested/reviewed. |
| Public rate limiting | Verified with limitation | Anonymous run creation uses the binding and local boundary tests. Cloudflare documents per-location, eventually consistent behavior; it is abuse friction rather than exact global accounting. No production load test was run. |
| Production smoke testing | Passed | The bounded opt-in suite passed against production: health, OpenAPI, OAuth/JWKS, success, ZIP, failure/timeout, isolation, deleted-run, green-decision, and cleanup checks. This verifies deployed `main`, not unmerged code. |
| OpenAPI/Scalar readiness | Verified | Both OpenAPI 3.1 documents validate, use the public server, publish distinct security/error models, and contain no retired mock aliases. |
| Production checks | Evidence below | Public read-only observations, historical broad smoke and hosted Action workflows have different coverage. No new mutating production smoke is claimed by this refresh. |
| OpenAPI readiness | Verified | Both OpenAPI 3.1 documents validate, use the public server, publish distinct security/error models, and contain no retired mock aliases. |
| SCIM | Separate architectural decision | Deferred; see `scim-decision.md`. |
| Website integration | Ready | Required endpoints, CORS, credentials, scenario flow, errors, expiry, cleanup, and Scalar guidance are documented. |
| Website integration | Implemented | The published website owns the read-only Swagger UI reference and interactive Playground. See `website-integration.md` for endpoints, credentials, errors, CORS and cleanup. |

## Validation evidence and limits

- [Main CI run 43620784834](https://github.com/commercekit-tools/sandbox/actions/runs/43620784834)
passed 63 Worker-runtime tests across 14 files, generated binding types, OpenAPI validation,
lint/type checks and the Worker bundle dry-run for the assessed source.
- Read-only production checks on November 18 UTC returned healthy Worker/SQLite status,
the expected production website CORS header and a public-only RSA JWKS. Both published
OpenAPI objects matched the assessed main YAML. Matching public contracts does not identify
the deployed code commit or prove fresh token issuance or every lifecycle path.
- The October 15 assessment recorded a passing opt-in production smoke covering OAuth,
lifecycle success/failure/timeouts, isolation, ZIP logs, green decisions and run removal.
That historical result is not a new execution of this branch.
- The owner-authorized November 15 hosted
[build/approval/synthetic-deploy run](https://github.com/commercekit-tools/action-integration-tests/actions/runs/43681867766)
and [cleanup dry-run/repeat run](https://github.com/commercekit-tools/action-integration-tests/actions/runs/43681889413)
passed. The approved deploy recreated a synthetic build in a fresh run; provider delivery
was disabled. The [integration evidence](https://github.com/commercekit-tools/action-integration-tests/blob/1174dd82b4a8c4f049e234d1862387b56571c0b0/docs/VALIDATION.md)
preserves the tested revisions, assertions and verified run removals.

The original hosted smoke/full/provider matrix, live Slack/Teams delivery and dedicated
hosted cancellation/timeout scenarios remain unrun in that evidence. They require a separate
deliberate authorization. Sandbox success does not establish real SAP cleanup eligibility,
operational deletion guarantees or Action release approval.

## Development dependency security

The development-only minimatch 10.2.6 paths in ESLint and TypeScript-ESLint were affected by
[GHSA-g3hv-75wg-m249](https://github.com/advisories/GHSA-g3hv-75wg-m249).
ESLint 10.15.0 and TypeScript-ESLint 8.73.0 adopt patched upstream requirements; the lockfile
resolves minimatch 11.0.9 without an override. Worker runtime dependencies are unchanged.
`pnpm security:audit` checks the complete dependency graph, including development tooling,
in the existing local and GitHub CI gates.

## Security hardening completed

Expand All @@ -40,16 +73,15 @@ merged through Cloudflare Workers Builds.

## Remaining risks and manual checks

1. Review the PR's GitHub CI result. The workflow now points at the correct pnpm
package and runs the OpenAPI gate explicitly.
1. Review the exact change's GitHub CI result, including dependency security and OpenAPI checks.
2. Confirm the existing `CCV2_RUN` namespace, custom domain, four required
secrets, and rate-limit namespace remain configured before merging.
3. After merge and the normal Cloudflare Workers Builds deployment, repeat the
production smoke suite to verify this branch's deployed artifact.
4. Merge only through the normal review path. Do not deploy this feature branch.
3. After a runtime deployment, use the documented read-only checks first. Run the mutating
production smoke only with explicit authorization and retain its sanitized result.
4. Keep normal review and main-based Cloudflare Workers Builds as the deployment path.

No secret or Cloudflare resource change is required by this branch. Schema
version 3 is additive. Rolling back code leaves the additional
The dependency/documentation update does not require new secrets, bindings or storage
migrations. The existing schema version 3 is additive. Rolling back code leaves the additional
`resource_sequences` table unused; existing run metadata and resources remain
readable by the previous schema version. Runs created after rollback could reuse
an extended-resource identifier only after a deletion, which is why rollback
Expand Down
46 changes: 29 additions & 17 deletions apps/ccv2/docs/website-integration.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
# CommerceKit website integration contract

The website should call the independently deployed API at
`https://ccv2.sandbox.commercekit.tools`. The Worker does not serve website UI
or Scalar assets.
The [CommerceKit Sandbox website](https://commercekit.tools/sandbox/ccv2) calls the
independently deployed API at `https://ccv2.sandbox.commercekit.tools`.
The website owns the API reference, documentation and interactive Playground; the Worker owns
the API and isolated simulation state.

## Required endpoints

Expand All @@ -16,6 +17,7 @@ or Scalar assets.
| Scenario | `GET`, `PUT /sandbox/v1/runs/{runId}/scenario` | Control bearer |
| Sanitized state | `GET /sandbox/v1/runs/{runId}/state` | Control bearer |
| Reset | `POST /sandbox/v1/runs/{runId}/reset` | Control bearer |
| Advanced test fixture | `PUT /sandbox/v1/runs/{runId}/cleanup-fixture` | Control bearer; isolated test setup |
| Delete | `DELETE /sandbox/v1/runs/{runId}` | Control bearer |
| OAuth token | `POST /oauth2/token` | Synthetic client credentials in the form body |
| Public signing keys | `GET /.well-known/jwks.json` | None |
Expand Down Expand Up @@ -63,9 +65,8 @@ authenticated token and is never a credential.

Control tokens, client secrets, and access tokens must not appear in URLs,
analytics events, error telemetry, console logs, or persistent public storage.
Keep them in memory where possible. If session recovery is required, use a
server-side session with encrypted, HTTP-only cookies rather than browser local
storage. Redact authorization headers before logging request diagnostics.
The current Playground keeps them in an in-memory session provider; a full page refresh
clears the local session. Redact authorization headers before logging request diagnostics.

## Scenario configuration

Expand Down Expand Up @@ -104,11 +105,14 @@ restores the default scenario, and preserves credentials and expiration.
The website should branch on HTTP status and media type before decoding an error.
Treat `401` as token invalidation, `403` as a run/token mismatch, `404` after
expiry or deletion as a terminal run state, `429` as retryable only after the
provided `Retry-After`, and `5xx` as a bounded retry condition.
provided `Retry-After`, and unexpected `5xx` as a visible failure. The current Playground
does not automatically replay general requests: its bounded progress poller handles `429`
with `Retry-After`, while other polling failures stop and can be resumed deliberately.
Do not replay a create mutation whose server-side outcome is unknown.

## CORS and browser requests

The deployed allowlist includes exactly `https://commercekit.tools` and the
The checked-in allowlist includes exactly `https://commercekit.tools` and the
CommerceKit Vite development origin `http://localhost:5173`. Override the
comma-separated `ALLOWED_ORIGINS` value when another exact development origin
is required; origins do not include a trailing slash. Preflight responses allow
Expand All @@ -130,15 +134,23 @@ Runs expire 24 hours after creation. An expired or deleted run cannot issue a
new token, and previously issued tokens stop authorizing Management operations.
The website should show the expiry, stop polling at terminal states, cap all
polling attempts, and delete a run when the user ends the playground session.
Cleanup should be best effort during navigation because browser unload requests
are not guaranteed. Server-side expiration remains the final cleanup mechanism.
The current Playground preserves the active in-memory run during client-side navigation
across the website; End Session explicitly removes it. A full page refresh clears the local
credentials. Browser unload cannot guarantee cleanup, so server-side expiration remains
the fallback when deletion cannot complete.

## Scalar integration
## OpenAPI reference and advanced fixtures

Both documents are OpenAPI 3.1 JSON, use the public API server URL, define their
security schemes, and contain typed request and response schemas. The website can
point Scalar at `/openapi.json` for SAP-compatible operations and offer
`/openapi/sandbox.json` as a separate control document. The website should inject
credentials only into the active Scalar client state and must prevent Scalar,
browser extensions, and analytics tooling from persisting them. No retired
`/__mock` route or alias is present.
security schemes, and contain typed request and response schemas. The published
[API reference](https://commercekit.tools/sandbox/ccv2/api) uses Swagger UI to display
the Management and Sandbox Control documents. Try requests, credential configuration,
credential persistence and the external validator are disabled there. Interactive runs and
synthetic credentials belong to the [Playground](https://commercekit.tools/sandbox/ccv2/playground).

The Control document also exposes `seedCleanupFixture` for advanced isolated integration
tests. It seeds bounded build/deployment records and deterministic cleanup races; it is not
a Playground editor or a SAP endpoint. Hosted approval testing uses it to recreate a build
after the original run is removed. See the
[integration workflow guide](https://github.com/commercekit-tools/action-integration-tests/blob/1174dd82b4a8c4f049e234d1862387b56571c0b0/docs/WORKFLOWS.md)
for that synthetic handoff and the separate dry-run eligibility limits.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,13 @@
"typecheck": "pnpm --filter @commercekit/sandbox-ccv2 typecheck",
"test": "pnpm --filter @commercekit/sandbox-ccv2 test",
"build:check": "pnpm --filter @commercekit/sandbox-ccv2 build:check",
"ci": "pnpm --filter @commercekit/sandbox-ccv2 types:check && pnpm format:check && pnpm lint && pnpm typecheck && pnpm --filter @commercekit/sandbox-ccv2 openapi:check && pnpm test && pnpm build:check"
"security:audit": "pnpm audit --audit-level=moderate",
"ci": "pnpm security:audit && pnpm --filter @commercekit/sandbox-ccv2 types:check && pnpm format:check && pnpm lint && pnpm typecheck && pnpm --filter @commercekit/sandbox-ccv2 openapi:check && pnpm test && pnpm build:check"
},
"devDependencies": {
"@eslint/js": "10.0.1",
"eslint": "10.14.0",
"eslint": "10.15.0",
"prettier": "3.10.0",
"typescript-eslint": "8.72.2"
"typescript-eslint": "8.73.0"
}
}
Loading