Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
7a4a6c9
ci: scope website lint gates
christian-byrne Oct 4, 2026
a1aa8f6
ci: auto-approve trusted website changes
christian-byrne Oct 4, 2026
10d64a6
ci: satisfy approval policy quality gates
christian-byrne Oct 4, 2026
79e8b14
ci: close approval race conditions
christian-byrne Oct 4, 2026
6d093f9
validation: harden website canary and production oracle
christian-byrne Oct 5, 2026
845307e
ci: simplify website approval validation
christian-byrne Oct 5, 2026
17da17b
ci: harden website canary controls
christian-byrne Oct 5, 2026
78b2df0
ci: require rollback baseline preflight
christian-byrne Oct 5, 2026
a471460
ci: verify exact production deployment
christian-byrne Oct 5, 2026
b5b3bc7
ci: serialize website production controls
christian-byrne Oct 5, 2026
585d62f
ci: secure staged website promotion
christian-byrne Oct 5, 2026
c84bdaf
ci: preserve canonical marker json
christian-byrne Oct 5, 2026
206eb03
ci: withdraw unverifiable website approvals
christian-byrne Oct 5, 2026
11294dc
validation: add synthetic website canary author
christian-byrne Oct 5, 2026
339f049
Merge remote-tracking branch 'origin/main' into validation/website-na…
christian-byrne Oct 5, 2026
abe4702
test(ci): cover website-only output defaults
christian-byrne Oct 5, 2026
c975dd3
ci: add authorized label approval route
christian-byrne Oct 5, 2026
0b43ec4
ci: bind approval label to current revision
christian-byrne Oct 5, 2026
ef0f493
ci: exclude website path from CodeRabbit review
christian-byrne Oct 5, 2026
75fc52f
fix: use approved website workflow identity
christian-byrne Oct 6, 2026
32b249c
fix: pin website approval checkout action
christian-byrne Oct 6, 2026
5d4b8f1
docs: name website approval primary path
christian-byrne Oct 6, 2026
a15963c
ci: queue approved website changes
christian-byrne Oct 6, 2026
1d4e20d
fix: satisfy website queue workflow lint
christian-byrne Oct 6, 2026
f95ed20
[automated] Apply ESLint and Oxfmt fixes
actions-user Oct 6, 2026
f3a40b9
ci: retain website rollback evidence
christian-byrne Oct 6, 2026
fea4612
Merge origin/main into website validation
christian-byrne Oct 6, 2026
cc10dac
Merge remote-tracking branch 'origin/main' into validation/website-na…
christian-byrne Oct 7, 2026
ddf7011
refactor(ci): make package fast lanes declarative
christian-byrne Oct 7, 2026
ef22dfe
fix(ci): stage production-targeted deployments
christian-byrne Oct 7, 2026
964f919
fix(ci): serialize fast-lane lifecycle runs
christian-byrne Oct 7, 2026
0d3763c
fix(ci): bind label approval to the live head event
christian-byrne Oct 7, 2026
59cd024
fix(ci): arm only the approved fast-lane head
christian-byrne Oct 7, 2026
e955907
fix(ci): preserve compensation failure context
christian-byrne Oct 7, 2026
5d85351
fix(ci): dequeue fast lanes by pull request id
christian-byrne Oct 7, 2026
6fda68c
fix(ci): retain the first fast-lane ownership floor
christian-byrne Oct 7, 2026
cc83981
fix(ci): dismiss stale fast-lane policy approvals
christian-byrne Oct 7, 2026
15144ca
docs(ci): define revision-bound label events
christian-byrne Oct 7, 2026
d2056fe
fix(ci): make fast-lane compensation fail safe
christian-byrne Oct 7, 2026
7a01651
fix(ci): drop blocked review-event fast-lane runs
christian-byrne Oct 7, 2026
e0b0960
fix(ci): limit approval job to target events
christian-byrne Oct 7, 2026
1acd80e
docs(ci): name live fast-lane reconcile events
christian-byrne Oct 7, 2026
877bd26
fix(ci): retain website locale integrity checks
christian-byrne Oct 7, 2026
5b6eed1
test(ci): exercise website-only path classification
christian-byrne Oct 7, 2026
9e70fdc
fix(ci): build website previews from the exact PR head
christian-byrne Oct 7, 2026
9189923
fix(ci): distinguish policy approvals from human reviews
christian-byrne Oct 7, 2026
6f27166
docs(ci): name trusted fast-lane triggers
christian-byrne Oct 7, 2026
f8d2ff0
fix(ci): isolate fast-lane lifecycle by pull request
christian-byrne Oct 7, 2026
dd646a2
fix(ci): authorize label reruns by triggering actor
christian-byrne Oct 7, 2026
294038b
fix(ci): revoke lane approval when its label is removed
christian-byrne Oct 7, 2026
61ca138
fix(ci): retain locale source history for website checks
christian-byrne Oct 7, 2026
32fb3e6
test(ci): isolate fast-lane label authorization fields
christian-byrne Oct 7, 2026
86fe45c
test(ci): cover fail-safe hold compensation
christian-byrne Oct 7, 2026
520de83
test(ci): distinguish website-plus-docs routing
christian-byrne Oct 7, 2026
1938eac
fix(ci): serialize every production website deployment
christian-byrne Oct 7, 2026
397cc56
docs(ci): explain fast-lane label revocation
christian-byrne Oct 7, 2026
bd0fda6
docs(ci): scope fast-lane serialization per pull request
christian-byrne Oct 7, 2026
8b2be52
fix(ci): report compensation summaries only on success
christian-byrne Oct 7, 2026
abde041
Merge remote-tracking branch 'origin/main' into validation/website-na…
christian-byrne Oct 8, 2026
1a53093
refactor(ci): resolve every fast-lane event to one per-PR job
DrJKL Oct 8, 2026
ceadf96
ci: run website fixers inside the lint job
DrJKL Oct 8, 2026
fcb15c3
ci: tidy rollback inputs and the website-only output description
DrJKL Oct 8, 2026
6644fd5
docs: record the fast-lane ADR and operator procedures
DrJKL Oct 8, 2026
eab7e2d
refactor(ci): share website deployment identity checks
DrJKL Oct 8, 2026
cbf77d9
refactor(ci): remove duplicated fast-lane logic
DrJKL Oct 8, 2026
23d3d29
refactor(ci): keep only verified fields in the website build identity
DrJKL Oct 8, 2026
d1ede07
refactor(ci): move the fast-lane engine into tools/cicd/fast-lane
DrJKL Oct 8, 2026
c1b1a64
refactor(ci): replace custom website CI plumbing with native tools
DrJKL Oct 8, 2026
91e8072
refactor(ci): keep fast-lane policies in a typed module
DrJKL Oct 8, 2026
b387448
docs: describe the simplified fast lane and website rollback
DrJKL Oct 8, 2026
9ad947a
fix: resolve pnpm lockfile conflict
github-actions[bot] Oct 8, 2026
10e178b
fix: repair pnpm lockfile
github-actions[bot] Oct 8, 2026
bb496e3
Merge main and repair fast-lane checks
christian-byrne Oct 11, 2026
50953ba
fix: keep staged server-fact checks merge-aware
christian-byrne Oct 11, 2026
d4fbd61
fix: repair pnpm lockfile
github-actions[bot] Oct 11, 2026
a39b084
test: make merge regression fixture exercise server facts
christian-byrne Oct 11, 2026
69fd67f
chore: merge current main into website native canary
christian-byrne Oct 12, 2026
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
2 changes: 2 additions & 0 deletions .coderabbit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ reviews:
profile: assertive
high_level_summary: false
request_changes_workflow: true
path_filters:
- '!apps/website/**'
# Without this, a review that never happened (rate limit, internal error)
# still reports green, so an unreviewed PR is indistinguishable from a
# cleanly reviewed one.
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ci-vercel-website-preview.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ jobs:
deploy-production:
if: github.event_name == 'push'
runs-on: ubuntu-latest
environment:
name: website-production
url: ${{ steps.deploy.outputs.url }}
steps:
- name: Checkout repository
uses: actions/checkout@v7
Expand Down Expand Up @@ -210,9 +213,6 @@ jobs:
URL=$(vercel deploy --prebuilt --prod --archive=tgz)
echo "url=$URL" >> "$GITHUB_OUTPUT"

