Skip to content

Commit ed2ba9a

Browse files
author
Carl
committed
Merge main into remember-the-community
Preserve identity-name service injection alongside the opt-in development relay seed; update the seed test helper for the combined signature. Signed-off-by: Carl <32a2e2c9d428ee08902cab75d956da2c1d235a22d4766b0dd4138bf6e2e5db1d@buzz.block.builderlab.xyz>
2 parents 71ffe4f + fdc8a71 commit ed2ba9a

102 files changed

Lines changed: 3913 additions & 831 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.

‎dev/relay-broker-api.test.mjs‎

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,6 +1007,24 @@ test.each([undefined, "22222222-2222-4222-8222-222222222222"])(
10071007
?.delivery,
10081008
).toBe("accepted"),
10091009
);
1010+
const temporaryCreationId = owner.outbox.send({
1011+
kind: 9007,
1012+
content: "",
1013+
tags: [
1014+
["h", "33333333-3333-4333-8333-333333333333"],
1015+
["name", "Standup"],
1016+
["visibility", "open"],
1017+
["channel_type", "stream"],
1018+
["ttl", "604800"],
1019+
],
1020+
});
1021+
await vi.waitFor(() =>
1022+
expect(
1023+
owner.local
1024+
.snapshot()
1025+
.find((row) => row.event.id === temporaryCreationId)?.delivery,
1026+
).toBe("accepted"),
1027+
);
10101028
const invitationId = owner.outbox.send({
10111029
kind: 9000,
10121030
content: "",
@@ -1036,7 +1054,7 @@ test.each([undefined, "22222222-2222-4222-8222-222222222222"])(
10361054
).toBe("accepted"),
10371055
);
10381056
expect(h.publications.map((event) => event.kind)).toEqual([
1039-
9007, 9000, 9,
1057+
9007, 9007, 9000, 9,
10401058
]);
10411059
const denied = await h.post("sign", {
10421060
kind: 9050,
@@ -1052,3 +1070,29 @@ test.each([undefined, "22222222-2222-4222-8222-222222222222"])(
10521070
}
10531071
},
10541072
);
1073+
1074+
test.each(["sign", "publish"])(
1075+
"%s rejects truncated channel creation tags as a client error",
1076+
async (route) => {
1077+
const h = await harness(success, { channelCreation: true });
1078+
try {
1079+
const required = [
1080+
["h", "11111111-1111-4111-8111-111111111111"],
1081+
["name", "Work"],
1082+
["visibility", "open"],
1083+
["channel_type", "stream"],
1084+
];
1085+
for (let length = 0; length < required.length; length++) {
1086+
const response = await h.post(route, {
1087+
kind: 9007,
1088+
created_at: 1700000000,
1089+
content: "",
1090+
tags: required.slice(0, length),
1091+
});
1092+
expect(response.status).toBe(400);
1093+
}
1094+
} finally {
1095+
await h.close();
1096+
}
1097+
},
1098+
);

‎dev/relay-broker.mjs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { validSessionCommand } from "./session-commands.mjs";
1+
import { validChannelCommand } from "./session-commands.mjs";
22
import { SocketRequestError } from "../src/features/relay/socket-requests.ts";
33
import {
44
validateWorkflowEvent,
@@ -1171,11 +1171,11 @@ export function relayBrokerPlugin({
11711171
const authority = await getAuthority(relay);
11721172
if (
11731173
!enrollment &&
1174-
!(authority.channelCreation && validSessionCommand(filters))
1174+
!(authority.channelCreation && validChannelCommand(filters))
11751175
)
11761176
return json(res, 400, {
11771177
error:
1178-
"Agent enrollment or session operation unavailable or invalid",
1178+
"Agent enrollment or channel operation unavailable or invalid",
11791179
sent: false,
11801180
});
11811181
} else if (![7, 9].includes(filters?.kind)) {

‎dev/session-commands.mjs‎

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { sessionMetadata } from "../src/features/sessions/metadata.ts";
22
// Host signing allowlist. No arbitrary kinds, roles or metadata edits.
33
const uuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
4-
export function validSessionCommand(event) {
4+
export function validChannelCommand(event) {
55
if (
66
!event ||
77
!Number.isSafeInteger(event.created_at) ||
@@ -25,18 +25,41 @@ export function validSessionCommand(event) {
2525
const [h, p] = tags;
2626
if (h?.length !== 2 || h[0] !== "h" || !uuid.test(h[1])) return false;
2727
if (event.kind === 9007) {
28-
const expected = ["h", "name", "visibility", "channel_type", "about"];
28+
const expected = ["h", "name", "visibility", "channel_type"];
29+
const optional = tags.slice(expected.length);
30+
const optionalNames = optional.map(([name]) => name);
31+
const validOptionalOrder = [[], ["about"], ["ttl"], ["about", "ttl"]].some(
32+
(names) =>
33+
names.length === optionalNames.length &&
34+
names.every((name, index) => name === optionalNames[index]),
35+
);
36+
const about = optional.find(([name]) => name === "about");
37+
const ttl = optional.find(([name]) => name === "ttl");
38+
const aboutValue = about?.[1];
39+
const ttlValue = ttl?.[1];
2940
return (
3041
event.content === "" &&
31-
tags.length === expected.length &&
32-
tags.every(
33-
(tag, index) => tag.length === 2 && tag[0] === expected[index],
34-
) &&
42+
tags.length >= expected.length &&
43+
validOptionalOrder &&
44+
tags
45+
.slice(0, expected.length)
46+
.every(
47+
(tag, index) => tag.length === 2 && tag[0] === expected[index],
48+
) &&
3549
!!tags[1][1].trim() &&
3650
[...tags[1][1]].length <= 120 &&
37-
tags[2][1] === "private" &&
51+
["open", "private"].includes(tags[2][1]) &&
3852
tags[3][1] === "stream" &&
39-
sessionMetadata(tags[4][1]) !== undefined
53+
(!about ||
54+
(about.length === 2 &&
55+
[...aboutValue].length <= 1000 &&
56+
(sessionMetadata(aboutValue) !== undefined ||
57+
!aboutValue.includes("Buzz session (")))) &&
58+
(!ttl ||
59+
(ttl.length === 2 &&
60+
/^(?:[1-9]\d*)$/.test(ttlValue) &&
61+
Number(ttlValue) <= 2_147_483_647 &&
62+
sessionMetadata(aboutValue) === undefined))
4063
);
4164
}
4265
if (event.kind === 9000)

‎dev/session-commands.test.mjs‎

Lines changed: 113 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { expect, it } from "vitest";
2-
import { validSessionCommand } from "./session-commands.mjs";
2+
import { validChannelCommand } from "./session-commands.mjs";
33
const id = "11111111-1111-4111-8111-111111111111";
44
const event = (body, tags = [["h", id]]) => ({
55
kind: 9050,
@@ -8,11 +8,11 @@ const event = (body, tags = [["h", id]]) => ({
88
tags,
99
});
1010
it("rejects custom session commands", () => {
11-
expect(validSessionCommand(event({ action: "create", title: "Work" }))).toBe(
11+
expect(validChannelCommand(event({ action: "create", title: "Work" }))).toBe(
1212
false,
1313
);
1414
expect(
15-
validSessionCommand(
15+
validChannelCommand(
1616
event({ action: "move", parent_id: id, confirm_history: true }),
1717
),
1818
).toBe(false);
@@ -27,17 +27,17 @@ it("allows only ordinary invitations, without extra roles", () => {
2727
["p", "a".repeat(64)],
2828
],
2929
};
30-
expect(validSessionCommand(invite)).toBe(true);
30+
expect(validChannelCommand(invite)).toBe(true);
3131
expect(
32-
validSessionCommand({
32+
validChannelCommand({
3333
...invite,
3434
tags: [...invite.tags, ["role", "admin"]],
3535
}),
3636
).toBe(false);
37-
expect(validSessionCommand({ ...invite, kind: 9001 })).toBe(false);
37+
expect(validChannelCommand({ ...invite, kind: 9001 })).toBe(false);
3838
});
3939

40-
it("allows only private stream creation marked for Sessions", () => {
40+
it("preserves strict Sessions metadata while allowing ordinary stream visibility", () => {
4141
const create = {
4242
kind: 9007,
4343
created_at: 1,
@@ -50,31 +50,29 @@ it("allows only private stream creation marked for Sessions", () => {
5050
["about", "Buzz session (buzz.sessions/v1)"],
5151
],
5252
};
53-
expect(validSessionCommand(create)).toBe(true);
53+
expect(validChannelCommand(create)).toBe(true);
5454
const child = (description) => ({
5555
...create,
5656
tags: create.tags.map((tag) =>
5757
tag[0] === "about" ? ["about", description] : tag,
5858
),
5959
});
6060
expect(
61-
validSessionCommand(child(`Buzz session (buzz.sessions/v1)\nparent:${id}`)),
61+
validChannelCommand(child(`Buzz session (buzz.sessions/v1)\nparent:${id}`)),
6262
).toBe(true);
6363
for (const parent of ["invalid", `${id}\nrole:owner`, `${id}extra`]) {
6464
expect(
65-
validSessionCommand(
65+
validChannelCommand(
6666
child(`Buzz session (buzz.sessions/v1)\nparent:${parent}`),
6767
),
6868
).toBe(false);
6969
}
7070
for (const [index, value] of [
71-
[2, "open"],
7271
[3, "dm"],
73-
[4, "arbitrary"],
7472
[1, " "],
7573
]) {
7674
expect(
77-
validSessionCommand({
75+
validChannelCommand({
7876
...create,
7977
tags: create.tags.map((tag, i) =>
8078
i === index ? [tag[0], value] : tag,
@@ -83,25 +81,123 @@ it("allows only private stream creation marked for Sessions", () => {
8381
).toBe(false);
8482
}
8583
expect(
86-
validSessionCommand({
84+
validChannelCommand({
85+
...create,
86+
tags: create.tags.map((tag, i) =>
87+
i === 4 ? [tag[0], "Buzz session (forged)"] : tag,
88+
),
89+
}),
90+
).toBe(false);
91+
expect(
92+
validChannelCommand({
8793
...create,
8894
tags: [...create.tags, ["p", "a".repeat(64)]],
8995
}),
9096
).toBe(false);
91-
expect(validSessionCommand({ ...create, content: "extra" })).toBe(false);
97+
expect(validChannelCommand({ ...create, content: "extra" })).toBe(false);
9298
});
9399

94100
it("accepts one trailing outbox identifier for invitations and rejects ambiguous envelopes", () => {
95101
const invite = (tags) => ({ kind: 9000, created_at: 1, content: "", tags });
96102
const h = ["h", id],
97103
p = ["p", "a".repeat(64)],
98104
client = ["client-id", id];
99-
expect(validSessionCommand(invite([h, p, client]))).toBe(true);
105+
expect(validChannelCommand(invite([h, p, client]))).toBe(true);
100106
for (const tags of [
101107
[h, p, client, client],
102108
[client, h, p],
103109
[h, p, ["client-id", "invalid"]],
104110
[h, p, [...client, "extra"]],
105111
])
106-
expect(validSessionCommand(invite(tags))).toBe(false);
112+
expect(validChannelCommand(invite(tags))).toBe(false);
113+
});
114+
115+
it("allows bounded ordinary stream creation without a Sessions marker", () => {
116+
const create = {
117+
kind: 9007,
118+
created_at: 1,
119+
content: "",
120+
tags: [
121+
["h", id],
122+
["name", "Release notes"],
123+
["visibility", "open"],
124+
["channel_type", "stream"],
125+
["about", "Updates for the team"],
126+
],
127+
};
128+
expect(validChannelCommand(create)).toBe(true);
129+
expect(
130+
validChannelCommand({ ...create, tags: create.tags.slice(0, 4) }),
131+
).toBe(true);
132+
expect(
133+
validChannelCommand({
134+
...create,
135+
tags: create.tags.map((tag) =>
136+
tag[0] === "about" ? ["about", "x".repeat(1001)] : tag,
137+
),
138+
}),
139+
).toBe(false);
140+
expect(
141+
validChannelCommand({
142+
...create,
143+
tags: create.tags.map((tag) =>
144+
tag[0] === "about" ? ["about", "Buzz session (forged)"] : tag,
145+
),
146+
}),
147+
).toBe(false);
148+
expect(
149+
validChannelCommand({
150+
...create,
151+
tags: [...create.tags, ["ttl", "604800"]],
152+
}),
153+
).toBe(true);
154+
expect(
155+
validChannelCommand({
156+
...create,
157+
tags: [...create.tags.slice(0, 4), ["ttl", "604800"]],
158+
}),
159+
).toBe(true);
160+
for (const ttl of ["0", "-1", "forever", "2147483648"]) {
161+
expect(
162+
validChannelCommand({
163+
...create,
164+
tags: [...create.tags, ["ttl", ttl]],
165+
}),
166+
).toBe(false);
167+
}
168+
});
169+
170+
it("rejects every truncated mandatory creation-tag prefix", () => {
171+
const create = {
172+
kind: 9007,
173+
created_at: 1,
174+
content: "",
175+
tags: [
176+
["h", id],
177+
["name", "Release notes"],
178+
["visibility", "open"],
179+
["channel_type", "stream"],
180+
],
181+
};
182+
for (let length = 0; length < create.tags.length; length++)
183+
expect(
184+
validChannelCommand({ ...create, tags: create.tags.slice(0, length) }),
185+
).toBe(false);
186+
});
187+
188+
it("does not add temporary cleanup to Sessions metadata", () => {
189+
const create = {
190+
kind: 9007,
191+
created_at: 1,
192+
content: "",
193+
tags: [
194+
["h", id],
195+
["name", "Work"],
196+
["visibility", "private"],
197+
["channel_type", "stream"],
198+
["about", "Buzz session (buzz.sessions/v1)"],
199+
["ttl", "604800"],
200+
],
201+
};
202+
expect(validChannelCommand(create)).toBe(false);
107203
});

‎docs/agents.md‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,3 +352,13 @@ These are targeted integration checks, not a completed `just scan`. The earlier
352352
scan was interrupted during browser tests; broader hosted CI, DCO and required
353353
review remain separate gates. Packaged native activity without the development
354354
broker remains unsupported.
355+
356+
### Shared identity names
357+
358+
The Agents plugin supplies display names through the app-owned identity-name
359+
service. Each relay session binds its own view. A ready native record takes
360+
precedence only in its matching community; otherwise the ready legacy display
361+
inventory supplies the name, then the public profile. Plugin disable restores
362+
public-profile names. These labels never change identity keys, membership,
363+
credentials, or runtime admission. Profile panels consume this view; other name
364+
surfaces are being migrated separately.
142 KB
Loading
143 KB
Loading

‎docs/contributing.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,6 +256,11 @@ configuration/dependencies and hook-runner changes select this job; a missing ba
256256
runs it conservatively. Its selection is independent of the unit-test skip, so
257257
CSS-only and viewer-only errors still block a push. Documentation-only and
258258
native-only pushes skip both jobs. Both selected jobs must pass.
259+
On a busy machine, set `BUZZ_TEST_WORKERS=2 git push` to limit Vitest worker
260+
concurrency in the hook. The optional value must be a positive integer; leaving
261+
it unset preserves Vitest's default. This also applies to direct Vitest runs and
262+
does not change test selection, timeouts, assertions, or retries.
263+
259264
Neither job fetches, installs dependencies, formats, builds Rust, or starts browsers.
260265
The design job disables pnpm dependency auto-repair. Install dependencies when
261266
switching branches, not during a push.

‎src/app/agent-control.integration.test.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,5 +167,7 @@ it("retains working injected control across Agents disable/re-enable and communi
167167
vi
168168
.mocked(invoke)
169169
.mock.calls.filter(([cmd]) => cmd.startsWith("agent_control_")),
170-
).toEqual(Array.from({ length: 4 }, () => ["agent_control_snapshot"]));
170+
// Four explicit reads plus five naming-provider activations (re-enable,
171+
// then disconnected and connected sessions for each joined community).
172+
).toEqual(Array.from({ length: 9 }, () => ["agent_control_snapshot"]));
171173
});

0 commit comments

Comments
 (0)