Skip to content

Commit eaa64e3

Browse files
committed
Merge origin/main into fsola/verified-profiles-relay
Signed-off-by: Bradley Axen <[email protected]>
2 parents b7dacd5 + eafd77e commit eaa64e3

113 files changed

Lines changed: 4918 additions & 2825 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.github/workflows/_ci-clients.yml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,13 @@ jobs:
177177
~/.gradle/wrapper
178178
key: gradle-${{ runner.os }}-${{ hashFiles('mobile/android/**/*.gradle*', 'mobile/android/gradle/wrapper/gradle-wrapper.properties', 'mobile/pubspec.lock') }}
179179
restore-keys: gradle-${{ runner.os }}-
180+
# The Hermit package cache above holds only Flutter, so the build's first
181+
# just and cmake calls download them.
182+
- name: Fetch Hermit tools
183+
if: matrix.lane == 'android'
184+
run: |
185+
scripts/ci-hermit-retry.sh ./bin/just --version
186+
scripts/ci-hermit-retry.sh ./bin/cmake --version
180187
# SDK component and plugin downloads intermittently fail on hosted
181188
# runners; retry once only for those, so real build failures still fail.
182189
- name: Build Android debug APK

‎.github/workflows/_ci-desktop-macos.yml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ jobs:
3131
steps:
3232
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
3333
- uses: cashapp/activate-hermit@cea9af7913204a965fd488637a8d1811bba2e616 # v1
34+
- name: Fetch Hermit tools
35+
run: scripts/ci-hermit-retry.sh ./bin/just --version
3436
- name: Verify macOS icon representations
3537
run: scripts/macos-icon.sh --check
3638
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32

‎.github/workflows/_ci-relay.yml‎

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,21 @@ jobs:
8888
uses: Mozilla-Actions/sccache-action@fc920bf0ec8de6ee65d409111f7ec508035751ba # v0.0.11 # zizmor: ignore[cache-poisoning] Bounded trial: only PR 5224 writes to its isolated merge-ref scope; trusted pushes retain production writes.
8989
with:
9090
version: v0.16.0
91+
# The sccache server checks its GHA cache storage at startup and refuses to
92+
# start when that fails (egress over the account limit, a failed read),
93+
# which used to fail cargo's first `sccache rustc -vV` and the build.
94+
# SCCACHE_IGNORE_SERVER_IO_ERROR doesn't cover startup in v0.16.0, so start
95+
# it here and build with plain rustc if it won't start.
96+
- name: Start sccache
97+
id: sccache
98+
if: steps.relay-artifacts-cache.outputs.cache-hit != 'true'
99+
run: |
100+
if sccache --start-server; then
101+
echo "wrapper=sccache" >> "$GITHUB_OUTPUT"
102+
else
103+
echo "::warning::sccache did not start; building without it"
104+
echo "wrapper=" >> "$GITHUB_OUTPUT"
105+
fi
91106
- name: Install cargo-nextest
92107
if: steps.relay-artifacts-cache.outputs.cache-hit != 'true' && matrix.artifact != 'relay-binaries'
93108
uses: taiki-e/install-action@0fd46367812ee04360509b4169d9f659d6892bb2 # v2.79.15
@@ -96,12 +111,12 @@ jobs:
96111
- name: Build relay binaries
97112
if: steps.relay-artifacts-cache.outputs.cache-hit != 'true' && matrix.artifact == 'relay-binaries'
98113
env:
99-
RUSTC_WRAPPER: sccache
114+
RUSTC_WRAPPER: ${{ steps.sccache.outputs.wrapper }}
100115
run: cargo build --profile ci -p buzz-relay -p git-credential-nostr
101116
- name: Build backend integration test archive
102117
if: steps.relay-artifacts-cache.outputs.cache-hit != 'true' && matrix.artifact == 'backend-integration-tests'
103118
env:
104-
RUSTC_WRAPPER: sccache
119+
RUSTC_WRAPPER: ${{ steps.sccache.outputs.wrapper }}
105120
run: |
106121
cargo nextest archive \
107122
--cargo-profile ci \
@@ -116,7 +131,7 @@ jobs:
116131
- name: Build PostgreSQL test archive
117132
if: steps.relay-artifacts-cache.outputs.cache-hit != 'true' && matrix.artifact == 'postgres-tests'
118133
env:
119-
RUSTC_WRAPPER: sccache
134+
RUSTC_WRAPPER: ${{ steps.sccache.outputs.wrapper }}
120135
run: |
121136
postgres_package_args=()
122137
while IFS= read -r package; do
@@ -191,6 +206,9 @@ jobs:
191206
steps:
192207
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
193208
- uses: cashapp/activate-hermit@cea9af7913204a965fd488637a8d1811bba2e616 # v1
209+
# pgschema has no --version; --help exits 0 once Hermit has fetched it.
210+
- name: Fetch Hermit tools
211+
run: scripts/ci-hermit-retry.sh ./bin/pgschema --help
194212
- name: Tune disposable PostgreSQL
195213
env:
196214
PGPASSWORD: ${{ env.BUZZ_TEST_POSTGRES_PASSWORD }}
@@ -243,6 +261,9 @@ jobs:
243261
steps:
244262
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
245263
- uses: cashapp/activate-hermit@cea9af7913204a965fd488637a8d1811bba2e616 # v1
264+
# pgschema has no --version; --help exits 0 once Hermit has fetched it.
265+
- name: Fetch Hermit tools
266+
run: scripts/ci-hermit-retry.sh ./bin/pgschema --help
246267
- name: Start integration services
247268
run: |
248269
for attempt in 1 2 3; do
@@ -433,6 +454,9 @@ jobs:
433454
steps:
434455
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
435456
- uses: cashapp/activate-hermit@cea9af7913204a965fd488637a8d1811bba2e616 # v1
457+
# pgschema has no --version; --help exits 0 once Hermit has fetched it.
458+
- name: Fetch Hermit tools
459+
run: scripts/ci-hermit-retry.sh ./bin/pgschema --help
436460
- name: Install cargo-nextest
437461
uses: taiki-e/install-action@0fd46367812ee04360509b4169d9f659d6892bb2 # v2.79.15
438462
with:

