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
31 changes: 28 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,16 @@ jobs:
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@v5
uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
with:
persist-credentials: false
- name: Setup pnpm
uses: pnpm/action-setup@v4
uses: pnpm/action-setup@b906affcce14559ad1aafd4ab0e942779e9f58b1 # v4
with:
version: 10.28.0
run_install: false
- name: Setup Node.js
uses: actions/setup-node@v4
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version: 22.19.0
cache: pnpm
Expand All @@ -44,3 +44,28 @@ jobs:
run: pnpm test
- name: Build
run: pnpm build
- name: Smoke test Worker
run: pnpm test:smoke
- name: Check deployment package
run: pnpm exec wrangler deploy --dry-run --containers-rollout=none

sandbox:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout
uses: actions/checkout@fbc6f3992d24b796d5a048ff273f7fcc4a7b6c09 # v5
with:
persist-credentials: false
- name: Build Oxc sandbox
run: docker build --tag oxc-factory:ci .
- name: Verify Oxc tooling
run: >-
docker run --rm --entrypoint sh oxc-factory:ci -ec
'test "$INSTA_REQUIRE_FULL_MATCH" = 1;
test "$(pnpm --version)" = 12.7.0;
command -v cargo;
just --version;
cargo-insta --version;
cargo-shear --version;
ast-grep --version'
15 changes: 13 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@ FROM docker.io/cloudflare/sandbox:0.12.5