- name: Add deployment URL to summary
run: echo "**Production:** ${{ steps.deploy.outputs.url }}" >> "$GITHUB_STEP_SUMMARY"

- name: Notify IndexNow of changed pages
continue-on-error: true
timeout-minutes: 5
Expand Down
62 changes: 62 additions & 0 deletions .github/workflows/pr-website-auto-approve.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Run the website package's configured delivery lane.
#
# Security boundary: pull_request_target and workflow_run load this workflow,
# the policy, and the engine from the default branch; pull request code is
# never executed. Eligibility rules: docs/architecture/package-delivery-lanes.md.
name: 'PR: Website Fast Lane'

on:
pull_request_target:
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
types:
- opened
- reopened
- synchronize
- ready_for_review
- converted_to_draft
- edited
- labeled
- unlabeled
workflow_run:
workflows:
- 'CI: Tests E2E'
- 'CI: Website E2E'
types: [completed]

permissions:
contents: read

jobs:
fast-lane:
if: github.event.pull_request || github.event.workflow_run.pull_requests[0]
concurrency:
group: website-fast-lane-${{ github.event.pull_request.number || github.event.workflow_run.pull_requests[0].number }}
cancel-in-progress: false
environment: website-approval
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout trusted base automation
uses: actions/checkout@v7
with:
ref: refs/heads/${{ github.event.repository.default_branch }}
persist-credentials: false
sparse-checkout: |
.nvmrc
tools/cicd/fast-lane