‎.github/workflows/ci.yml‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ jobs:
3434
with:
3535
fetch-depth: 2
3636
- uses: cashapp/activate-hermit@cea9af7913204a965fd488637a8d1811bba2e616 # v1
37+
# The first call of each Hermit tool downloads it. A stalled Node download
38+
# hung the selection step until this job's cap cancelled every gate. One
39+
# invocation fetches both tools, so its worst case (under 6 minutes)
40+
# still leaves the rest of the job inside the 10-minute cap.
41+
- name: Fetch Hermit tools
42+
run: scripts/ci-hermit-retry.sh sh -c './bin/node --version && ./bin/just --version'
3743
- uses: dorny/paths-filter@ceb8a2b8f2d89434be7ff52d3de7ec3738c5cc9d # v4.0.3
3844
id: filter
3945
with:
@@ -69,6 +75,7 @@ jobs:
6975
- 'scripts/model-capabilities.json'
7076
- 'scripts/normative-corpus.json'
7177
- 'scripts/ci-apt-retry.sh'
78+
- 'scripts/ci-hermit-retry.sh'
7279
- 'Justfile'
7380
desktop:
7481
- '.github/workflows/ci.yml'
@@ -104,6 +111,7 @@ jobs:
104111
- 'scripts/test-mobile-release-contract.sh'
105112
- 'scripts/test-mobile-release-candidate-publisher.sh'
106113
- 'scripts/test-mobile-worktree-overrides.sh'
114+
- 'scripts/ci-hermit-retry.sh'
107115
- '.github/workflows/mobile-release-candidate.yml'
108116
- '.github/workflows/ci.yml'
109117
- '.github/workflows/_ci-*.yml'
@@ -144,7 +152,7 @@ jobs:
144152
- name: CI required-context isolation contract
145153
run: scripts/test-ci-required-context-isolation.sh
146154
- name: CI path selection regression tests
147-
run: node --test scripts/ci-selection.test.mjs scripts/ci-required-gates.test.mjs scripts/ci-apt-retry.test.mjs
155+
run: node --test scripts/ci-selection.test.mjs scripts/ci-required-gates.test.mjs scripts/ci-apt-retry.test.mjs scripts/ci-hermit-retry.test.mjs
148156
- name: File size policy
149157
run: just file-size-check
150158

