Skip to content

Commit bf920ee

Browse files
authored
Bind trusted runner routing to canonical PR revisions (#1271)
Trusted Linux jobs should select the managed runner only when the workflow is executing in the canonical repository. Fork-local events must remain on GitHub-hosted labels even when their branch and repository identities match each other. The PR dispatchers call main-pinned reusable workflows without runner, trust, or checkout inputs. Those workflows independently derive trust from the canonical head and base repository identities, while checkout uses the immutable SHA GitHub associated with the caller event. The managed image is intentionally lean, so the desktop composite explicitly installs a commit-pinned stable Rust toolchain instead of relying on hosted-image defaults. Playwright CI is bounded to eight workers because the host exposes more logical CPUs than each runner pod requests. The coverage fixture now waits for the filesystem to expose a new change-time tick before asserting same-size rewrite detection, avoiding false failures on fast overlay filesystems without weakening the signature assertion. Co-authored-by: Wes McKinney <wesm@users.noreply.github.com>
1 parent 59672c4 commit bf920ee

10 files changed

Lines changed: 33 additions & 57 deletions

File tree

.github/actions/build-desktop-artifact/action.yml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ runs:
2626
with:
2727
node-version: "24"
2828

29+
- uses: dtolnay/rust-toolchain@4cda84d5c5c54efe2404f9d843567869ab1699d4 # stable
30+
2931
- name: Setup MinGW (Windows)
3032
if: runner.os == 'Windows'
3133
uses: msys2/setup-msys2@66cd2cce69caa17b53920067426061ca1de3a884 # v2
@@ -73,7 +75,7 @@ runs:
7375
cd desktop
7476
export TAURI_ENV_TARGET_TRIPLE="$AGENTSVIEW_TARGET_TRIPLE"
7577
npm run prepare-sidecar
76-
build_cmd=(npx tauri build --bundles "$BUNDLE")
78+
build_cmd=(npx tauri build --verbose --bundles "$BUNDLE")
7779
if [ -n "$AGENTSVIEW_TARGET_TRIPLE" ]; then
7880
build_cmd+=(--target "$AGENTSVIEW_TARGET_TRIPLE")
7981
fi

.github/workflows/bench-pr.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,3 @@ permissions: read-all
2020
jobs:
2121
run:
2222
uses: kenn-io/agentsview/.github/workflows/bench.yml@main
23-
with:
24-
checkout_ref: refs/pull/${{ github.event.pull_request.number }}/merge

.github/workflows/bench.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,6 @@ name: Bench Gate
2929

3030
on:
3131
workflow_call:
32-
inputs:
33-
checkout_ref:
34-
description: Git ref to check out
35-
required: false
36-
type: string
37-
default: ""
3832
concurrency:
3933
group: bench-${{ github.head_ref || github.ref }}
4034
cancel-in-progress: true
@@ -45,11 +39,10 @@ permissions:
4539
jobs:
4640
bench-gate:
4741
name: Benchmark Gate
48-
runs-on: ${{ (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || 'ubuntu-latest' }}
42+
runs-on: ${{ github.repository == 'kenn-io/agentsview' && (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || 'ubuntu-latest' }}
4943
steps:
5044
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
5145
with:
52-
ref: ${{ inputs.checkout_ref || github.sha }}
5346
persist-credentials: false
5447
fetch-depth: 0
5548

.github/workflows/ci-pr.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,3 @@ permissions: read-all
1111
jobs:
1212
run:
1313
uses: kenn-io/agentsview/.github/workflows/ci.yml@main
14-
with:
15-
checkout_ref: refs/pull/${{ github.event.pull_request.number }}/merge

.github/workflows/ci.yml

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@ name: CI
22

33
on:
44
workflow_call:
5-
inputs:
6-
checkout_ref:
7-
description: Git ref to check out
8-
required: false
9-
type: string
10-
default: ""
115
push:
126
branches: [main]
137
# Run on every pull request regardless of base branch so stacked PRs that
@@ -23,11 +17,10 @@ permissions:
2317

2418
jobs:
2519
lint:
26-
runs-on: ${{ (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || 'ubuntu-latest' }}
20+
runs-on: ${{ github.repository == 'kenn-io/agentsview' && (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || 'ubuntu-latest' }}
2721
steps:
2822
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
2923
with:
30-
ref: ${{ inputs.checkout_ref || github.sha }}
3124
persist-credentials: false
3225

3326
- uses: actions/setup-go@924ae3a1cded613372ab5595356fb5720e22ba16 # v6.5.0
@@ -43,11 +36,10 @@ jobs:
4336
run: make lint-ci
4437

4538
frontend:
46-
runs-on: ${{ (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || 'ubuntu-latest' }}
39+
runs-on: ${{ github.repository == 'kenn-io/agentsview' && (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || 'ubuntu-latest' }}
4740
steps:
4841
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
4942
with:
50-
ref: ${{ inputs.checkout_ref || github.sha }}
5143
persist-credentials: false
5244

5345
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
@@ -74,11 +66,10 @@ jobs:
7466
working-directory: frontend
7567

7668
frontend-node-25:
77-
runs-on: ${{ (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || 'ubuntu-latest' }}
69+
runs-on: ${{ github.repository == 'kenn-io/agentsview' && (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || 'ubuntu-latest' }}
7870
steps:
7971
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
8072
with:
81-
ref: ${{ inputs.checkout_ref || github.sha }}
8273
persist-credentials: false
8374

8475
- uses: actions/setup-node@48b55a011bda9f5d6aeb4c2d9c7362e8dae4041e # v6.4.0
@@ -94,11 +85,10 @@ jobs:
9485
working-directory: frontend
9586

9687
docs:
97-
runs-on: ${{ (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || 'ubuntu-latest' }}
88+
runs-on: ${{ github.repository == 'kenn-io/agentsview' && (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || 'ubuntu-latest' }}
9889
steps:
9990
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
10091
with:
101-
ref: ${{ inputs.checkout_ref || github.sha }}
10292
persist-credentials: false
10393

10494
- uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
@@ -117,11 +107,10 @@ jobs:
117107
run: make docs-check
118108

119109
scripts:
120-
runs-on: ${{ (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || 'ubuntu-latest' }}
110+
runs-on: ${{ github.repository == 'kenn-io/agentsview' && (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || 'ubuntu-latest' }}
121111
steps:
122112
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
123113
with:
124-
ref: ${{ inputs.checkout_ref || github.sha }}
125114
persist-credentials: false
126115

127116
- name: Run shell script tests
@@ -134,15 +123,14 @@ jobs:
134123
135124
test:
136125
name: Go Test (${{ matrix.os }})
137-
runs-on: ${{ contains(fromJSON('["ubuntu-latest","ubuntu-24.04","ubuntu-22.04"]'), matrix.os) && (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || matrix.os }}
126+
runs-on: ${{ contains(fromJSON('["ubuntu-latest","ubuntu-24.04","ubuntu-22.04"]'), matrix.os) && github.repository == 'kenn-io/agentsview' && (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || matrix.os }}
138127
strategy:
139128
fail-fast: false
140129
matrix:
141130
os: [ubuntu-latest, windows-latest]
142131
steps:
143132
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
144133
with:
145-
ref: ${{ inputs.checkout_ref || github.sha }}
146134
fetch-depth: 0
147135
persist-credentials: false
148136

@@ -196,7 +184,6 @@ jobs:
196184
steps:
197185
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
198186
with:
199-
ref: ${{ inputs.checkout_ref || github.sha }}
200187
persist-credentials: false
201188

202189
- name: Prepare placeholder sidecar resource
@@ -227,11 +214,10 @@ jobs:
227214
run: cargo test --locked --manifest-path desktop/src-tauri/Cargo.toml --lib install_downloaded_update
228215

229216
coverage:
230-
runs-on: ${{ (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || 'ubuntu-latest' }}
217+
runs-on: ${{ github.repository == 'kenn-io/agentsview' && (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || 'ubuntu-latest' }}
231218
steps:
232219
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
233220
with:
234-
ref: ${{ inputs.checkout_ref || github.sha }}
235221
fetch-depth: 0
236222
persist-credentials: false
237223

@@ -259,7 +245,7 @@ jobs:
259245
run: echo "::warning::Codecov upload failed"
260246

261247
integration:
262-
runs-on: ${{ (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || 'ubuntu-latest' }}
248+
runs-on: ${{ github.repository == 'kenn-io/agentsview' && (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || 'ubuntu-latest' }}
263249
services:
264250
postgres:
265251
image: pgvector/pgvector:pg18
@@ -277,7 +263,6 @@ jobs:
277263
steps:
278264
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
279265
with:
280-
ref: ${{ inputs.checkout_ref || github.sha }}
281266
fetch-depth: 0
282267
persist-credentials: false
283268

@@ -326,11 +311,10 @@ jobs:
326311
TEST_SSH_KEY: ${{ github.workspace }}/testdata/ssh/test_key
327312

328313
e2e:
329-
runs-on: ${{ (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || 'ubuntu-latest' }}
314+
runs-on: ${{ github.repository == 'kenn-io/agentsview' && (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || 'ubuntu-latest' }}
330315
steps:
331316
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
332317
with:
333-
ref: ${{ inputs.checkout_ref || github.sha }}
334318
fetch-depth: 0
335319
persist-credentials: false
336320

.github/workflows/desktop-artifacts-pr.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,3 @@ permissions: read-all
1919
jobs:
2020
run:
2121
uses: kenn-io/agentsview/.github/workflows/desktop-artifacts.yml@main
22-
with:
23-
checkout_ref: refs/pull/${{ github.event.pull_request.number }}/merge

.github/workflows/desktop-artifacts.yml

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,6 @@ name: Desktop Artifacts
22

33
on:
44
workflow_call:
5-
inputs:
6-
checkout_ref:
7-
description: Git ref to check out
8-
required: false
9-
type: string
10-
default: ""
115
# Linux builds use the managed public fleet for main and same-repository PRs.
126
# macOS builds live in desktop-macos-main.yml.
137
push:
@@ -29,7 +23,7 @@ concurrency:
2923
jobs:
3024
build:
3125
name: Desktop Build (${{ matrix.name }})
32-
runs-on: ${{ contains(fromJSON('["ubuntu-latest","ubuntu-24.04","ubuntu-22.04"]'), matrix.os) && (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || matrix.os }}
26+
runs-on: ${{ contains(fromJSON('["ubuntu-latest","ubuntu-24.04","ubuntu-22.04"]'), matrix.os) && github.repository == 'kenn-io/agentsview' && (github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.event.pull_request.base.repo.full_name == github.repository)) && 'kenn-linux-x64-public' || matrix.os }}
3327
strategy:
3428
fail-fast: false
3529
matrix:
@@ -55,7 +49,6 @@ jobs:
5549
steps:
5650
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
5751
with:
58-
ref: ${{ inputs.checkout_ref || github.sha }}
5952
persist-credentials: false
6053

6154
- uses: ./.github/actions/build-desktop-artifact

.github/workflows/docker.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ env:
1616

1717
jobs:
1818
build-and-push:
19-
runs-on: ${{ github.ref == 'refs/heads/main' && 'kenn-linux-x64-public' || 'ubuntu-latest' }}
19+
runs-on: ${{ github.repository == 'kenn-io/agentsview' && github.ref == 'refs/heads/main' && 'kenn-linux-x64-public' || 'ubuntu-latest' }}
2020
steps:
2121
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
2222
with:

frontend/playwright.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const isCI = process.env.CI === "true";
55
export default defineConfig({
66
testDir: "e2e",
77
timeout: isCI ? 45_000 : 20_000,
8+
workers: isCI ? 8 : undefined,
89
retries: 0,
910
use: {
1011
baseURL: "http://127.0.0.1:8090",

internal/sync/change_time_test.go

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"os"
77
"path/filepath"
88
"testing"
9+
"time"
910

1011
"github.com/stretchr/testify/assert"
1112
"github.com/stretchr/testify/require"
@@ -20,14 +21,22 @@ func TestFileChangeTimeDetectsSameStatRewrite(t *testing.T) {
2021
beforeChange, ok := fileChangeTime(path, beforeInfo)
2122
require.True(t, ok, "native change time unavailable")
2223

23-
require.NoError(t, os.WriteFile(path, []byte("after!"), 0o600))
24-
require.NoError(t, os.Chtimes(
25-
path, beforeInfo.ModTime(), beforeInfo.ModTime(),
26-
))
27-
afterInfo, err := os.Stat(path)
28-
require.NoError(t, err)
29-
afterChange, ok := fileChangeTime(path, afterInfo)
30-
require.True(t, ok, "native change time unavailable after rewrite")
24+
var afterInfo os.FileInfo
25+
afterChange := beforeChange
26+
deadline := time.Now().Add(2 * time.Second)
27+
for afterChange == beforeChange && time.Now().Before(deadline) {
28+
require.NoError(t, os.WriteFile(path, []byte("after!"), 0o600))
29+
require.NoError(t, os.Chtimes(
30+
path, beforeInfo.ModTime(), beforeInfo.ModTime(),
31+
))
32+
afterInfo, err = os.Stat(path)
33+
require.NoError(t, err)
34+
afterChange, ok = fileChangeTime(path, afterInfo)
35+
require.True(t, ok, "native change time unavailable after rewrite")
36+
if afterChange == beforeChange {
37+
time.Sleep(time.Millisecond)
38+
}
39+
}
3140

3241
require.Equal(t, beforeInfo.Size(), afterInfo.Size(),
3342
"fixture must preserve size")

0 commit comments

Comments
 (0)