Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

fix(signals): stop handing a paid feed's open positions to non-subscribers

nirholas3ce197a2d130
diff --git a/api/_lib/signal-engine.js b/api/_lib/signal-engine.js
index e67bdc9f8..5d859c84a 100644
--- a/api/_lib/signal-engine.js
+++ b/api/_lib/signal-engine.js
@@ -525,8 +525,48 @@ export async function getMarketplace({ network = 'mainnet', limit = 60, sort = '
return { network: net, sort: FEED_SORTS.has(sort) ? sort : 'edge', feeds: ranked, t: Date.now() };
}
-/** A single feed's detail: full stats + recent emissions (with realized outcomes). */
-export async function getFeedDetail({ slug, network = 'mainnet', emissionLimit = 40 }) {
+// Is this viewer entitled to a paid feed's live alpha? The publisher-owner and
+// any active, non-killed subscriber are; everyone else sees the track record with
+// the still-actionable parts withheld. Same rule the SSE stream enforces, so the
+// two surfaces can never disagree about who has paid.
+async function viewerEntitled(feed, viewerUserId) {
+ if (!viewerUserId) return false;
+ if (feed.owner_user_id === viewerUserId) return true;
+ const [sub] = await sql`
+ select 1 from signal_subscriptions
+ where feed_id = ${feed.id} and owner_user_id = ${viewerUserId}
+ and status = 'active' and killed = false
+ limit 1
+ `.catch(() => []);
+ return !!sub;
+}
+
+// An open position is the product a subscriber pays for: naming its mint (and
+// linking the entry tx, which names it too) IS the signal. A closed one is track
+// record whose alpha is spent, so it stays fully visible and on-chain verifiable:
+// that is the sales surface, and hiding it would make the feed's own claims
+// unauditable. Free feeds redact nothing.
+function redactOpenEmission(e) {
+ return {
+ ...e,
+ mint: null,
+ symbol: null,
+ name: null,
+ entry_sol: null,
+ buy_url: null,
+ sell_url: null,
+ locked: true,
+ };
+}
+
+/**
+ * A single feed's detail: full stats + recent emissions (with realized outcomes).
+ *
+ * `viewerUserId` decides how much of a PAID feed's OPEN positions come back
+ * (security review L7). Omit it and the caller is treated as anonymous, which is
+ * the safe default for a public page.
+ */
+export async function getFeedDetail({ slug, network = 'mainnet', emissionLimit = 40, viewerUserId = null }) {
const net = network === 'devnet' ? 'devnet' : 'mainnet';
const [feed] = await sql`
select f.*, a.name as publisher_name, a.avatar_url as publisher_avatar, a.profile_image_url as publisher_image, a.is_public
@@ -549,9 +589,14 @@ export async function getFeedDetail({ slug, network = 'mainnet', emissionLimit =
const shaped = shapeFeed(feed, rollups.get(Number(feed.id)), subCounts.get(Number(feed.id)) || 0, deliveryRollups.get(Number(feed.id)), metrics);
const solscan = (sig) => (sig && sig !== 'SIMULATED' ? (net === 'devnet' ? `https://solscan.io/tx/${sig}?cluster=devnet` : `https://solscan.io/tx/${sig}`) : null);
+ // A paid feed's open positions are withheld from anyone who has not paid.
+ const paid = shaped.pricing.per_signal_usdc > 0 || shaped.pricing.per_epoch_usdc > 0;
+ const entitled = paid ? await viewerEntitled(feed, viewerUserId) : true;
+ const gate = (row, raw) => (entitled || raw.status !== 'open' ? row : redactOpenEmission(row));
return {
...shaped,
- emissions: emissions.map((e) => ({
+ viewer: { entitled, paywalled: paid && !entitled },
+ emissions: emissions.map((e) => gate({
id: Number(e.id),
side: e.side,
mint: e.mint,
@@ -568,6 +613,7 @@ export async function getFeedDetail({ slug, network = 'mainnet', emissionLimit =
sell_url: solscan(e.source_sell_sig),
emitted_at: e.emitted_at,
closed_at: e.closed_at,
- })),
+ locked: false,
+ }, e)),
};
}
diff --git a/api/signals/feed.js b/api/signals/feed.js
index 8b5063200..596c35b61 100644
--- a/api/signals/feed.js
+++ b/api/signals/feed.js
@@ -3,13 +3,21 @@
*
* One feed's public detail page: the publisher's verified track record, the
* feed's proven signal accuracy (hit-rate, avg realized ROI, follower ROI,
- * emit→fill latency), pricing, and the recent emission log — every signal with
+ * emit-to-fill latency), pricing, and the recent emission log: every signal with
* its realized outcome and a link to the on-chain tx that proves it.
+ *
+ * On a PAID feed the still-OPEN positions are the product, so they come back
+ * redacted (no mint, no size, no tx links, `locked: true`) unless the caller is
+ * the publisher or an active subscriber (security review L7). Closed signals stay
+ * fully visible to everyone: that is the verifiable track record the feed sells
+ * itself on. The response is therefore viewer-dependent and must never land in a
+ * shared cache for a signed-in reader.
*/
import { cors, json, error, method, wrap, rateLimited } from '../_lib/http.js';
import { limits, clientIp } from '../_lib/rate-limit.js';
import { getFeedDetail } from '../_lib/signal-engine.js';
+import { getSessionUser, authenticateBearer, extractBearer } from '../_lib/auth.js';
import { normNetwork } from './_common.js';
export default wrap(async (req, res) => {
@@ -24,9 +32,19 @@ export default wrap(async (req, res) => {
if (!slug) return error(res, 400, 'invalid_slug', 'slug required');
const network = normNetwork(url.searchParams.get('network'));
- const detail = await getFeedDetail({ slug, network });
+ // Identify the reader so a paying subscriber sees what they bought. A failed
+ // or absent credential is simply an anonymous read, never an error.
+ const session = await getSessionUser(req).catch(() => null);
+ const bearer = session ? null : await authenticateBearer(extractBearer(req)).catch(() => null);
+ const viewerUserId = session?.id ?? bearer?.userId ?? null;
+
+ const detail = await getFeedDetail({ slug, network, viewerUserId });
if (!detail) return error(res, 404, 'not_found', 'feed not found');
- res.setHeader('cache-control', 'public, max-age=10, stale-while-revalidate=30');
+ // Only the anonymous projection is shareable across readers.
+ res.setHeader(
+ 'cache-control',
+ viewerUserId ? 'private, no-store' : 'public, max-age=10, stale-while-revalidate=30',
+ );
return json(res, 200, { feed: detail });
});
diff --git a/docs/signals.md b/docs/signals.md
index cded7bde4..2c753d68a 100644
--- a/docs/signals.md
+++ b/docs/signals.md
@@ -29,6 +29,8 @@ A **feed** (`signal_feeds`) belongs to a publisher agent and carries its pricing
The marketplace read is public and cacheable (no auth); subscribing is owner-authenticated and CSRF-protected because it commits your agent's wallet to paying and trading.
+**A paid feed's open positions are the product, so they are withheld until you subscribe.** `GET /api/signals/feed` returns every CLOSED signal in full to everyone, mint and Solscan links included: that is the verifiable track record the feed sells itself on, and hiding it would make its claims unauditable. A signal that is still open comes back with `locked: true` and no `mint`, `symbol`, `entry_sol`, or tx links unless you are the publisher or an active, non-killed subscriber, the same entitlement the live SSE stream enforces. The response carries `viewer: { entitled, paywalled }` so a client can render the locked rows honestly, and a signed-in read is `private, no-store` so one reader's entitlement never lands in a shared cache. Free feeds redact nothing.
+
## Walkthrough
1. Open [/signals](https://three.ws/signals). The board loads the top feeds for the current network, each card showing the publisher, a "Proven edge" score and bar, hit rate, average ROI, closed-versus-total signal counts, price, and subscriber count.
diff --git a/src/signal-detail.js b/src/signal-detail.js
index 068268c6e..4f263b525 100644
--- a/src/signal-detail.js
+++ b/src/signal-detail.js
@@ -92,6 +92,20 @@ function outcomeCell(e) {
}
function emitRow(e) {
+ // A paid feed's open positions come back redacted for anyone who has not
+ // subscribed. Render that as the deliberate state it is (locked, with the
+ // conviction and side still shown so the row still says something) rather
+ // than as a row with missing data.
+ if (e.locked) {
+ const conv = e.conviction != null ? `conv ${Math.round(e.conviction * 100)}%` : '';
+ const meta = [conv, 'subscribe to see the coin'].filter(Boolean).join('<span aria-hidden="true">·</span>');
+ return `
+ <div class="sd-emit is-locked">
+ <span class="sd-emit-side ${e.side}">${e.side}</span>
+ <div class="sd-emit-coin"><div class="sym" aria-label="Locked signal">🔒 Live signal</div><div class="meta">${meta}</div></div>
+ <div class="sd-emit-out">${outcomeCell(e)}</div>
+ </div>`;
+ }
const sym = e.symbol ? `$${escapeHtml(e.symbol)}` : `${escapeHtml((e.mint || '').slice(0, 6))}…`;
const conv = e.conviction != null ? `conv ${Math.round(e.conviction * 100)}%` : '';
const size = e.size_multiple != null ? `${e.size_multiple.toFixed(2)}× size` : '';
@@ -108,9 +122,14 @@ function emitRow(e) {
function logHtml(f) {
const rows = (f.emissions || []).map(emitRow).join('');
+ const lockedCount = (f.emissions || []).filter((e) => e.locked).length;
+ const note = lockedCount
+ ? `<p class="sd-note">${lockedCount} live ${lockedCount === 1 ? 'position is' : 'positions are'} open right now. Closed signals below are shown in full with their on-chain proof; subscribe to see the open ones as they are called.</p>`
+ : '';
return `
<div class="sd-panel">
<h2>Signal log <span class="sd-count">${f.emissions?.length || 0} recent · realized outcomes</span></h2>
+ ${note}
<div class="sd-log">${rows || '<p class="sd-note">No signals emitted yet. The moment this trader opens or closes a real position, it appears here.</p>'}</div>
</div>`;
}
diff --git a/src/signals.css b/src/signals.css
index f55660d1c..d441105ae 100644
--- a/src/signals.css
+++ b/src/signals.css
@@ -176,6 +176,10 @@
.sd-emit-out .pct.win { color: var(--sm-win); } .sd-emit-out .pct.loss { color: var(--sm-loss); } .sd-emit-out .pct.flat { color: var(--sm-flat); }
.sd-emit-out .badge { display: inline-block; margin-top: 3px; font: 600 9.5px/1 var(--mono, monospace); text-transform: uppercase; letter-spacing: 0.04em; color: var(--ink-dim, #889); }
.sd-emit-out .badge.open { color: var(--sm-accent); }
+/* A paid feed's open position, withheld until you subscribe. Dashed edge so it
+ reads as deliberately held back rather than as a row that failed to load. */
+.sd-emit.is-locked { background: var(--surface-1, rgba(255,255,255,0.02)); border: 1px dashed var(--surface-3, rgba(255,255,255,0.14)); }
+.sd-emit.is-locked .sd-emit-coin .sym { color: var(--ink-dim, #889); }
/* Subscribe panel */
.sd-price-row { display: flex; align-items: baseline; gap: 8px; margin-bottom: 16px; }