Skip to content

Commit 26dc4f0

Browse files
committed
[loop4] renumber fork 0033->0035 task_system; absorb upstream 0033/0034 (migration renumber plan step 1)
Merge upstream/main through be8d775 (19 commits since cdab765), resolving migrations/0033_task_system.sql -> migrations/0035_task_system.sql against upstream's 0033_private_managed_agent_fts + 0034_replica_heartbeat_ vacuum_truncate. migration.rs count assert resolved to 35; fork task_system test re-indexed migrations[32]->[34], version 33->35. See buzz-program/specs/MIGRATION-RENUMBER-PLAN.md Step 1. Known debt carried (NOT from this commit): check:file-sizes red on merged tree (ChannelPane.tsx 983->1009, allowed 1000) = Loop 2 extraction task; buzz-relay mesh_demo 504!=200 fails identically on pre-merge product/main. Signed-off-by: Michael Fethe <[email protected]>
2 parents 3dd4942 + be8d775 commit 26dc4f0

118 files changed

Lines changed: 14333 additions & 766 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.

‎.env.example‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,12 @@ RUST_LOG=buzz_relay=debug,buzz_datastore=info,buzz_db=debug,buzz_auth=debug,buzz
172172
# Use `buzz-acp models` to discover available model IDs.
173173
# BUZZ_ACP_MODEL=
174174

175+
# Optional Databricks model-picker visibility filter. Discovery-only; this does
176+
# not grant inference access. Comma-separated full-string * / ? patterns are
177+
# OR-matched against raw workspace endpoint and Unity Catalog model-service IDs.
178+
# Unset or blank shows every catalog entry. A nonblank value with no usable patterns is invalid.
179+
# DATABRICKS_MODEL_FILTER=databricks-*,data_tools.goose.*
180+
175181
# ── Timeouts & sessions ──────────────────────────────────────────────────────
176182
# Max seconds per agent turn before timeout (default 320 = ~5 min).
177183
# BUZZ_ACP_TURN_TIMEOUT=320

‎.github/scripts/codex-security-review.js‎

Lines changed: 35 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ const completedMarker = (baseSha, headSha) =>
2828

2929
const reviewCommand = (headSha) => `${REVIEW_COMMAND} ${headSha}`;
3030

31+
const isOrganizationMember = (association) =>
32+
association === "MEMBER" || association === "OWNER";
33+
34+
const hasCurrentReviewLabel = (pullRequest) =>
35+
pullRequest.labels?.some(
36+
(label) =>
37+
(typeof label === "string" ? label : label?.name) ===
38+
CURRENT_REVIEW_LABEL,
39+
) ?? false;
40+
3141
const isObject = (value) =>
3242
value !== null && typeof value === "object" && !Array.isArray(value);
3343

