feat(market): wake managed buyers from Pulse

Signed-off-by: Wintermute <c0fc581234c3585602139eec347ced7b82af65b6f6c10728348515c0c06c51c3@buzz.block.builderlab.xyz>
This commit is contained in:
Wintermute
2026-09-01 23:52:51 -04:00
parent 91698b954e
commit 1b893365ae
12 changed files with 164 additions and 51 deletions

View File

@@ -283,6 +283,8 @@ with a TypeScript lookup table or an id comparison in a component.
17. **Databricks model discovery has one shared catalog authority.** Desktop and ACP call the shared `buzz-agent` discovery library; Desktop passes the effective merged `DATABRICKS_MODEL_FILTER` explicitly, and the library applies it to raw workspace endpoint IDs and Unity Catalog model-service FQNs after the additive union. A successful filtered-empty catalog is authoritative: it stays empty, disables switching, and never falls through to configured or known-model fallback. UC FQNs are catalog data and always use the MLflow Chat Completions route, regardless of family-looking text in their components.
18. **Market buying is opt-in managed-agent behavior, not a detached watcher process.** A truthy `BUZZ_MARKET_BUYER` in the effective definition/instance env lets `managed_agents/market_buyer.rs` configure the existing ACP heartbeat at spawn. Keep the prompt and interval Desktop-owned so runtime state and process lifetime stay truthful. The prompt gives the model relevance judgment but requires canonical channel verification, a duplicate-response check, and a signed channel `response`; joining is never treated as buying. Lazy harnesses must preserve a due heartbeat as wake-worthy work in `buzz-acp` rather than skipping it while the worker pool sleeps.
## The tests that enforce this
- `lib/agentConfigCore.test.mjs` — field model per harness × scope, clearing
@@ -325,6 +327,7 @@ with a TypeScript lookup table or an id comparison in a component.
unbroken Unicode text without horizontal overflow.
- `lib/agentDescription.test.mjs` — authored-description resolution: trim,
blank/missing → null.
- Rust: `managed_agents::market_buyer` pins opt-in heartbeat injection, and `buzz-acp`'s `lazy_pool_wakes_for_pending_heartbeat_without_channel_work` pins proactive wake-up while the worker pool sleeps.
- Rust: `runtime_metadata_env_vars` tests pin spawn-time key application.
- Rust: persona sharing/retention tests pin relay+owner scoping, durable
enqueue errors, relay rejection/unavailability, and accepted publication.

View File

