Skip to content

Commit 516de46

Browse files
baxenART2murderbotSmartieclaude
authored
Let plugin pages publish NIP-AR artifacts and embed the host thread view (#434)
Signed-off-by: ART2 <1f93b265cb51233526359491b17b06447c1ef75ed1d2a86de9701fdb58a43cdc@buzz.test.blockstaging.build> Signed-off-by: Bradley Axen <[email protected]> Signed-off-by: ART3 <822f566773c6b5ec5de21614f3900e5dd78a36d772fb826a3ee0f4b140d68255@buzz.block.builderlab.xyz> Co-authored-by: ART2 <1f93b265cb51233526359491b17b06447c1ef75ed1d2a86de9701fdb58a43cdc@buzz.test.blockstaging.build> Co-authored-by: murderbot <3754f8729004d95654c46dbab3129e4ab9ef05cc2534e2a3fbfc155983bd637b@buzz.block.builderlab.xyz> Co-authored-by: Smartie <fb3185faacfc3760b6b4fe0085a8878d8dd537f7a7671c7d3184fe1aa1b04df4@buzz.block.builderlab.xyz> Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]> Co-authored-by: ART3 <822f566773c6b5ec5de21614f3900e5dd78a36d772fb826a3ee0f4b140d68255@buzz.block.builderlab.xyz>
1 parent bfe4c7f commit 516de46

17 files changed

Lines changed: 629 additions & 16 deletions

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

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1376,6 +1376,41 @@ test.each([
13761376
},
13771377
);
13781378

