feat: grow new accounts by commenting on active threads
A new Reddit account cannot start chats until Reddit considers it established, and nothing in the app previously did anything about that. Account growth posts a small number of AI-written comments per day on active threads in an operator-chosen list of communities, per account, so the history that lifts the hold actually accumulates. Growth is account-scoped rather than part of the shared outreach funnel: karma, comment history and pacing all belong to one identity. It runs as the lowest-priority work in the account runtime, after inbound replies, and deliberately keeps running while an account is held out of outbound messaging. Comments publish without operator review, so the guards are the feature: - Both screening stages fail closed. A deterministic gate rejects links, contact solicitation, user tags, filler and any text that reveals the generator; the classifier must actively approve with confidence, and an outage stalls growth rather than publishing unreviewed text. - Thread text reaches the model only as fenced untrusted data, since Reddit posts do contain instructions aimed at automated readers. - The daily allowance is adaptive, not configured: it starts at two per day and rises only while comments survive and earn upvotes. - Posted comments are swept at ~15m/2h/24h with one batched info.json request, plus a single signed-out probe that detects a comment the public cannot see. Two consecutive removals, an invisible comment, or a captcha challenge pauses the account until an operator clears it. A failed probe never pauses anything. - One comment per thread across every owned account, enforced by a unique index, because two of our accounts on one post is the easiest pattern to correlate. - A comment interrupted mid-post is abandoned, never retried: we cannot know whether the write landed and a duplicate cannot be withdrawn. - Reddit's refusals are authoritative — a ban disables that community for that account, a throttle backs off at the scope Reddit named, and a signed-out response invalidates the session. Comments are submitted through the account's own browser session against the old.reddit form endpoint, which returns machine-readable error codes and needs no credentials beyond the cookies already imported. API-first: /api/growth exposes state, settings, the community list and pause/resume, all verified against a local instance. Route responses are parsed with the shared contracts in tests so the server-side mirror cannot drift from what the dashboard expects. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
14d92e14ee
commit
1ac6ad22ad
46 files changed
+7500
-5
No files matched your search
@@ -40,7 +40,10 @@ describe('materializePreparedPostForAccount', () => {
|
||||
});
|
||||
|
||||
describe('AccountRuntimeLoop mode gating', () => {
|
||||
function loopHarness(getBotMode: () => 'running' | 'scan' | 'stopped') {
|
||||
function loopHarness(
|
||||
getBotMode: () => 'running' | 'scan' | 'stopped',
|
||||
growthService?: { tick: ReturnType<typeof vi.fn>; recoverAfterRestart: ReturnType<typeof vi.fn> },
|
||||
) {
|
||||
const conversationAutomation = { processPendingConversations: vi.fn().mockResolvedValue([]) };
|
||||
const responseChecker = { checkForResponses: vi.fn().mockResolvedValue([]) };
|
||||
const mediaSyncService = { start: vi.fn(), stop: vi.fn() };
|
||||
@@ -61,13 +64,14 @@ describe('AccountRuntimeLoop mode gating', () => {
|
||||
recipientAccountStatusService: { start: vi.fn(), stop: vi.fn() },
|
||||
establishmentService: { start: vi.fn(), stop: vi.fn() },
|
||||
browserClient: { close: vi.fn().mockResolvedValue(undefined) },
|
||||
...(growthService ? { growthService } : {}),
|
||||
};
|
||||
const config = { reddit: { pollIntervalMs: 1_000 } };
|
||||
const logger = { info: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn() };
|
||||
const loop = new AccountRuntimeLoop(
|
||||
resources as never, config as never, logger as never, getBotMode, { } as never,
|
||||
);
|
||||
return { loop, conversationAutomation, responseChecker, mediaSyncService, chatService };
|
||||
return { loop, conversationAutomation, responseChecker, mediaSyncService, chatService, growthService };
|
||||
}
|
||||
|
||||
/** Lets the loop complete at least one full pass before we assert. */
|
||||
@@ -125,4 +129,79 @@ describe('AccountRuntimeLoop mode gating', () => {
|
||||
// Only ever started once — the reconcile must not re-enter on every tick.
|
||||
expect(fixture.mediaSyncService.start).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
describe('account growth', () => {
|
||||
function growthStub(tick = vi.fn().mockResolvedValue({ kind: 'idle', reason: 'test' })) {
|
||||
return { tick, recoverAfterRestart: vi.fn().mockReturnValue(0) };
|
||||
}
|
||||
|
||||
it('retires interrupted comments before starting any growth work', async () => {
|
||||
const growth = growthStub();
|
||||
const fixture = loopHarness(() => 'running', growth);
|
||||
|
||||
await runBriefly(fixture.loop);
|
||||
|
||||
expect(growth.recoverAfterRestart).toHaveBeenCalledTimes(1);
|
||||
const recoverOrder = growth.recoverAfterRestart.mock.invocationCallOrder[0];
|
||||
const tickOrder = growth.tick.mock.invocationCallOrder[0];
|
||||
expect(recoverOrder).toBeLessThan(tickOrder);
|
||||
});
|
||||
|
||||
it('lets growth post in running mode', async () => {
|
||||
const growth = growthStub();
|
||||
const fixture = loopHarness(() => 'running', growth);
|
||||
|
||||
await runBriefly(fixture.loop);
|
||||
|
||||
expect(growth.tick).toHaveBeenCalledWith({ allowPosting: true }, expect.anything());
|
||||
});
|
||||
|
||||
it('verifies but never posts in scan mode', async () => {
|
||||
const growth = growthStub();
|
||||
const fixture = loopHarness(() => 'scan', growth);
|
||||
|
||||
await runBriefly(fixture.loop);
|
||||
|
||||
expect(growth.tick).toHaveBeenCalledWith({ allowPosting: false }, expect.anything());
|
||||
});
|
||||
|
||||
it('does not run growth at all when stopped', async () => {
|
||||
const growth = growthStub();
|
||||
const fixture = loopHarness(() => 'stopped', growth);
|
||||
|
||||
await runBriefly(fixture.loop);
|
||||
|
||||
expect(growth.tick).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('runs growth only after replies have been handled in the same pass', async () => {
|
||||
const growth = growthStub();
|
||||
const fixture = loopHarness(() => 'running', growth);
|
||||
|
||||
await runBriefly(fixture.loop);
|
||||
|
||||
// Growth is the lowest-priority work: inbound replies come first.
|
||||
const replyOrder = fixture.conversationAutomation.processPendingConversations
|
||||
.mock.invocationCallOrder[0];
|
||||
expect(replyOrder).toBeLessThan(growth.tick.mock.invocationCallOrder[0]);
|
||||
});
|
||||
|
||||
it('keeps reply handling alive when a growth tick throws', async () => {
|
||||
const growth = growthStub(vi.fn().mockRejectedValue(new Error('growth exploded')));
|
||||
const fixture = loopHarness(() => 'running', growth);
|
||||
|
||||
fixture.loop.start();
|
||||
await new Promise((resolve) => setTimeout(resolve, 60));
|
||||
await fixture.loop.stop();
|
||||
|
||||
expect(growth.tick).toHaveBeenCalled();
|
||||
expect(fixture.responseChecker.checkForResponses).toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('works with no growth service configured', async () => {
|
||||
const fixture = loopHarness(() => 'running');
|
||||
|
||||
await expect(runBriefly(fixture.loop)).resolves.toBeUndefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user