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(x-content): stop hand-sent posts from holding the schedule shut for a day

ni3a72a1de47da0b
diff --git a/api/_lib/x-content/schedule.js b/api/_lib/x-content/schedule.js
index 1871331d4..b3cbc1867 100644
--- a/api/_lib/x-content/schedule.js
+++ b/api/_lib/x-content/schedule.js
@@ -185,8 +185,16 @@ export function pickDue({
if (last && now < Date.parse(last.publishedAt) + cadence.minimumMinutesApart * MINUTE) {
return { item: null, reason: `spacing: the last post went out at ${last.publishedAt}` };
}
- const lastDay = published.filter((row) => now - Date.parse(row.publishedAt) < DAY).length;
- if (lastDay >= cadence.dailyCap) return { item: null, reason: `daily cap of ${cadence.dailyCap} reached` };
+ // The cap governs the schedule, so it counts scheduled posts only. A post an
+ // operator forces out by hand carries no slot, and counting those let one
+ // afternoon of owner-requested posts (four between 17:43 and 19:49 UTC on
+ // 2026-09-20) hold every scheduled slot shut for the next 24 hours, so the
+ // account went quiet the morning after its busiest day. Slots already limit
+ // the schedule to one post each, and the spacing check above still measures
+ // from the last post of any kind, so a hand-sent post can never be followed by
+ // a scheduled one minutes later.
+ const scheduledLastDay = published.filter((row) => row.slot && now - Date.parse(row.publishedAt) < DAY).length;
+ if (scheduledLastDay >= cadence.dailyCap) return { item: null, reason: `daily cap of ${cadence.dailyCap} scheduled posts reached` };
// On a weekend a flagship post waits for Monday instead of filling a lower slot.
const holdFlagship = Boolean(cadence.flagshipWeekdaysOnly) && isWeekend(slot.opensAt);
diff --git a/docs/x-content-pipeline.md b/docs/x-content-pipeline.md
index 4222b75c9..95bb5320b 100644
--- a/docs/x-content-pipeline.md
+++ b/docs/x-content-pipeline.md
@@ -108,6 +108,8 @@ X Articles require the posting account to be on X Premium.
Cadence lives at the top of the file: `slots` (each `{ tier, at }` in UTC), `windowMinutes` (how far a slot's opening may be jittered), `minimumMinutesApart`, `dailyCap`, and `quietHoursUtc` (a `["HH:MM", "HH:MM"]` pair, which may wrap midnight). `quality` sets the similarity limits and the maximum same-lane and same-pattern runs.
+**What the cap counts:** `dailyCap` limits scheduled posts in the last 24 hours, and a scheduled post is one the scheduler placed in a slot. A post an operator sends by hand (`run --id`) carries no slot and does not count toward it, because counting those let four owner-requested posts on one afternoon hold every slot shut the following morning. Hand-sent posts do still count toward `minimumMinutesApart`, which measures from the last post of any kind, so the schedule never fires minutes after a manual post. To fill an open slot by hand and keep the schedule's bookkeeping right, run a scheduler tick (`npm run x:content -- run`, no `--id`): it takes the same lock as the cron, picks the post the cron would, and records the slot so the cron sees it as used.
+
## How the next post is chosen
**When:** three slots a day, one per tier, eight hours apart, every day of the week: T3 at 04:00 UTC, T2 at 12:00, T1 at 20:00. That cadence is the owner's (2026-09-20): three a day, weekends included. It replaced a tighter window drawn from the volume study, which measured every original post against 1-minute candles of the $THREE pool and found that a post between 12:00 and 20:00 UTC was followed by a volume response about 1.7 times as often as one outside it. Two of the three slots still sit in that window; the third takes the off-peak turn so the day stays evenly spaced. Each slot opens at a minute only the production seed can reproduce (up to `windowMinutes` late), and stays open for three hours (`slotOpenMinutes`), so a missed run or a deploy still posts, but no slot is ever spent twice. Slots are at least `minimumMinutesApart` apart even at their latest opening, so an earlier post never blocks a later slot. There are no quiet hours: with fixed slots eight hours apart, the slot times already say when the account posts. `flagshipWeekdaysOnly` would withhold the T1 slot on Saturday and Sunday and keep T1 posts out of the lower slots too; the queue no longer sets it, and it is the one lever that would return the account to weekdays-only flagships.
@@ -221,4 +223,4 @@ Queue edits reach production with the next deploy, because the cron reads the qu
## Tests
-[tests/x-content.test.js](../tests/x-content.test.js) covers the tiered slots, fill-down, priority scoring, holds and the fall-through that publishes the next post when one fails, stock counting, quote-tweet ids and their publish wiring, the video speed-up filter chain and its caption ordering, the voice and editorial lint, the claims ledger, media quality, review records binding approval to exact content, the editor verdict rules, the media rules, the Markdown to Article offsets, the scheduler's spacing, cap, embargo, and resume rules, and the publisher's thread chaining, crash resume, and Article draft, publish, and quote sequence.
+[tests/x-content.test.js](../tests/x-content.test.js) covers the tiered slots, fill-down, priority scoring, holds and the fall-through that publishes the next post when one fails, stock counting, quote-tweet ids and their publish wiring, hand-sent posts counting toward spacing but not the cap, the video speed-up filter chain and its caption ordering, the voice and editorial lint, the claims ledger, media quality, review records binding approval to exact content, the editor verdict rules, the media rules, the Markdown to Article offsets, the scheduler's spacing, cap, embargo, and resume rules, and the publisher's thread chaining, crash resume, and Article draft, publish, and quote sequence.
diff --git a/tests/x-content.test.js b/tests/x-content.test.js
index 8b0e338ea..a86da373b 100644
--- a/tests/x-content.test.js
+++ b/tests/x-content.test.js
@@ -183,6 +183,23 @@ describe('schedule', () => {
expect(pickDue({ items: [item('a', { tier: 1 })], state: capped, now: primeTime, cadence }).reason).toMatch(/daily cap/);
});
+ it('lets hand-sent posts count toward spacing but not toward the daily cap', () => {
+ // Four owner-requested posts in one afternoon (no slot) used to fill the
+ // rolling window and hold every scheduled slot shut the next morning.
+ const manual = [8, 9, 10, 11].map((h, i) => ({ id: `m${i}`, publishedAt: new Date(primeTime - h * HOUR).toISOString() }));
+ const pick = pickDue({ items: [item('a', { tier: 1 })], state: { published: manual }, now: primeTime, cadence });
+ expect(pick.reason ?? '').not.toMatch(/daily cap/);
+ expect(pick.item?.id).toBe('a');
+
+ // The same posts sent minutes ago still block the slot on spacing.
+ const justNow = [{ id: 'm', publishedAt: new Date(primeTime - 10 * 60_000).toISOString() }];
+ expect(pickDue({ items: [item('a', { tier: 1 })], state: { published: justNow }, now: primeTime, cadence }).reason).toMatch(/spacing/);
+
+ // Scheduled posts still fill the cap exactly as before.
+ const scheduled = [5, 11, 17].map((h, i) => ({ id: `s${i}`, slot: `k${i}`, publishedAt: new Date(primeTime - h * HOUR).toISOString() }));
+ expect(pickDue({ items: [item('a', { tier: 1 })], state: { published: [...manual, ...scheduled] }, now: primeTime, cadence }).reason).toMatch(/daily cap/);
+ });
+
it('ranks within a tier and falls to the next post when one is held', () => {
const items = [item('low', { tier: 1, priority: -10 }), item('high', { tier: 1, priority: 30 }), item('mid', { tier: 1 })];
const first = pickDue({ items, state: {}, now: primeTime, cadence });