1379+
test.each([
1380+
["conflict: artifact head changed", "failed", "conflict: the relay state"],
1381+
["error: internal server error", "unknown", "could not be confirmed"],
1382+
])(
1383+
"artifact refusal %s reaches broker/outbox as %s / %s",
1384+
async (reason, delivery, error) => {
1385+
const h = await harness();
1386+
let traffic, owner;
1387+
try {
1388+
browserFetch(h.base);
1389+
const transport = await connectBrokerTransport(h.base);
1390+
traffic = transport.subscribe(callbacks);
1391+
await until(() => h.requests.length >= 1);
1392+
owner = createOutbox(transport.viewer, transport.writer, {
1393+
load: () => [],
1394+
save() {},
1395+
});
1396+
const id = owner.outbox.send({
1397+
kind: 45010,
1398+
content: "",
1399+
tags: [["h", "00000000-0000-4000-8000-000000000001"]],
1400+
});
1401+
await until(() => h.publications.length === 1);
1402+
await h.sockets[0].receive(["OK", id, false, reason]);
1403+
await until(() => owner.outbox.snapshot()[0]?.delivery === delivery);
1404+
expect(owner.outbox.snapshot()[0].error).toContain(error);
1405+
} finally {
1406+
owner?.dispose();
1407+
traffic?.dispose();
1408+
vi.unstubAllGlobals();
1409+
await h.close();
1410+
}
1411+
},
1412+
);
1413+
13791414
test("joined batches survive the real HTTP boundary and retirement only rebuilds the affected scope", async () => {
13801415
const h = await harness();
13811416
let traffic;

‎dev/relay-broker.mjs‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1426,6 +1426,7 @@ export function relayBrokerPlugin({
14261426
30078,
14271427
40100,
14281428
1984,
1429+
45010,
14291430
...WORKFLOW_KINDS,
14301431
...((await getAuthority(relay)).channelCreation ? [9007] : []),
14311432
],
@@ -2396,6 +2397,8 @@ export function relayBrokerPlugin({
23962397
sent: false,
23972398
});
23982399
}
2400+
} else if (filters?.kind === 45010) {
2401+
// NIP-AR artifacts; the relay enforces write permission.
23992402
} else if (filters?.kind === 1984) {
24002403
if (!validReport(filters))
24012404
return json(res, 400, {
@@ -2492,7 +2495,11 @@ export function relayBrokerPlugin({
24922495
log.warn(
24932496
`${publication} stage=socket sent=${failure ? failure.sent : "unknown"} reason=${failure?.message ?? "unclassified failure"}${failure?.refusal ? ` refusal=${failure.refusal}` : ""}`,
24942497
);
2495-
return json(res, 503, {
2498+
// Match the relay's HTTP status for a proven CAS refusal.
2499+
const conflict =
2500+
failure?.sent === false &&
2501+
failure.refusal?.startsWith("conflict:");
2502+
return json(res, conflict ? 409 : 503, {
24962503
error:
24972504
failure?.sent === false &&
24982505
failure.refusal?.startsWith("rate-limited:")

‎dev/workflow-broker.test.mjs‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ it("real broker scoped history signs exact GET path/cursor and captured principa
227227
const other = await connectBrokerTransport(h.base, undefined, "secondary");
228228
expect(h.calls).toHaveLength(0);
229229
expect(first.writer.kinds).toEqual([
230-
30315, 30030, 7, 9, 40003, 42000, 9000, 9001, 30078, 40100, 1984, 30620,
231-
46020, 5,
230+
30315, 30030, 7, 9, 40003, 42000, 9000, 9001, 30078, 40100, 1984, 45010,
231+
30620, 46020, 5,
232232
]);
233233
await first.workflows.runs(id, cursor, signal());
234234
await other.workflows.runs(id, undefined, signal());
@@ -395,8 +395,8 @@ it("existing backend signs only canonical workflow sign/publish with exact own e
395395
const t = await connectBrokerTransport(h.base);
396396
live = await openBrokerSocket(t);
397397
expect(t.writer.kinds).toEqual([
398-
30315, 30030, 7, 9, 40003, 42000, 9000, 9001, 30078, 40100, 1984, 30620,
399-
46020, 5,
398+
30315, 30030, 7, 9, 40003, 42000, 9000, 9001, 30078, 40100, 1984, 45010,
399+
30620, 46020, 5,
400400
]);
401401
for (const input of [
402402
template(),

‎docs/plugin-architecture.md‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -568,13 +568,27 @@ unambiguous signed person/agent mentions share the inline hover styling. Names i
568568
ordinary prose never create notification intent or establish an identity.
569569

570570
The conversation preview exposes top-level `registerTool`, `registerCompletion` and `registerInline`
571-
methods and stable `conversation.ui.Composer` / `.Message` components. Generated
571+
methods and stable `conversation.ui.Composer` / `.Message` / `.Thread` components. Generated
572572
type-only `@buzz/author` declarations are exercised by a source-only external consumer
573573
fixture in `tests/fixtures/conversation-consumer`; it is built and installed only in
574574
the browser test's temporary profile.
575575
This remains a host-matched preview, not a stable cross-version SDK. Shared session
576576
ownership and trusted-plugin authority do not change.
577577

578+
`conversation.ui.Thread({ session, scope, channelId, channelName, messageId })`
579+
renders the existing `ThreadPanel` without its side-panel header, close control
580+
or Escape dismissal; the page owns the surrounding header and placement. The
581+
host supplies the rest of the Channels thread behavior: contribution renderers,
582+
message management (edit, delete, mark read/unread, and a notice above the
583+
thread to retry or discard a failed edit or deletion), session-channel
584+
recipients, Buzz link navigation, and one modal at a time for a registered panel
585+
or media review. The page passes its current ready session and stable
586+
community/viewer scope; retargeting disposes the old thread and its modal. As in
587+
Channels, showing a thread is one visit to its channel for unread state, and
588+
that visit lasts across threads of the same channel. The page holds no second
589+
message reader, cache or outbox.
590+
Exact message links still navigate to Channels rather than the page's route.
591+
578592
### Composer ownership and mention tools
579593

580594
The standard composer is reusable host UI in `features/messages`, not a mandatory

‎docs/relay-queries.md‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,11 @@ text to 16 KiB. Its ten-second deadline includes queued/authentication time.
564564
Disconnect, cancellation or timeout after dispatch, throwing sends, malformed
565565
receipts and internal/unknown negative receipts remain uncertain. Only a proven
566566
unsent operation or documented validation/admission rejection proves non-delivery.
567+
A compare-and-set refusal is proven too: `conflict:` for workflow and NIP-AR
568+
artifact (45010) events, which the dev broker answers as 409 like the relay's
569+
`/events`. Either reaches the outbox as `failed`; an artifact write carries a fixed
570+
`conflict:` error, so its writer reloads and reconciles instead of retrying a
571+
stale revision.
567572
NIP-01 rejection does not guarantee rollback of Buzz command side effects. Accepted
568573
command receipt text stays ephemeral; it is never journaled or replaced by an echo.
569574

‎src-tauri/src/relay.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ fn validate_event(community: &str, event: &EventTemplate) -> Result<()> {
223223
}
224224
} else if !matches!(
225225
event.kind,
226-
0 | 7 | 9 | 1984 | 9000 | 9001 | 20001 | 30030 | 30315 | 40003 | 40100 | 42000
226+
0 | 7 | 9 | 1984 | 9000 | 9001 | 20001 | 30030 | 30315 | 40003 | 40100 | 42000 | 45010
227227
) {
228228
return Err("This event is not supported by the packaged relay connection".into());
229229
}

0 commit comments

Comments
 (0)