This page covers the Scwrap repository itself. Code reaches its main after the checks pass. Every push to main then deploys the docs site at https://scwrap.dev, the maintainer's production instance and every Release of this repository's catalog that changed; Releases other repositories deployed to the instance stay installed. There are no pull requests. A copy of the repository that deploys its own instance keeps the gate and gives the deploy job its credentials as repository secrets (Infrastructure).
The gate
Run it before you call a change ready:
pnpm verifyIt runs turbo run check test build. In an Amp orb (AMP_ORB set) it runs one task at a time, as pnpm check and pnpm test do there, so the gate peaks under 3 GB and fits an a1.small orb (4 GB); in parallel it peaks above 5 GB.
| Check | What it catches |
|---|---|
| TypeScript with the Effect language service | Type errors and Effect mistakes, such as a missing Capability or an undeclared error. |
| Oxlint | Package boundaries, code comments, module-level mutable state, Effects run by hand in tests. |
| Oxfmt | Formatting. |
| knip, jscpd, sherif | Unused files, exports and dependencies; duplication; package.json hygiene. |
| varlock | Environment variables that are not declared in .env.schema. Run pnpm env:check after editing it. |
| Tests | Behaviour, through each package's public interface. |
| Builds | Every package's dist/ and this docs site. A dead link fails the docs build. |
Lefthook runs pnpm check and pnpm test before every commit, and the changeset check before every push. Never pass --no-verify. If a check fails, fix the cause.
What CI does
| Job | Runs |
|---|---|
| Lint, typecheck, and build | pnpm turbo run check build, pnpm scwrap --help, and the @scwrap/deploy and @scwrap/infra tests. It archives the build outputs. |
| Test | Two parallel suites alongside the build job, each building its own prerequisites: Captcha (@scwrap/captcha-templates) and Other packages. |
| Deploy production | Waits for every job above. Deploys the docs site, the ScwrapDocs/production Stack (The docs site), then the ScwrapInstance/production Stack, up to four attempts 20, 40 and 60 seconds apart, then runs pnpm scwrap deploy --changed for the catalog, then checks the deployed catalog, then runs the kitchen-sink Scraper with its default checks and fails when one of them fails, printing every check. It keeps the journal as a workflow artifact. |
The first two jobs hold no credentials. The deploy job reads the production document from OpenBao through GitHub OIDC (Infrastructure).
Fix a red main before anything else.
Publishing the SDKs
The seven SDK packages share one version and are released with Changesets. .changeset/config.json holds them in one fixed group, so a release moves all seven to the same version.
Every SDK change carries a changeset
A commit that changes an SDK's src/, bin/ or README.md comes with a changeset in .changeset/:
pnpm changesetIt asks for the bump and a summary for the changelog. Pick patch only for a change that keeps the domain contract below; anything else is minor. A change that ships nothing to npm, such as a test, needs no changeset; if the check asks for one anyway, add pnpm changeset --empty.
pnpm exec changeset status enforces it twice: the Lefthook pre-push hook compares against origin/main, and the Lint, typecheck, and build CI job compares against the commit before the push, so a push without a changeset turns main red.
Releasing
Changesets pile up on main until a release. The agent working on the SDKs decides when to release: when a consumer such as a Scraper repository needs a change, or when enough has piled up. Batch changes into one release, because npm sends an email for every published package version.
pnpm changeset version
pnpm verify
git commit -am "Release the SDKs 0.5.1"
git tag v0.5.1
git push --atomic origin main v0.5.1changeset version consumes the changesets, raises the seven versions and writes each package's CHANGELOG.md. The tag is v plus that version.
A pushed v* tag starts the Publish SDKs workflow (.github/workflows/publish.yml). It refuses a tag that is not on main or does not name the version of all seven packages, waits for CI to pass on the tagged commit, builds and tests the SDKs, packs them with pnpm sdk:pack, and publishes each version npm does not have yet, with provenance. It holds no npm token: npm trusts that workflow in the npm environment of this repository through GitHub OIDC (trusted publishing). A published version cannot be replaced, so a mistake ships as the next patch. To publish a tag again, start the workflow by hand on that tag.
Compatibility
The SDKs
The other six SDKs depend on @scwrap/domain as workspace:^, which packs as a caret range such as ^0.5.0. Every release moves all seven to one version. A patch, such as 0.5.1, must stay backward-compatible, because a Scraper that pins one SDK at 0.5.0 still accepts domain 0.5.1: no removed or changed export, no changed schema, and no change to the scwrap-sdk.mjs contract. Anything else is a minor version, such as 0.6.0, because ^0.5.0 does not accept 0.6.0.
The HTTP API and result records
Callers depend on the HTTP API and the result record without installing anything, and a push to main changes production at once, so the instance keeps them stable on its own terms:
- Added at any time: a route, an optional query parameter or header, a field of a JSON answer or result record, and an answer to a request that used to fail. A caller ignores fields it does not know;
@scwrap/clientdoes. - Never changed in place: a route's path or method, the meaning of a status code, a field's name, type or meaning, a
statusvalue, and a header's meaning. Adding astatusvalue counts as a change, because a caller that matchesrunning,completedandfailedwould misread it. - Changed only across two minor versions: one SDK minor version, such as
0.5.0, adds the new shape next to the old one and marks the old one deprecated in these docs and in Known gaps; the next,0.6.0, removes the old one. - Stored records stay readable: result records live as long as the instance's retention, 30 days by default, so every change reads records written by the platform within that time, as
tokenNamestays optional for records written before named tokens.
What needs sign-off
| Work | Approval |
|---|---|
| Code and tests in this repository's existing packages, docs, glossary terms | Within the requested scope. |
| A new package, dependency, pin, vendor or credential, or a weaker check | Owner sign-off. |
A push to main | Owner sign-off. It includes the automatic production deploy. |
A Release deployed by hand with pnpm scwrap deploy | Owner sign-off naming the instance and the Releases. |
| Instance infrastructure, a new instance, tokens or OpenBao documents | Owner sign-off naming the instance and its hostname. |
WARNING
Get approval before a live change. A guard flag such as --yes is not approval.
Deploying by hand
CI deploys production. Deploy by hand only for another instance, or when the owner asks.
- Releases: build, run
pnpm scwrap deploy <scraper-id>, thenpnpm scwrap retrywith the journal it printed until every Release isactive(The scwrap CLI). - Infrastructure:
CI=1 pnpm infra:instance:plan --stage <stage> --no-inputshows the diff and changes nothing.infra:instance:deployapplies it (Infrastructure). - Afterwards: check the catalog, start one Run and read its items (Calling your Scraper).
Credentials
This repository's credentials come from personal OpenBao. An infra command in an orb exchanges the Amp project's workload identity for a short-lived token through with-credentials.ts, which also takes credentials from plain environment variables (Variables). Nothing is stored in Amp settings, repository files or shell arguments.
Names
Deployed identifiers are Scwrap's: the ScwrapInstance Stack and the scwrap-instance-<stage> Workers. Renaming a Stack changes its state identity and recreates everything in it. Renaming a physical name usually replaces that resource. Both are deploys and need sign-off.
Source
- lefthook.yml: the pre-commit checks
- ci.yml: the three CI jobs
- AGENTS.md: the rules of the repository