@@ -17,7 +17,6 @@ import {
} from "@/features/profile/ui/ProfileAvatarWithStatus";
import { UserProfilePopover } from "@/features/profile/ui/UserProfilePopover";
import { Button } from "@/shared/ui/button";
import { Badge } from "@/shared/ui/badge";
import type { Channel, PresenceStatus } from "@/shared/api/types";
import { UserAvatar } from "@/shared/ui/UserAvatar";
import {
@@ -203,11 +202,7 @@ export function ChannelScreenHeader({
) : undefined
}
statusBadge={
marketProjection ? (
<Badge data-testid="market-header-status" variant="outline">
{marketProjection.scenario.status}
</Badge>
) : (
marketProjection ? undefined : (
<ChannelHeaderStatusBadge
ephemeralDisplay={activeChannelEphemeralDisplay}
/>

View File

@@ -60,8 +60,8 @@ export function presentMarketEvent(
case "settlement":
return {
amount: `${envelope.amountSats} fake sats`,
eyebrow: "Sandbox receipt",
summary: "Signed settlement metadata recorded. No real payment moved.",
eyebrow: "Settlement",
summary: `Paid ${envelope.amountSats} fake sats. No real payment moved.`,
title: `${envelope.actorName} marked the award settled`,
};
}

View File

@@ -1,5 +1,6 @@
import * as React from "react";
import type { ComponentProps } from "react";
import { WalletCards } from "lucide-react";
import { ChannelScreen } from "@/features/channels/ui/ChannelScreen";
import { MarketChannelProvider } from "@/features/market/lib/MarketChannelContext";
@@ -9,7 +10,6 @@ import { AgentWalletPanel } from "@/features/market/ui/AgentWalletPanel";
import type { Channel } from "@/shared/api/types";
import { cn } from "@/shared/lib/cn";
import { Button } from "@/shared/ui/button";
import { DrawerPanelIcon } from "@/shared/ui/DrawerPanelIcon";
import { useOptionalSidebar } from "@/shared/ui/sidebar";
export function MarketChannelHome({
@@ -22,7 +22,7 @@ export function MarketChannelHome({
}) {
const projection = useMarketChannelProjection(activeChannel, announcement);
const sidebar = useOptionalSidebar();
const [walletOpen, setWalletOpen] = React.useState(true);
const [walletOpen, setWalletOpen] = React.useState(false);
if (!projection)
return <ChannelScreen activeChannel={activeChannel} {...screenProps} />;
@@ -30,7 +30,7 @@ export function MarketChannelHome({
<Button
aria-label={walletOpen ? "Hide agent wallet" : "Show agent wallet"}
aria-pressed={walletOpen}
className="h-7 w-7 text-sidebar-foreground hover:bg-sidebar-accent"
className="h-8 w-8"
data-testid="market-wallet-toggle"
onClick={() => setWalletOpen((open) => !open)}
size="icon"
@@ -38,11 +38,7 @@ export function MarketChannelHome({
type="button"
variant="ghost"
>
<DrawerPanelIcon
className="-scale-x-100"
side={walletOpen ? "left" : "right"}
testId="market-wallet-toggle-icon"
/>
<WalletCards data-testid="market-wallet-toggle-icon" />
</Button>
);

View File

@@ -36,7 +36,6 @@ export function MarketContractCard({ scenario }: { scenario: MarketScenario }) {
<div className="min-w-0 p-5">
<div className="flex flex-wrap items-center gap-2">
<Badge variant="secondary">{scenario.eyebrow}</Badge>
<Badge variant="outline">{scenario.status}</Badge>
</div>
<h2 className="mt-3 text-xl font-semibold tracking-tight">
{scenario.title}

View File

@@ -2,7 +2,6 @@ import { useMarketChannel } from "@/features/market/lib/MarketChannelContext";
import { presentMarketEvent } from "@/features/market/lib/marketEventPresentation";
import { parseMarketEnvelope } from "@/features/market/lib/marketProtocol";
import { MarketEventCard } from "@/features/market/ui/MarketEventCard";
import { Badge } from "@/shared/ui/badge";
export function MarketMessageBody(
content: string,
@@ -18,12 +17,7 @@ export function MarketMessageBody(
) : null;
}
/**
* Inside a market channel, lifecycle envelopes read as ordinary chat
* messages: the agent's words as the body, with a small inline badge naming
* the signed transition. Outside market channels (Pulse, forwarded events)
* the full card treatment remains.
*/
/** Pulse keeps the listing card; inside its channel signed transitions read as chat. */
function MarketEventMessage({
authorPubkey,
content,
@@ -54,22 +48,15 @@ function MarketEventMessage({
className="min-w-0 max-w-full"
data-testid={`market-message-${envelope.type}`}
>
<div className="flex flex-wrap items-center gap-1.5">
<Badge className="capitalize" variant="secondary">
{presentation.eyebrow}
</Badge>
{presentation.amount ? (
<span className="text-xs font-medium text-muted-foreground">
{presentation.amount}
</span>
) : null}
{rejection ? (
<Badge data-testid="market-message-rejected" variant="destructive">
Rejected · {rejection.reason}
</Badge>
) : null}
</div>
<p className="mt-1 max-w-full text-message">{body}</p>
<p className="max-w-full text-message">{body}</p>
{rejection ? (
<p
className="mt-1 text-xs text-destructive"
data-testid="market-message-rejected"
>
Not accepted: {rejection.reason}
</p>
) : null}
</div>
);
}

View File

@@ -163,8 +163,7 @@ export const MessageRow = React.memo(
videoReviewCommentRootId?: string;
videoReviewContext?: VideoReviewContext;
}) {
// Keep the transient send state with its timestamp rather than collapsing
// it into a grouped message row with no header.
// Keep transient send state with its timestamp and header.
const isDisplayedAsContinuation = isContinuation && !message.pending;
const [expandedDiffId, setExpandedDiffId] = React.useState<string | null>(
null,
@@ -436,10 +435,7 @@ export const MessageRow = React.memo(
emojiOnly &&
"text-4xl leading-tight [&_p]:leading-tight [&_img[data-custom-emoji]]:h-[1.45em] [&_img[data-custom-emoji]]:align-middle [&_button:has(img[data-custom-emoji])]:align-middle",
)}
// Only pass the author pubkey for agent-authored messages so
// config-nudge cards can authenticate the sender. Uses the
// raw event signer (signerPubkey), not a relay-delegated display
// author, because the agent itself must have signed the card.
// Authenticate config nudges with the raw event signer.
configNudgeAuthorPubkey={getConfigNudgeAuthorPubkey(
message,
isKnownAgentPubkey,
@@ -935,8 +931,7 @@ export const MessageRow = React.memo(
</article>
</div>
);
// Callbacks (onReply, onToggleReaction) intentionally excluded: inline arrows
// from parent create new refs every render — including them defeats memo.
// Exclude unstable parent callback refs so memoization remains useful.
},
(prev, next) =>
prev.message.id === next.message.id &&