RUN apt-get update \
&& apt-get install -y --no-install-recommends \
git ripgrep curl ca-certificates build-essential pkg-config \
git ripgrep curl ca-certificates build-essential pkg-config python3 clang cmake \
&& rm -rf /var/lib/apt/lists/*

# Package manager for reproducing/building target repositories.
RUN npm install -g pnpm@10
RUN npm install -g corepack@0.34.6 @ast-grep/cli@0.44.0 \
&& corepack enable \
&& corepack prepare pnpm@12.7.0 --activate

ENV INSTA_REQUIRE_FULL_MATCH=1

# Rust support, for repositories like @astrojs/compiler-rs.
#
Expand All @@ -29,6 +33,13 @@ RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs \
| sh -s -- -y --no-modify-path --profile minimal --default-toolchain none \
&& chmod -R a+w "$RUSTUP_HOME" "$CARGO_HOME"

# Oxc's Rust verification tools are shared by every triage container. Remove
# the build toolchain after installation; the target checkout selects its own.
RUN rustup toolchain install stable --profile minimal \
&& cargo +stable install --locked just cargo-insta cargo-shear@1.13.1 \
&& rustup toolchain uninstall stable \
&& chmod -R a+w "$RUSTUP_HOME" "$CARGO_HOME"

# Adversary agent commands run as this user while the sandbox control plane
# remains root for the other workflows that share this image.
RUN useradd --create-home --shell /bin/bash sandbox-agent
Expand Down
18 changes: 12 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,12 @@
# Factory
# Oxc Factory

Oxc's fork of [withastro/factory](https://github.com/withastro/factory).
The Worker is scoped to `oxc-project/oxc`; it uses Oxc's repository skills,
leaves fixes to issue assignees, and writes minimal Conventional Commit PRs.
See [Oxc deployment](docs/oxc-deployment.md) for setup and cutover.

The upstream architecture and capability documentation follows.


A software factory: one Cloudflare Worker that receives GitHub webhooks and
routes them through a deterministic dispatcher to durable
Expand All @@ -13,7 +21,7 @@ Built by combining [withastro/astro-review](https://github.com/withastro/astro-r

## Scope

Factory is the triage and review automation **for the Astro repository's own
Upstream Factory is the triage and review automation **for the Astro repository's own
use** (`withastro/astro`): its routing rules, labels, skills, and the
release-security capability are tuned for how the Astro team works. It is
**not a general-purpose tool** for anyone to install — the package is private
Expand Down Expand Up @@ -435,10 +443,8 @@ may add domain-specific criteria but cannot weaken the built-in correctness and
factory's review and triage defaults live in `skills/review/` and `skills/triage/`;
a repository can replace either one by committing a skill under
`.agents/skills/` and pointing the capability's `skill` setting at it.
Triage pull requests use Factory's built-in `Changes`, `Testing`, and `Docs`
format. A repository can add its own PR writing guidance with
`triage.prWriterSkill`; that skill is applied in addition to the built-in
format.
This fork writes scoped Conventional Commit titles and brief PR bodies without
section headings. Repository guidance comes from `triage.prWriterSkill`.

(The bundled entry file is stored as `skill.md` — Flue's vite plugin treats
imports literally named `SKILL.md` as packaged skills, and we need the raw
Expand Down
74 changes: 74 additions & 0 deletions docs/oxc-deployment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# Oxc deployment

This fork deploys `oxc-factory` on Cloudflare Workers with Cloudflare Sandbox
0.12.5, Durable Objects, Workflows, and two private R2 buckets. Inference uses a
named AI Gateway. No Astro Discord destination is configured. The Astro release
security capability remains inactive because its repository scope is unchanged.
Oxc disables the upstream Astro persona accounts in `.github/factory.yml`.

## Account and credentials

Use the Cloudflare account approved for Oxc infrastructure. The old triage
Action's Workers AI token is not necessarily a deployment token. Deployment
needs Workers, Durable Objects, Workflows, Containers, and R2 permissions.
The existing Oxc CI token was denied Containers (403) and Workflows (401) in
[the credential preflight](https://github.com/oxc-project/oxc/actions/runs/43802011137).
Provide a deployment token separately from inference credentials.
Create `oxc-factory-private-reports` and `oxc-factory-adversary-artifacts` in that
account before deploying. Configure the named Gateway to accept authenticated
requests from the inference token.

Store these encrypted Worker secrets (never in the sandbox):
- `GITHUB_APP_ID`: `oxc-captain` App client ID (`CAPTAIN_ID` in Oxc CI).
- `GITHUB_APP_PRIVATE_KEY`: its PKCS#8 key (`CAPTAIN_KEY` in Oxc CI); convert a
PKCS#1 key using `openssl pkcs8 -topk8 -nocrypt` before uploading.
- `GITHUB_WEBHOOK_SECRET`: a new random secret shared with the App webhook.
- `FACTORY_AI_GATEWAY_ACCOUNT_ID`: Gateway account ID.
- `FACTORY_AI_GATEWAY_ID`: Gateway slug.
- `FACTORY_AI_GATEWAY_TOKEN`: token authorized to call that Gateway.

Opus 5.5 uses `cloudflare-ai-gateway/claude-opus-5-5`. It requires working
Gateway provider billing or a configured Anthropic provider key. Oxc's direct
Unified Billing CI probes on 2026-11-16 returned HTTP 402; resolve that before
turning on the Opus configuration. Model metadata alone does not enable billing.

## Build and deploy

```sh
pnpm install --frozen-lockfile
pnpm cf-typegen
pnpm check:types
pnpm test
pnpm build
pnpm test:smoke
pnpm exec wrangler deploy --dry-run
pnpm exec wrangler deploy
```

A Docker daemon is required to build the sandbox image. The image includes
Corepack/pnpm, Rustup, just, cargo-insta, cargo-shear, and ast-grep. The checkout's
`rust-toolchain.toml` selects Rust, so install its components during bootstrap.
`INSTA_REQUIRE_FULL_MATCH=1` applies to all sandbox commands.

## Cutover

1. Merge Oxc's Factory configuration and compatible triage skills. Keep its
legacy Issue Triage workflow enabled during deployment.
2. Install `oxc-captain` on Oxc with Contents, Issues, and Pull requests write.
Issue triage alone does not need Checks write. Review and preview capabilities
additionally require Checks access and their documented subscriptions.
3. Deploy with the six secrets above; verify `/health` returns `{"status":"ok"}`
and unsigned webhook requests are rejected.
4. Set the GitHub App webhook URL to the deployed Worker's
`/channels/github/webhook`, with the same signing secret. Subscribe to
**Issues** and **Issue comment**. These App subscriptions require an App
owner; the existing App has no subscribed events as of 2026-11-16.
5. Disable legacy triage by setting Oxc's Actions repository variable
`FACTORY_ENABLED=true`, then activate the App webhook. Check GitHub's ping
delivery and run a controlled issue triage before considering cutover done.
Keep only one consumer active while testing an issue.

Rollback: deactivate the Factory webhook, then remove or set
`FACTORY_ENABLED=false` to resume the legacy Action. Existing state labels are
shared. Factory uses `factory/fix-N` branches; legacy branches use their own
prefix and are not automatically adopted or deleted by Factory.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"deploy": "vite build && wrangler deploy",
"cf-typegen": "wrangler types",
"check:types": "tsc --noEmit",
"test": "vitest run --config vitest.config.ts"
"test": "vitest run --config vitest.config.ts",
"test:smoke": "node scripts/smoke.mjs"
},
"dependencies": {
"@biomejs/biome": "2.6.2",
Expand All @@ -29,13 +30,13 @@
"valibot": "^1.4.2"
},
"devDependencies": {
"@cloudflare/vite-plugin": "^1.51.1",
"@cloudflare/vite-plugin": "^1.69.1",
"@flue/cli": "^2.3.0",
"@flue/vite": "^2.3.0",
"@types/node": "^22.10.10",
"typescript": "^7.0.2",
"vite": "^8.2.1",
"vitest": "^4.1.10",
"wrangler": "^4.120.0"
"wrangler": "^4.162.0"
}
}
Loading
Loading