@@ -352,6 +362,15 @@ async function prepare({ github, context, core }) {
352362
);
353363
return;
354364
}
365+
if (
366+
context.eventName === "pull_request_target" &&
367+
!isOrganizationMember(pullRequest.author_association)
368+
) {
369+
core.info(
370+
`Pull request #${prNumber} requires authorization from a Block organization member.`,
371+
);
372+
return;
373+
}
355374
if (pullRequest.head.sha !== requestedHeadSha) {
356375
core.setFailed(
357376
`Pull request #${prNumber} moved after this review was authorized. ` +
@@ -362,6 +381,7 @@ async function prepare({ github, context, core }) {
362381

363382
const baseSha = await getLiveMainSha({ github, context });
364383
const commitRange = `${baseSha}...${pullRequest.head.sha}`;
384+
core.setOutput("authorized", "true");
365385
core.setOutput("pr_number", String(prNumber));
366386
core.setOutput("trigger_actor", context.actor);
367387
core.setOutput("base_sha", baseSha);
@@ -455,9 +475,12 @@ async function prepareBaseReconciliation({ github, context, core }) {
455475
}
456476

457477
async function invalidatePullRequestUpdate({ github, context, core }) {
458-
const association = context.payload.pull_request?.author_association || "";
459-
const existingOnly = association === "MEMBER" || association === "OWNER";
460-
await invalidate({ github, context, core, existingOnly });
478+
await invalidate({
479+
github,
480+
context,
481+
core,
482+
existingOnlyForOrganizationMembers: true,
483+
});
461484
}
462485

463486
async function invalidate({
@@ -466,6 +489,7 @@ async function invalidate({
466489
core,
467490
prNumber: requestedPrNumber,
468491
existingOnly = false,
492+
existingOnlyForOrganizationMembers = false,
469493
}) {
470494
const prNumber = Number(
471495
requestedPrNumber ?? context.payload.pull_request?.number,
@@ -482,8 +506,14 @@ async function invalidate({
482506
}
483507

484508
const existing = await findReviewComment({ github, context, prNumber });
485-
if (!existing && existingOnly) {
486-
await clearCurrentReview({ github, context, prNumber });
509+
const shouldOnlyUpdateExisting =
510+
existingOnly ||
511+
(existingOnlyForOrganizationMembers &&
512+
isOrganizationMember(pullRequest.author_association));
513+
if (!existing && shouldOnlyUpdateExisting) {
514+
if (existingOnly || hasCurrentReviewLabel(pullRequest)) {
515+
await clearCurrentReview({ github, context, prNumber });
516+
}
487517
core.info(`PR #${prNumber} has no Codex security review to invalidate.`);
488518
return;
489519
}

‎.github/scripts/codex-security-review.test.js‎

Lines changed: 84 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
"use strict";
22

33
const assert = require("node:assert/strict");
4+
const { readFileSync } = require("node:fs");
5+
const path = require("node:path");
46
const test = require("node:test");
57

68
const {
@@ -20,8 +22,14 @@ const NEW_BASE_SHA = "e".repeat(40);
2022
const MARKER = "<!-- codex-security-review -->";
2123
const CURRENT_REVIEW_LABEL = "codex-security-review-current";
2224

23-
function pullRequest({ baseSha = OLD_BASE_SHA, headSha = HEAD_SHA } = {}) {
25+
function pullRequest({
26+
authorAssociation = "CONTRIBUTOR",
27+
baseSha = OLD_BASE_SHA,
28+
headSha = HEAD_SHA,
29+
labels = [],
30+
} = {}) {
2431
return {
32+
author_association: authorAssociation,
2533
state: "open",
2634
base: {
2735
ref: "main",
@@ -33,6 +41,7 @@ function pullRequest({ baseSha = OLD_BASE_SHA, headSha = HEAD_SHA } = {}) {
3341
repo: { full_name: "outside/buzz" },
3442
},
3543
changed_files: 1,
44+
labels,
3645
};
3746
}
3847

@@ -48,6 +57,7 @@ function harness({
4857
const updated = [];
4958
const addedLabels = [];
5059
const removedLabels = [];
60+
const removeLabelCalls = [];
5161
const outputs = new Map();
5262
const failures = [];
5363
const notices = [];
@@ -85,6 +95,7 @@ function harness({
8595
addedLabels.push(input);
8696
},
8797
removeLabel: async (input) => {
98+
removeLabelCalls.push(input);
8899
if (!labelExists) {
89100
throw Object.assign(new Error("not found"), { status: 404 });
90101
}
@@ -139,6 +150,7 @@ function harness({
139150
info,
140151
notices,
141152
outputs,
153+
removeLabelCalls,
142154
removedLabels,
143155
storedComments,
144156
updated,
@@ -198,6 +210,7 @@ test("prepare binds a member command to the named head SHA", async () => {
198210
await prepare(current);
199211

200212
assert.deepEqual(current.failures, []);
213+
assert.equal(current.outputs.get("authorized"), "true");
201214
assert.equal(current.outputs.get("head_sha"), HEAD_SHA);
202215
assert.equal(current.outputs.get("base_sha"), BASE_SHA);
203216
assert.notEqual(current.outputs.get("base_sha"), OLD_BASE_SHA);
@@ -218,6 +231,62 @@ test("prepare binds a member command to the named head SHA", async () => {
218231
);
219232
});
220233

234+
test("pull request authorization uses the live author association", async () => {
235+
const member = harness({
236+
pull: pullRequest({ authorAssociation: "MEMBER" }),
237+
});
238+
member.context.eventName = "pull_request_target";
239+
member.context.payload.pull_request = {
240+
number: 6816,
241+
head: { sha: HEAD_SHA },
242+
author_association: "CONTRIBUTOR",
243+
};
244+
245+
await prepare(member);
246+
247+
assert.equal(member.outputs.get("authorized"), "true");
248+
assert.deepEqual(member.failures, []);
249+
250+
const external = harness({
251+
pull: pullRequest({ authorAssociation: "CONTRIBUTOR" }),
252+
});
253+
external.context.eventName = "pull_request_target";
254+
external.context.payload.pull_request = {
255+
number: 6816,
256+
head: { sha: HEAD_SHA },
257+
author_association: "MEMBER",
258+
};
259+
260+
await prepare(external);
261+
262+
assert.equal(external.outputs.get("authorized"), undefined);
263+
assert.deepEqual(external.failures, []);
264+
assert.match(external.info.at(-1), /requires authorization/);
265+
});
266+
267+
test("PR mutation jobs use pull request write permission", () => {
268+
const workflow = readFileSync(
269+
path.join(__dirname, "../workflows/codex-security-review.yml"),
270+
"utf8",
271+
);
272+
for (const jobName of [
273+
"reconcile-base-reviews",
274+
"invalidate-previous-review",
275+
"post-review",
276+
]) {
277+
const start = workflow.indexOf(` ${jobName}:\n`);
278+
assert.notEqual(start, -1, `missing workflow job ${jobName}`);
279+
const remainder = workflow.slice(start + 2);
280+
const nextJob = remainder.search(/^ [a-z][a-z0-9-]*:\n/m);
281+
const job =
282+
nextJob === -1
283+
? workflow.slice(start)
284+
: workflow.slice(start, start + 2 + nextJob);
285+
assert.match(job, /^ pull-requests: write$/m);
286+
assert.doesNotMatch(job, /^ issues: write$/m);
287+
}
288+
});
289+
221290
test("prepare rejects review commands without a full exact SHA", async () => {
222291
const state = harness();
223292
state.context.payload.comment.body = "@buzz-security-review";
@@ -431,7 +500,10 @@ test("base reconciliation does not create comments on unreviewed PRs", async ()
431500

432501
test("pull request updates invalidate member reviews without adding placeholders", async () => {
433502
const reviewed = harness({
434-
pull: pullRequest({ headSha: OTHER_HEAD_SHA }),
503+
pull: pullRequest({
504+
authorAssociation: "MEMBER",
505+
headSha: OTHER_HEAD_SHA,
506+
}),
435507
comments: [
436508
reviewComment(
437509
`${MARKER}\n<!-- codex-security-review-range:${BASE_SHA}...${HEAD_SHA} -->\nold review`,
@@ -441,7 +513,7 @@ test("pull request updates invalidate member reviews without adding placeholders
441513
reviewed.context.eventName = "pull_request_target";
442514
reviewed.context.payload.pull_request = {
443515
number: 6816,
444-
author_association: "MEMBER",
516+
author_association: "CONTRIBUTOR",
445517
};
446518
await reviewed.github.rest.issues.addLabels({
447519
issue_number: 6816,
@@ -456,23 +528,28 @@ test("pull request updates invalidate member reviews without adding placeholders
456528
);
457529
assert.equal(reviewed.removedLabels.length, 1);
458530

459-
const unreviewed = harness();
531+
const unreviewed = harness({
532+
pull: pullRequest({ authorAssociation: "OWNER" }),
533+
});
460534
unreviewed.context.eventName = "pull_request_target";
461535
unreviewed.context.payload.pull_request = {
462536
number: 6816,
463-
author_association: "OWNER",
537+
author_association: "CONTRIBUTOR",
464538
};
465539

466540
await invalidatePullRequestUpdate(unreviewed);
467541

468542
assert.equal(unreviewed.created.length, 0);
469543
assert.equal(unreviewed.updated.length, 0);
544+
assert.equal(unreviewed.removeLabelCalls.length, 0);
470545

471-
const external = harness();
546+
const external = harness({
547+
pull: pullRequest({ authorAssociation: "CONTRIBUTOR" }),
548+
});
472549
external.context.eventName = "pull_request_target";
473550
external.context.payload.pull_request = {
474551
number: 6816,
475-
author_association: "CONTRIBUTOR",
552+
author_association: "MEMBER",
476553
};
477554

478555
await invalidatePullRequestUpdate(external);

‎.github/workflows/ci.yml‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ jobs:
130130
steps:
131131
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3
132132
- uses: cashapp/activate-hermit@cea9af7913204a965fd488637a8d1811bba2e616 # v1
133-
- uses: rui314/setup-mold@9c9c13bf4c3f1adef0cc596abc155580bcb04444 # v1
133+
- uses: rui314/setup-mold@7e4f20ad28a2e8ca6fd0892ccf72e2abb706b9c3 # v1
134134
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2.9.1
135135
with:
136136
key: sherpa-cache-v1
@@ -155,7 +155,7 @@ jobs:
155155
with:
156156
fetch-depth: 2
157157
- uses: cashapp/activate-hermit@cea9af7913204a965fd488637a8d1811bba2e616 # v1
158-
- uses: rui314/setup-mold@9c9c13bf4c3f1adef0cc596abc155580bcb04444 # v1
158+
- uses: rui314/setup-mold@7e4f20ad28a2e8ca6fd0892ccf72e2abb706b9c3 # v1
159159
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2.9.1
160160
with:
161161
workspaces: desktop/src-tauri
@@ -347,7 +347,7 @@ jobs:
347347
target/ci/git-credential-nostr
348348
target/ci/backend-integration-tests.tar.zst
349349
key: relay-artifacts-${{ runner.os }}-${{ hashFiles('crates/**', 'migrations/**', 'Dockerfile', 'Cargo.toml', 'Cargo.lock', 'rust-toolchain.toml', '.cargo/config.toml', '.github/workflows/ci.yml') }}
350-
- uses: rui314/setup-mold@9c9c13bf4c3f1adef0cc596abc155580bcb04444 # v1
350+
- uses: rui314/setup-mold@7e4f20ad28a2e8ca6fd0892ccf72e2abb706b9c3 # v1
351351
if: steps.relay-artifacts-cache.outputs.cache-hit != 'true'
352352
- uses: Swatinem/rust-cache@e18b497796c12c097a38f9edb9d0641fb99eee32 # v2.9.1
353353
if: steps.relay-artifacts-cache.outputs.cache-hit != 'true'
@@ -516,7 +516,7 @@ jobs:
516516
run: |
517517
./bin/pgschema apply --file schema/schema.sql --auto-approve
518518
docker exec -i -e PGPASSWORD=buzz_dev buzz-postgres \
519-
psql -U buzz -d buzz -v ON_ERROR_STOP=1 < scripts/attach-schema-partitions.sql
519+
psql -U buzz -d buzz -v ON_ERROR_STOP=1 < scripts/reconcile-schema-after-pgschema.sql
520520
docker exec -e PGPASSWORD=buzz_dev buzz-postgres \
521521
psql -U buzz -d buzz -qtA -c "
522522
INSERT INTO communities (id, host)
@@ -677,7 +677,7 @@ jobs:
677677
run: |
678678
./bin/pgschema apply --file schema/schema.sql --auto-approve
679679
docker exec -i -e PGPASSWORD=buzz_dev buzz-postgres \
680-
psql -U buzz -d buzz -v ON_ERROR_STOP=1 < scripts/attach-schema-partitions.sql
680+
psql -U buzz -d buzz -v ON_ERROR_STOP=1 < scripts/reconcile-schema-after-pgschema.sql
681681
docker exec -e PGPASSWORD=buzz_dev buzz-postgres \
682682
psql -U buzz -d buzz -qtA -c "
683683
INSERT INTO communities (id, host)

‎.github/workflows/codex-security-review.yml‎

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ jobs:
1717
# This workflow posts an advisory review; its skipped jobs are not a merge
1818
# gate and must not be configured as required status checks.
1919
# MEMBER and OWNER are GitHub's associations for members of the `block`
20-
# organization. Outside contributors require this exact command from one
20+
# organization. The trusted prepare step checks the live PR instead of the
21+
# event snapshot. Outside contributors require this exact command from one
2122
# of those members: @buzz-security-review <full-head-sha>
2223
if: >-
2324
github.repository == 'block/buzz' && (
2425
(
2526
github.event_name == 'pull_request_target' &&
26-
github.event.pull_request.draft == false &&
27-
contains(fromJSON('["MEMBER", "OWNER"]'), github.event.pull_request.author_association)
27+
github.event.pull_request.draft == false
2828
) || (
2929
github.event_name == 'issue_comment' &&
3030
github.event.issue.pull_request &&
@@ -38,6 +38,7 @@ jobs:
3838
contents: read
3939
pull-requests: read
4040
outputs:
41+
authorized: ${{ steps.pr.outputs.authorized }}
4142
pr_number: ${{ steps.pr.outputs.pr_number }}
4243
trigger_actor: ${{ steps.pr.outputs.trigger_actor }}
4344
base_sha: ${{ steps.pr.outputs.base_sha }}
@@ -111,8 +112,7 @@ jobs:
111112
cancel-in-progress: true
112113
permissions:
113114
contents: read
114-
issues: write
115-
pull-requests: read
115+
pull-requests: write
116116
steps:
117117
- name: Checkout trusted workflow support
118118
if: matrix.pr_number != 0
@@ -192,8 +192,7 @@ jobs:
192192
cancel-in-progress: true
193193
permissions:
194194
contents: read
195-
issues: write
196-
pull-requests: read
195+
pull-requests: write
197196
steps:
198197
- name: Checkout trusted workflow support
199198
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
@@ -212,6 +211,7 @@ jobs:
212211
security-review:
213212
name: Run Codex Security Review
214213
needs: prepare-review
214+
if: needs.prepare-review.outputs.authorized == 'true'
215215
runs-on: ubuntu-latest
216216
environment: codex-review
217217
timeout-minutes: 30
@@ -453,8 +453,7 @@ jobs:
453453
cancel-in-progress: true
454454
permissions:
455455
contents: read
456-
issues: write
457-
pull-requests: read
456+
pull-requests: write
458457
env:
459458
CODEX_MODEL: gpt-5.6-sol
460459
REVIEW_JSON: ${{ needs.security-review.outputs.review_json }}

‎.github/workflows/desktop-release-cache-proof.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ jobs:
6767
name: Prove Linux cache visibility
6868
if: github.repository == 'block/buzz'
6969
runs-on: ubuntu-latest
70-
container: ubuntu:24.04@sha256:561618e2c15bf2397621dd04f96926663a3b5616c189cf7e38db7e82f5c538ea
70+
container: ubuntu:24.04@sha256:33ceb71981b602c1a7443a53469e4dba065f7503eab3078a2d7a57a2ab987517
7171
timeout-minutes: 15
7272
defaults:
7373
run:

0 commit comments

Comments
 (0)