‎crates/buzz-agent/tests/permission_boundary.rs‎

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -136,18 +136,16 @@ async fn drive(
136136
// Session init + call-log helpers
137137
// ─────────────────────────────────────────────────────────────────────────────
138138

139-
fn call_log_path(tag: &str) -> String {
140-
let p = std::env::temp_dir().join(format!(
141-
"buzz_perm_calllog_{tag}_{}_{:x}.log",
142-
std::process::id(),
143-
std::time::SystemTime::now()
144-
.duration_since(std::time::UNIX_EPOCH)
145-
.unwrap_or_default()
146-
.as_nanos()
147-
));
148-
let s = p.to_string_lossy().to_string();
149-
let _ = std::fs::remove_file(&s);
150-
s
139+
/// A fresh call-log path inside its own temp dir. Keep the returned `TempDir`
140+
/// bound for the whole test: dropping it deletes the log, including when an
141+
/// assertion panics.
142+
fn call_log_path(tag: &str) -> (tempfile::TempDir, String) {
143+
let dir = tempfile::Builder::new()
144+
.prefix(&format!("buzz_perm_calllog_{tag}_"))
145+
.tempdir()
146+
.expect("create call-log temp dir");
147+
let path = dir.path().join("calls.log").to_string_lossy().into_owned();
148+
(dir, path)
151149
}
152150

153151
/// Invoked tool names recorded by fake_mcp (bare names, one per `tools/call`).
@@ -214,7 +212,7 @@ fn stop_reason(resp: &Value) -> String {
214212
/// the tally ends at one.
215213
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
216214
async fn test_allow_reaches_tool_exactly_once_and_not_before_approval() {
217-
let log = call_log_path("allow");
215+
let (_log_dir, log) = call_log_path("allow");
218216
let llm = spawn_capturing_llm(vec![shell_call("tc1"), openai_text("done")]).await;
219217
let mut h = Harness::spawn(&llm.url).await;
220218
let sid = init(
@@ -250,7 +248,7 @@ async fn test_allow_reaches_tool_exactly_once_and_not_before_approval() {
250248
/// sees a permission-denied tool error (the turn continues to `end_turn`).
251249
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
252250
async fn test_reject_option_never_invokes_tool() {
253-
let log = call_log_path("reject");
251+
let (_log_dir, log) = call_log_path("reject");
254252
let llm = spawn_capturing_llm(vec![shell_call("tc1"), openai_text("understood")]).await;
255253
let mut h = Harness::spawn(&llm.url).await;
256254
let sid = init(
@@ -321,7 +319,7 @@ async fn test_adversarial_outcomes_never_invoke_tool() {
321319
];
322320

323321
for (tag, build) in shapes {
324-
let log = call_log_path(tag);
322+
let (_log_dir, log) = call_log_path(tag);
325323
let llm = spawn_capturing_llm(vec![shell_call("tc1"), openai_text("ok")]).await;
326324
let mut h = Harness::spawn(&llm.url).await;
327325
let sid = init(
@@ -352,7 +350,7 @@ async fn test_adversarial_outcomes_never_invoke_tool() {
352350
/// waiter; the correct id then authorizes exactly once.
353351
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
354352
async fn test_stale_id_ignored_then_real_id_authorizes() {
355-
let log = call_log_path("staleid");
353+
let (_log_dir, log) = call_log_path("staleid");
356354
let llm = spawn_capturing_llm(vec![shell_call("tc1"), openai_text("done")]).await;
357355
let mut h = Harness::spawn(&llm.url).await;
358356
let sid = init(
@@ -406,7 +404,7 @@ async fn test_stale_id_ignored_then_real_id_authorizes() {
406404
/// by staying silent, and cancellation must not depend on that answer.
407405
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
408406
async fn test_cancel_while_waiting_executes_nothing_without_client_answer() {
409-
let log = call_log_path("cancelwait");
407+
let (_log_dir, log) = call_log_path("cancelwait");
410408
let llm = spawn_capturing_llm(vec![shell_call("tc1"), openai_text("done")]).await;
411409
let mut h = Harness::spawn(&llm.url).await;
412410
let sid = init(
@@ -452,7 +450,7 @@ async fn test_cancel_while_waiting_executes_nothing_without_client_answer() {
452450
/// proves only the allowed (second) call reached MCP — order-agnostic.
453451
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
454452
async fn test_crossed_parallel_decisions_authorize_only_matching_call() {
455-
let log = call_log_path("crossed");
453+
let (_log_dir, log) = call_log_path("crossed");
456454
// Two distinct registered tools so the call log distinguishes them by name.
457455
let llm = spawn_capturing_llm(vec![
458456
openai_tool_calls(&[
@@ -547,7 +545,7 @@ async fn test_load_skill_emits_no_permission_request() {
547545
/// objects once, forcing a hook invocation the test can observe.
548546
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
549547
async fn test_stop_hook_reaches_mcp_without_permission_ask() {
550-
let log = call_log_path("stophook");
548+
let (_log_dir, log) = call_log_path("stophook");
551549
// Text turn triggers the _Stop gate → hook objects once → agent loops →
552550
// second text turn, hook silent → end_turn. No model-issued tool call.
553551
let llm = spawn_capturing_llm(vec![
@@ -599,7 +597,7 @@ async fn test_stop_hook_reaches_mcp_without_permission_ask() {
599597
/// with an end-to-end proof that the negotiated version reaches the wire.
600598
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
601599
async fn test_v2_negotiation_emits_v2_request_shape() {
602-
let log = call_log_path("v2shape");
600+
let (_log_dir, log) = call_log_path("v2shape");
603601
let llm = spawn_capturing_llm(vec![shell_call("tc1"), openai_text("done")]).await;
604602
let mut h = Harness::spawn(&llm.url).await;
605603
let sid = init(

‎crates/buzz-agent/tests/regressions.rs‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1425,14 +1425,18 @@ async fn cancel_kills_inflight_tool_via_mcp_notification() {
14251425
])
14261426
.await;
14271427

1428+
// The agent stops buzz-dev-mcp with SIGKILL, so the server never deletes
1429+
// its own temp dirs. Point its TMPDIR at a dir this test owns and removes.
1430+
// Declared before `h` so it drops after the harness.
1431+
let dev_mcp_tmp = tempfile::TempDir::new().expect("create buzz-dev-mcp TMPDIR");
14281432
let mut h = Harness::spawn(&llm.url).await;
14291433
let sid = init_session(
14301434
&mut h,
14311435
json!([{
14321436
"name": "dev",
14331437
"command": &dev_mcp_bin,
14341438
"args": [],
1435-
"env": []
1439+
"env": [{"name": "TMPDIR", "value": dev_mcp_tmp.path()}]
14361440
}]),
14371441
)
14381442
.await;

‎crates/buzz-db/TESTING.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,12 @@ The wrapper isolates destructive tests by dropping the entire per-test
2121
database after the process exits. It does not `DELETE` rows or `TRUNCATE`
2222
shared tables, so tests may run concurrently without coordinating cleanup.
2323

24+
The wrapper drops only that per-test database. A test that needs another
25+
database or role on the server creates it with `test_support::ScratchDb` or
26+
`test_support::ScratchRole`, whose `Drop` removes it even when the test
27+
panics. Do not end a test with a manual `DROP DATABASE` or `DROP ROLE`: a
28+
failed assertion skips it and leaves the object behind.
29+
2430
## Choose the schema intentionally
2531

2632
Most tests use the committed desired-state schema from `schema/schema.sql`,

0 commit comments

Comments
 (0)