- uses: actions/setup-node@v6
with:
node-version-file: .nvmrc

- name: Approve, queue, or withdraw the website pull request
env:
FAST_LANE: website
FAST_LANE_TOKEN: ${{ secrets.WEBSITE_APPROVAL_TOKEN }}
FAST_LANE_DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
FAST_LANE_EVENT_ACTION: ${{ github.event.action }}
FAST_LANE_EVENT_ACTOR: ${{ github.triggering_actor }}
FAST_LANE_EVENT_LABEL: ${{ github.event.label.name }}
Comment on lines +56 to +58

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P3 This job only runs for status and workflow_run, and the only reader of these values (hasAuthorizedApprovalLabel) requires pull_request_target, so they cannot change behavior here.

Suggested change
FAST_LANE_EVENT_ACTION: ${{ github.event.action }}
FAST_LANE_EVENT_ACTOR: ${{ github.actor }}
FAST_LANE_EVENT_LABEL: ${{ github.event.label.name }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in 1a53093: with one job, the event lines exist once and only the pull_request_target labeled event is parsed.

GITHUB_REPOSITORY: ${{ github.repository }}
PR_HEAD_SHA: ${{ github.event.pull_request.head.sha || github.event.workflow_run.head_sha }}
PR_NUMBER: ${{ github.event.pull_request.number || github.event.workflow_run.pull_requests[0].number }}
run: node tools/cicd/fast-lane/src/run.ts
81 changes: 81 additions & 0 deletions docs/adr/CI-FAST-LANE-0041-path-scoped-policy-approval-lanes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# ADR-CI-FAST-LANE-0041: Path-Scoped Policy Approval Lanes

Date: 2026-10-08

## Status

Proposed

## Context

Website changes live in this monorepo, so a copy edit under `apps/website/` waits for the same
full-repository checks and human review as a change to the editor. The website's owners want to
ship website-only changes on their own timeline without weakening the safeguards for the rest of
the repository.

The `main` ruleset requires one approval, a `comfy_website_devs` approval for `apps/website/**`,
and the `lint-and-format`, `test`, `e2e-status`, and `website-e2e` checks. It dismisses stale
approvals on push and merges through the native merge queue.

## Decision

Introduce path-scoped delivery lanes, starting with the website:

- Each lane is a reviewed entry in `tools/cicd/fast-lane/src/lanes.ts` that names its path
prefixes, trusted authors, operator label, trusted labelers, and hold label.
- `pr-website-auto-approve.yaml` runs the `tools/cicd/fast-lane/` workspace from the default
branch. For an eligible same-repository pull request whose complete changed-file set is inside
the lane, it posts a policy-only approval bound to the exact head with a credential held in a
`main`-restricted environment, then arms native auto-merge or enters the queue. Every later run
re-reads live state and withdraws lane-owned approvals and merge state when the pull request
stops being eligible.
- A non-allowlisted author is eligible only on a trusted operator's `labeled` event for the
current head, and stays eligible only while the label remains applied.
- CodeRabbit skips `apps/website/**` for the trial; human change requests still block the lane.
- Production deploys record a GitHub deployment for their commit; rollback uses Vercel's Instant
Rollback.

### Alternatives not chosen

- **A GitHub App or bot identity instead of a personal token.** The trial uses an identity whose
team membership already satisfies the website review rule; moving to an App identity needs that
rule changed first.
- **A ruleset bypass list or CODEOWNERS change.** Either removes review for whole paths instead of
binding each approval to a policy decision on an exact head that can be withdrawn.
- **Keeping CodeRabbit on website files with `request_changes_workflow` disabled.** Its change
requests would still need a human to clear them on every website pull request.
- **Label freshness from timeline order.** Commit timeline entries carry author-controlled dates,
so a backdated push could sort before an older label.
- **One global concurrency group, or groups keyed by commit SHA.** A global group lets unrelated
pull requests cancel a pending hold or label run; SHA-keyed groups let two runs approve and
withdraw the same pull request at once. Runs are grouped per pull request instead.
- **Website-scoped lint and typecheck jobs.** The full typecheck (about 6 minutes) finishes before
the website unit and browser suites, so scoping it does not shorten the time to merge.
- **A deployment marker, staged promotion, and a rollback workflow.** The GitHub deployment record
and Vercel's deployment history already tie production to a commit, and Vercel's Instant Rollback
restores a known deployment.

## Consequences

### Positive

- A trusted author's website-only change can reach the merge queue without waiting for a human
reviewer, and every approval is tied to one head and can be withdrawn.
- The rest of the repository keeps its checks, review rule, and merge queue unchanged.
- Another package can add a lane with one entry and a copy of the workflow.

### Negative

- No human reviews a fast-laned diff, and `apps/website/**` includes build configuration and code
that the production build runs with deployment secrets.
- Policy approvals come from a personal account; that account's own manual merge actions after its
first policy review are treated as lane-owned.
- GitHub keeps only the newest pending run per concurrency group, so a pending `labeled` run can be
cancelled by another event on the same pull request; the operator re-runs it or re-applies the
label.
- The trial adds a workflow and an engine that operators must maintain.

## Notes

- Engine and operator model: [Package delivery lanes](../architecture/package-delivery-lanes.md).
- Trial runbook: [Website delivery validation](../architecture/website-delivery-validation.md).
72 changes: 72 additions & 0 deletions docs/architecture/package-delivery-lanes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Package delivery lanes

A package delivery lane lets one part of the monorepo choose its own balance of speed and rigor
without weakening the rest of the repository. A lane decides whether every changed path belongs to
the package, applies the package's reviewed approval policy to the exact commit, and then hands the
pull request to the repository's normal checks, merge queue, deployment, and rollback.

The website is the first lane. The approval engine in the `tools/cicd/fast-lane/` workspace is
package-neutral; the lane entry and the workflow are per lane.

## The dials a package owns

Each lane is an entry in `tools/cicd/fast-lane/src/lanes.ts`, written in lowercase. A policy change
receives normal repository review, so changing a dial is visible in history.

| Dial | Meaning |
| -------------------------- | -------------------------------------------------------------------------------------------- |
| `pathPrefixes` | The complete set of paths the lane is allowed to change. |
| `approval.identity` | The GitHub account whose token posts policy approvals; verified before the lane acts. |
| `approval.trustedAuthors` | Authors who may receive a policy approval without an operator label. |
| `approval.approvalLabel` | An explicit opt-in route for other authors. |
| `approval.trustedLabelers` | Operators allowed to apply that label. |
| `approval.holdLabel` | Stops the lane at its next run: dismisses lane approvals and disarms lane-owned merge state. |

## Fixed safety rules

These are implementation invariants, not package dials:

- The workflow and policy are checked out from the protected default branch. Pull request code is
never executed by the approval workflow.
- Forks, drafts, non-default base branches, stale event heads, incomplete file lists, and paths
outside the lane fail closed.
- Every approval is tied to the exact head SHA. A new commit needs a new policy decision.
- Approval-label provenance is bound to the current workflow event. A non-allowlisted author is
eligible only on the exact-head `labeled` event from a trusted operator; later events continue
while that same head has the policy approval and the label remains applied. Removing the label
withdraws the approval. Commit timestamps are never used as a proxy for push order.
- An active human change request blocks the lane. Comments and pending reviews do not count as
change requests.
- The credential's GitHub identity must match the identity declared in the policy, and it cannot
approve its own pull request.
- If verification or arming fails after the policy approval, every active policy approval is
dismissed. A run whose event head is no longer the pull request head changes nothing; the
repository ruleset dismisses approvals of older heads on push, and the run for the new head
decides again.
- Fast-lane runs for one pull request share a concurrency group, so at most one runs at a time and
GitHub keeps only the newest pending run. Hold and label-removal runs are safe to lose because
every run reads the live labels; a pending `labeled` approval run is not, and the operator
re-runs it or re-applies the label. Compensation attempts merge-state teardown and each active
policy-approval dismissal separately, so one failed API call does not skip the others.
- The lane disables only auto-merge or queue state that its identity enabled at or after its first
policy review on the pull request. Because the identity is a personal account, that includes the
account owner's own merge actions in that window.

The reusable TypeScript engine lives in `tools/cicd/fast-lane/src/`. `lanes.ts` holds the policies,
`policy.ts` the pure policy decisions, `github.ts` the GitHub transport, and `automation.ts` the
approval and merge lifecycle. Behavioral tests run `runFastLane` against an in-memory GitHub double
and cover each fixed rule.

## Adding a lane

1. Add the lane to `tools/cicd/fast-lane/src/lanes.ts`.
2. Copy `pr-website-auto-approve.yaml` and point it at the new lane and at the workflows whose
completion should re-run the lane.
3. Put the approval credential in a package-specific protected environment and restrict that
environment to the protected default branch.
4. Trial the lane with a disposable pull request. Record time from update to checks, approval,
queue entry, and production deployment before expanding its allowlist.

This process changes package policy, not the repository's underlying protection model. A package
can start with fast feedback and a narrow allowlist, then tighten or relax individual dials using
evidence from its own delivery times and failures.
41 changes: 41 additions & 0 deletions docs/architecture/website-delivery-validation.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Website delivery validation

The website trial answers one practical question: can a non-technical owner ship a website-only
change on their timeline while the rest of the monorepo keeps its current safeguards?

## Current lane

The `website` entry in `tools/cicd/fast-lane/src/lanes.ts` is the policy. It allows changes only
under `apps/website/`. `bertfy` is a trusted author. For other authors, a listed operator adds
`website-fast-lane:approve` to the current head; removing it withdraws the approval.
`website-fast-lane:hold`, a draft, a human change request, a fork, or a mixed-path change stops the
lane. A hold does not undo a merge that already happened. To resume after a hold, remove
`website-fast-lane:hold`; for an author who is not in the allowlist, also remove and re-apply
`website-fast-lane:approve`. If the run for an approval label shows as cancelled, a listed operator
re-runs it or re-applies the label; a re-run works only while the head is unchanged.

The `website-approval` environment supplies `WEBSITE_APPROVAL_TOKEN`. The credential currently
belongs to `christian-byrne`, whose team membership satisfies the website path review rule. The
workflow verifies that identity before it acts and cannot approve Christian's own pull requests.
After approval it uses squash auto-merge or enters an already-clean exact head in GitHub's native
queue without queue jumping. Each `CI: Tests E2E` or `CI: Website E2E` completion re-runs the lane
for its pull request in case native auto-merge did not hand the head to the queue.

Website-only pull requests run the normal required checks; the core unit and browser suites already
skip when nothing outside `apps/` changed. CodeRabbit is excluded from `apps/website/**` for this
trial; human change requests still block the lane.

## Production identity and rollback

Each production deploy records a `website-production` GitHub deployment for its commit, with the
immutable Vercel URL. To roll back, use Vercel's Instant Rollback on the last good production
deployment (dashboard or `vercel rollback <url>`). Vercel then stops assigning new production
deployments, so once the fix has merged, use Undo Rollback (or `vercel promote <url>`) on it.

## Evidence to record

Record timestamps for the contributor update, required checks, policy approval, queue entry, merge,
and production deployment. Also record any manual intervention, confusing UI, false-positive
check, or rollback problem. The trial succeeds only if the contributor can follow the path without
developer rescue and production can be tied to the expected commit. The allowlist should not expand
until the canary and rollback evidence are complete.
3 changes: 3 additions & 0 deletions knip.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ const config: KnipConfig = {
// Executed by models-snippets.test.ts inside the generated Node examples.
ignoreDependencies: ['mime-types']
},
'tools/cicd/fast-lane': {
project: ['src/**/*.ts']
},
'tools/architecture': {
project: ['src/**/*.ts']
},
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"dev": "vite --config vite.config.mts",
"fallow": "fallow",
"fallow:audit": "fallow audit",
"format:check": "oxfmt --check \"!apps/**\" \"!packages/**\" \"!tools/test-recorder/**\" \"!tools/architecture/**\"",
"format": "oxfmt --write \"!apps/**\" \"!packages/**\" \"!tools/test-recorder/**\" \"!tools/architecture/**\"",
"format:check": "oxfmt --check \"!apps/**\" \"!packages/**\" \"!tools/test-recorder/**\" \"!tools/architecture/**\" \"!tools/cicd/fast-lane/**\"",
"format": "oxfmt --write \"!apps/**\" \"!packages/**\" \"!tools/test-recorder/**\" \"!tools/architecture/**\" \"!tools/cicd/fast-lane/**\"",
"json-schema": "tsx scripts/generate-json-schema.ts",
"qa:desktop-frontend": "tsx scripts/qa-desktop-frontend.ts",
"deps:audit": "depcruise src",
Expand Down
9 changes: 9 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 54 additions & 0 deletions scripts/server-fact-gate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ describe('server-fact gate on a real diff', () => {
for (const linked of ['node_modules', 'tools']) {
symlinkSync(path.join(repoRoot, linked), path.join(dir, linked))
}
mkdirSync(path.join(dir, '.git/info'), { recursive: true })
writeFileSync(path.join(dir, '.git/info/exclude'), 'node_modules\ntools\n')
mkdirSync(path.join(dir, 'src'))
writeFileSync(path.join(dir, gatedFile), before.join('\n'))
Expand All @@ -216,6 +217,51 @@ describe('server-fact gate on a real diff', () => {
)
}

function runStagedGateDuringMerge() {
const dir = mkdtempSync(path.join(tmpdir(), 'server-fact-gate-'))
workDir = dir
const run = (...args: string[]) =>
execFileSync('git', args, { cwd: dir, stdio: 'ignore' })
run('init', '-q')
run('config', 'user.email', 'gate@test.invalid')
run('config', 'user.name', 'gate')
for (const linked of ['node_modules', 'tools']) {
symlinkSync(path.join(repoRoot, linked), path.join(dir, linked))
}
mkdirSync(path.join(dir, '.git/info'), { recursive: true })
writeFileSync(path.join(dir, '.git/info/exclude'), 'node_modules\ntools\n')
mkdirSync(path.join(dir, 'src'))
writeFileSync(path.join(dir, gatedFile), 'export const ready = true\n')
run('add', '.')
run('commit', '-q', '-m', 'base')
run('branch', 'feature')
writeFileSync(
path.join(dir, gatedFile),
'const { canInviteMembers } = useBillingCapabilities()\n' +
'export const canInvite = canInviteMembers.value || isPlanEnded.value\n'
)
run('add', gatedFile)
run('commit', '-q', '-m', 'upstream finding')
run('switch', '-q', 'feature')
writeFileSync(
path.join(dir, 'src/feature.ts'),
'export const feature = true\n'
)
run('add', 'src/feature.ts')
run('commit', '-q', '-m', 'feature')
run('merge', '--no-commit', '--no-ff', 'master')
return spawnSync(
process.execPath,
[
'--import',
'tsx',
path.join(repoRoot, 'scripts/server-fact-gate.ts'),
'--staged'
],
{ cwd: dir, encoding: 'utf8' }
)
}

it('reports a recombination exposed by deleting only its pendingServerFact wrapper lines', () => {
const wrapped = [
'const { canInviteMembers } = useBillingCapabilities()',
Expand Down Expand Up @@ -253,4 +299,12 @@ describe('server-fact gate on a real diff', () => {
expect(result.stderr).toBe('')
expect(result.status).toBe(0)
})

it('checks the feature delta instead of upstream files during a merge', () => {
const result = runStagedGateDuringMerge()

expect(result.stderr).toBe('')
expect(result.stdout).toContain('no findings on changed lines')
expect(result.status).toBe(0)
})
})
Loading
Loading