diff --git a/AGENTS.md b/AGENTS.md index 592a60f76..40229518f 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -661,14 +661,13 @@ drives may call it: that person is the creator, and their own live browser login is rechecked for write access as for `chat:send`; a turn nobody typed and background jobs are refused. It reuses MCP `create_document`'s draft validation, visual assessment and creation (`createDocument` in `apps/server/src/mcp/hosted.ts`), -keeps the creating document's repository and base branch, and is bounded per turn -(counted on the turn's own member request, for as long as it runs) and per person -per hour, with an idempotency key scoped to the creating document. The creating +keeps the creating document's repository and base branch, with an idempotency +key scoped to the creating document and no per-turn or hourly cap. The creating document's model choice is stored in the transaction that creates the new one (`CreateChannel.modelChoice`), so a retry never overwrites a choice made since. -A retry is found in storage before the limits are counted, is compared against -the base the first call recorded, and posts the linked line only if the first call -could not save it. The document is stored before the sidebar, the asking Chat's +A retry is found in storage, is compared against the base the first call +recorded, and posts the linked line only if the first call could not save it. +The document is stored before the sidebar, the asking Chat's one linked line (`Entry.document`) or its optional first instruction (posted as the creator's message, as `invoke_planner` does) hear of it. See [Creating documents](docs/hosted-agent.md#creating-documents). diff --git a/apps/server/src/agent/new-documents.test.ts b/apps/server/src/agent/new-documents.test.ts index 6d1ed0cdb..6b3f83d26 100644 --- a/apps/server/src/agent/new-documents.test.ts +++ b/apps/server/src/agent/new-documents.test.ts @@ -3,25 +3,14 @@ import { describe, expect, test } from "bun:test"; import { MemoryStorage } from "../storage/memory/adapter"; import { createDocument } from "../mcp/hosted"; import * as Plan from "../plan/service"; -import { - createNewDocument, - MAX_DOCUMENTS_PER_HOUR, - MAX_DOCUMENTS_PER_TURN, - newDocumentArguments, - NewDocumentLimits, -} from "./new-documents"; +import { createNewDocument, newDocumentArguments } from "./new-documents"; import { testLease } from "../storage/contract-support"; import type { AuthenticatedSession } from "../auth/session"; import type { Repository } from "../github/client"; import type { PlannerInvocation } from "../mcp/hosted"; import type { InvokePlannerError } from "../mcp"; -import type { - NewDocumentArguments, - NewDocumentDeps, - NewDocumentReservation, - TurnDocuments, -} from "./new-documents"; +import type { NewDocumentArguments, NewDocumentDeps } from "./new-documents"; import type { CreationOrigin } from "../mcp/create"; const NOW = new Date("2026-11-16T12:00:00.000Z"); @@ -156,13 +145,10 @@ async function fixture(options: { }, refusal: async code => code === "planner-not-attached" ? "No machine runs it." : undefined, appOrigin: "https://chopin.test", - limits: new NewDocumentLimits(() => clock.now), }; - let turns = new Map(); - let request = (value: NewDocumentArguments = args(), turnId = "turn-1") => + let request = (value: NewDocumentArguments = args()) => createNewDocument(deps, { sourceId: source.id, - turn: turns.get(turnId) ?? turns.set(turnId, { created: 0 }).get(turnId)!, creator: { userId: "U_mona", handle: "mona", claimantSessionId: "session-U_mona" }, arguments: value, announce: async document => { @@ -206,58 +192,6 @@ describe("create_document arguments", () => { }); }); -describe("new document limits", () => { - test("bound one turn and one person's hour, and give back refunds", () => { - let now = 0; - let limits = new NewDocumentLimits(() => now); - let turnA = { created: 0 }; - let taken: NewDocumentReservation[] = []; - for (let index = 0; index < MAX_DOCUMENTS_PER_TURN; index++) { - let reservation = limits.take(turnA, "U_mona"); - if (typeof reservation === "string") throw new Error(`unexpected ${reservation} limit`); - taken.push(reservation); - } - expect(limits.take(turnA, "U_mona")).toBe("turn"); - limits.refund(taken[0]!); - expect(typeof limits.take(turnA, "U_mona")).toBe("object"); - let turn = 0; - while (typeof limits.take({ created: 0 }, "U_mona") === "object" && ++turn < 100) {} - let next = { created: 0 }; - expect(limits.take(next, "U_mona")).toBe("hour"); - expect(typeof limits.take(next, "U_other")).toBe("object"); - now += 60 * 60_000; - expect(typeof limits.take(next, "U_mona")).toBe("object"); - expect(MAX_DOCUMENTS_PER_HOUR).toBeGreaterThan(MAX_DOCUMENTS_PER_TURN); - }); - - test("hold a turn's count for as long as the turn runs, however long that is", () => { - let now = 0; - let limits = new NewDocumentLimits(() => now); - let turn = { created: 0 }; - for (let index = 0; index < MAX_DOCUMENTS_PER_TURN; index++) { - expect(typeof limits.take(turn, "U_mona")).toBe("object"); - } - now += 3 * 60 * 60_000; - expect(limits.take(turn, "U_mona")).toBe("turn"); - expect(typeof limits.take({ created: 0 }, "U_mona")).toBe("object"); - }); - - test("refund removes only the failed reservation, not a newer one", () => { - let now = 0; - let limits = new NewDocumentLimits(() => now); - let first = limits.take({ created: 0 }, "U_mona"); - if (typeof first === "string") throw new Error(`unexpected ${first} limit`); - now = 55 * 60_000; - expect(typeof limits.take({ created: 0 }, "U_mona")).toBe("object"); - limits.refund(first); - now = 60 * 60_000 + 1_000; - for (let index = 1; index < MAX_DOCUMENTS_PER_HOUR; index++) { - expect(typeof limits.take({ created: 0 }, "U_mona")).toBe("object"); - } - expect(limits.take({ created: 0 }, "U_mona")).toBe("hour"); - }); -}); - describe("createNewDocument", () => { test("stores a top-level document on the base branch before the Chat line and its Planner", async () => { let context = await fixture(); @@ -317,7 +251,7 @@ describe("createNewDocument", () => { test("a retry with the same key creates and starts nothing again", async () => { let context = await fixture(); let first = await context.request(args({ instruction: "Start." })); - let second = await context.request(args({ instruction: "Start." }), "turn-2"); + let second = await context.request(args({ instruction: "Start." })); if (!first.ok || !second.ok) throw new Error("expected both calls to succeed"); expect(second.document).toEqual(first.document); expect(second.replayed).toBe(true); @@ -336,99 +270,6 @@ describe("createNewDocument", () => { expect(context.created).toHaveLength(1); }); - test("a retry is answered with its document after the turn's limit is spent", async () => { - let context = await fixture(); - let pieces = Array.from({ length: MAX_DOCUMENTS_PER_TURN }, (_, index) => - args({ - idempotencyKey: `piece-number-${index}`, - title: `Piece ${index}`, - document: `# Piece ${index}\n`, - })); - let first = await context.request(pieces[0]); - for (let piece of pieces.slice(1)) expect((await context.request(piece)).ok).toBe(true); - let retried = await context.request(pieces[0]); - if (!first.ok) throw new Error(first.message); - expect(retried).toMatchObject({ ok: true, replayed: true, document: first.document }); - expect(context.created).toHaveLength(MAX_DOCUMENTS_PER_TURN); - }); - - test("a retry is answered with its document after the person's hour is spent", async () => { - let context = await fixture(); - let first = await context.request(args(), "turn-0"); - for (let index = 1; index < MAX_DOCUMENTS_PER_HOUR; index++) { - let result = await context.request( - args({ - idempotencyKey: `piece-number-${index}`, - title: `Piece ${index}`, - document: `# Piece ${index}\n`, - }), - `turn-${index}`, - ); - expect(result.ok).toBe(true); - } - let over = await context.request( - args({ idempotencyKey: "piece-number-over", title: "Over", document: "# Over\n" }), - "turn-over", - ); - expect(over).toMatchObject({ ok: false, reason: "hour-limit" }); - let retried = await context.request(args(), "turn-over"); - if (!first.ok) throw new Error(first.message); - expect(retried).toMatchObject({ ok: true, replayed: true, document: first.document }); - }); - - test("a failed request refunds its own hourly reservation, not a newer one", async () => { - let context = await fixture(); - let create = context.deps.create; - let finishFirst!: () => void; - let firstWaiting = new Promise(resolve => { - finishFirst = resolve; - }); - let firstEntered!: () => void; - let entered = new Promise(resolve => { - firstEntered = resolve; - }); - let calls = 0; - context.deps.create = async (creator, input, instructed) => { - if (++calls === 1) { - firstEntered(); - await firstWaiting; - return { kind: "unavailable" }; - } - return create(creator, input, instructed); - }; - let first = context.request( - args({ idempotencyKey: "piece-slow-fail", title: "Slow", document: "# Slow\n" }), - "turn-slow", - ); - await entered; - context.clock.now += 55 * 60_000; - let second = await context.request( - args({ idempotencyKey: "piece-at-55m", title: "At 55m", document: "# At 55m\n" }), - "turn-55m", - ); - expect(second.ok).toBe(true); - finishFirst(); - expect(await first).toMatchObject({ ok: false, reason: "unavailable" }); - context.clock.now = NOW.getTime() + 60 * 60_000 + 1_000; - for (let index = 1; index < MAX_DOCUMENTS_PER_HOUR; index++) { - let result = await context.request( - args({ - idempotencyKey: `piece-after-hour-${index}`, - title: `After ${index}`, - document: `# After ${index}\n`, - }), - `turn-after-${index}`, - ); - expect(result.ok).toBe(true); - } - let over = await context.request( - args({ idempotencyKey: "piece-number-over", title: "Over", document: "# Over\n" }), - "turn-over", - ); - expect(over).toMatchObject({ ok: false, reason: "hour-limit" }); - expect(context.created).toHaveLength(MAX_DOCUMENTS_PER_HOUR); - }); - test("a Chat line that could not be saved is posted by the retry, once", async () => { let context = await fixture({ unsavedLines: 1 }); let first = await context.request(args({ instruction: "Start." })); @@ -540,9 +381,10 @@ describe("createNewDocument", () => { expect(context.created).toEqual([]); }); - test("one turn creates at most its limit", async () => { + test("one turn creates many documents without a per-turn or hourly cap", async () => { let context = await fixture(); - for (let index = 0; index < MAX_DOCUMENTS_PER_TURN; index++) { + let count = 35; + for (let index = 0; index < count; index++) { let result = await context.request(args({ idempotencyKey: `piece-number-${index}`, title: `Piece ${index}`, @@ -550,13 +392,7 @@ describe("createNewDocument", () => { })); expect(result.ok).toBe(true); } - let over = await context.request(args({ - idempotencyKey: "piece-number-over", - title: "Piece over", - document: "# Piece over\n", - })); - expect(over).toMatchObject({ ok: false, reason: "turn-limit" }); - expect(context.created).toHaveLength(MAX_DOCUMENTS_PER_TURN); + expect(context.created).toHaveLength(count); }); test("says when the new document's Planner could not start", async () => { diff --git a/apps/server/src/agent/new-documents.ts b/apps/server/src/agent/new-documents.ts index 591a54d4e..219d4ad13 100644 --- a/apps/server/src/agent/new-documents.ts +++ b/apps/server/src/agent/new-documents.ts @@ -5,10 +5,9 @@ * The person whose message drives the turn is the creator. Their own browser login is asked * again for write access to the repository, as `chat:send` is; the Planner's credential never * authorizes a new document by itself. A retried call with the same key returns the document the - * first call made, from the base that call recorded and outside the limits, and creates and starts - * nothing; it only posts the Chat line if the first call could not save it. A document is stored, - * with the creating document's model choice, before its Chat line, the sidebar or its own Planner - * hear of it. + * first call made, from the base that call recorded, and creates and starts nothing; it only posts + * the Chat line if the first call could not save it. A document is stored, with the creating + * document's model choice, before its Chat line, the sidebar or its own Planner hear of it. */ import { deterministicChannelId } from "../channels/id"; import { BRIEF, prepare } from "../mcp/create"; @@ -23,10 +22,7 @@ import type { Repository as GitHubRepository } from "../github/client"; import type { ChannelRecord, CreateChannel } from "../storage/model"; import type { Issue } from "@chopin/dialect"; -export const MAX_DOCUMENTS_PER_TURN = 10; -export const MAX_DOCUMENTS_PER_HOUR = 30; export const MAX_INSTRUCTION_BYTES = 64 * 1_024; -const HOUR_MS = 60 * 60_000; const KEY = /^[A-Za-z0-9_-]{8,64}$/; export type NewDocumentArguments = { @@ -97,64 +93,9 @@ export function newDocumentArguments(raw: unknown): NewDocumentArguments { }; } -/** The documents one turn has created; it lives exactly as long as the turn that holds it. */ -export type TurnDocuments = { created: number }; - -/** One reservation against a turn's and a person's hourly document limits. */ -export type NewDocumentReservation = { - id: number; - turn: TurnDocuments; - userId: string; - at: number; -}; - -/** How many documents one turn, and one person in an hour, may create. */ -export class NewDocumentLimits { - #hours = new Map(); - #refunded = new WeakSet(); - #now: () => number; - #nextId = 1; - - constructor(now: () => number = Date.now) { - this.#now = now; - } - - /** Counts one for the turn and the person, or says which limit is spent. */ - take(turn: TurnDocuments, userId: string): NewDocumentReservation | "turn" | "hour" { - let now = this.#now(); - let recent = (this.#hours.get(userId) ?? []).filter(entry => now - entry.at < HOUR_MS); - this.#hours.set(userId, recent); - if (turn.created >= MAX_DOCUMENTS_PER_TURN) return "turn"; - if (recent.length >= MAX_DOCUMENTS_PER_HOUR) return "hour"; - let reservation: NewDocumentReservation = { - id: this.#nextId++, - turn, - userId, - at: now, - }; - recent.push(reservation); - turn.created++; - return reservation; - } - - /** Gives back the reservation a call took, for a call that created nothing. */ - refund(reservation: NewDocumentReservation): void { - if (this.#refunded.has(reservation)) return; - this.#refunded.add(reservation); - reservation.turn.created = Math.max(0, reservation.turn.created - 1); - let recent = this.#hours.get(reservation.userId); - if (!recent) return; - let next = recent.filter(entry => entry.id !== reservation.id); - if (next.length === 0) this.#hours.delete(reservation.userId); - else this.#hours.set(reservation.userId, next); - } -} - export type NewDocumentRequest = { /** The document whose turn asked. */ sourceId: string; - /** The asking turn's own count, held by that turn and gone with it. */ - turn: TurnDocuments; creator: { userId: string; handle: string; claimantSessionId?: string }; arguments: NewDocumentArguments; /** @@ -205,7 +146,6 @@ export type NewDocumentDeps = { ) => Promise; /** This deployment's origin, for the URL the model is given. */ appOrigin: string; - limits: NewDocumentLimits; }; export type NewDocumentResult = @@ -228,8 +168,6 @@ const REFUSALS: Record = { + "was created.", "document-unavailable": "This document is archived, deleted or closing, so it can't create " + "others.", - "turn-limit": `One turn may create at most ${MAX_DOCUMENTS_PER_TURN} documents.`, - "hour-limit": `A person's turns may create at most ${MAX_DOCUMENTS_PER_HOUR} documents an hour.`, "idempotency-conflict": "Another document was already created with this idempotencyKey and " + "different content. Use a new key for a different document.", "title-taken": "The repository already has a document with this title. Choose another title.", @@ -258,7 +196,7 @@ export async function createNewDocument( deps: NewDocumentDeps, request: NewDocumentRequest, ): Promise { - let { creator, sourceId, turn } = request; + let { creator, sourceId } = request; let args = request.arguments; let source = await deps.channel(sourceId); if (!source || source.archivedAt || deps.deleting(sourceId) || source.parentChannelId) { @@ -298,34 +236,21 @@ export async function createNewDocument( }]); } if ("issues" in prepared) return refused("invalid-document", prepared.issues); - let reservation: NewDocumentReservation | undefined; - if (!earlier) { - let taken = deps.limits.take(turn, creator.userId); - if (typeof taken === "string") return refused(`${taken}-limit`); - reservation = taken; - } - let outcome: CreatedDocument; - try { - outcome = await deps.create( - { - user: login.user, - repository, - stillWrites: async () => { - let current = await deps.login(creator.userId, creator.claimantSessionId); - return !!current - && writes(await deps.repository(current, owner, name), source.repositoryId); - }, - modelChoice: () => deps.modelChoice(sourceId, creator.userId), - ...(request.signal ? { signal: request.signal } : {}), + let outcome = await deps.create( + { + user: login.user, + repository, + stillWrites: async () => { + let current = await deps.login(creator.userId, creator.claimantSessionId); + return !!current + && writes(await deps.repository(current, owner, name), source.repositoryId); }, - prepared.input, - args.instruction !== undefined, - ); - } catch (err) { - if (reservation) deps.limits.refund(reservation); - throw err; - } - if (reservation && outcome.kind !== "created") deps.limits.refund(reservation); + modelChoice: () => deps.modelChoice(sourceId, creator.userId), + ...(request.signal ? { signal: request.signal } : {}), + }, + prepared.input, + args.instruction !== undefined, + ); if (outcome.kind === "conflict") return refused("idempotency-conflict"); if (outcome.kind === "title-taken") return refused("title-taken"); if (outcome.kind === "forbidden") return refused("repository-forbidden"); diff --git a/apps/server/src/agent/tools.ts b/apps/server/src/agent/tools.ts index 71fa363ee..c1ca3bdda 100644 --- a/apps/server/src/agent/tools.ts +++ b/apps/server/src/agent/tools.ts @@ -347,7 +347,7 @@ export const documentTools = { + "large to review, unless the person asked for a single document. Give each a " + "complete first draft and brief; `instruction`, when given, starts its own Planner on " + "it as the person's message, so the documents run in parallel. Only a turn a person " - + "asked for can create documents, at most 10 a turn. The result gives each document's " + + "asked for can create documents. The result gives each document's " + "id and url; mention its link when you tell the person.", inputSchema: jsonSchema(NEW_DOCUMENT_SCHEMA), execute: (raw, { context: { room: context }, abortSignal }) => diff --git a/apps/server/src/chat/new-documents.test.ts b/apps/server/src/chat/new-documents.test.ts index e17b42a74..4ba4f5bd9 100644 --- a/apps/server/src/chat/new-documents.test.ts +++ b/apps/server/src/chat/new-documents.test.ts @@ -97,7 +97,6 @@ describe("a Planner turn creating a document", () => { let result = await documentRoom(context).createDocument!(draft); expect(result).toMatchObject({ ok: true }); expect(requests).toMatchObject([{ - turn: { created: 0 }, creator: { userId: "U_ana", handle: "ana", claimantSessionId: "session-ana" }, arguments: draft, }]); @@ -115,18 +114,6 @@ describe("a Planner turn creating a document", () => { expect(frames.at(-1)).toMatchObject({ kind: "chat:message", entry: { id: line.id } }); }); - it("counts every call of one turn together, and a new turn afresh", async () => { - let { chat, context, requests } = room(); - let tools = documentRoom(context); - await tools.createDocument!(draft); - await tools.createDocument!(draft); - expect(requests[1]!.turn).toBe(requests[0]!.turn); - chat.activeRequest = { ...chat.activeRequest!, turnId: "turn-2", documents: undefined }; - chat.turn = { ...chat.turn!, id: "turn-2" }; - await tools.createDocument!(draft); - expect(requests[2]!.turn).not.toBe(requests[0]!.turn); - }); - it("is refused in a turn nobody typed", async () => { let { context, requests } = room({ member: false }); expect(await documentRoom(context).createDocument!(draft)).toMatchObject({ diff --git a/apps/server/src/chat/service.ts b/apps/server/src/chat/service.ts index 0a918fd95..327d83047 100644 --- a/apps/server/src/chat/service.ts +++ b/apps/server/src/chat/service.ts @@ -38,7 +38,7 @@ import { plannerInstructions } from "../agent/planner"; import type { AiAccountRefusal } from "../ai/account-check"; import type { ActiveOwnerBinding } from "../agent/active-owner"; import type { DocumentRoom, ResearchWorkspaceRequest } from "../agent/tools"; -import type { NewDocumentRequest, NewDocumentResult, TurnDocuments } from "../agent/new-documents"; +import type { NewDocumentRequest, NewDocumentResult } from "../agent/new-documents"; import type { VisualAdmission } from "../agent/visual-admission"; import type { ChildDocuments } from "./children"; import type { TellChat } from "./thread-notes"; @@ -180,8 +180,6 @@ export type ActiveMemberRequest = { turnId: string; lifecycle: number; focus?: Focus; - /** The documents this turn had the Planner create, counted for as long as the turn runs. */ - documents?: TurnDocuments; }; /** `retry` runs the message's turn again after it failed: the same message, once in context. */ @@ -2494,7 +2492,6 @@ export function documentRoom(context: Room): DocumentRoom { (value): value is AbortSignal => !!value, ); return context.createDocument!({ - turn: active.documents ??= { created: 0 }, creator: { userId: active.userId, handle: active.handle, diff --git a/apps/server/src/harness/remote/planner-dispatch.test.ts b/apps/server/src/harness/remote/planner-dispatch.test.ts index 622b0b134..2182c3cb1 100644 --- a/apps/server/src/harness/remote/planner-dispatch.test.ts +++ b/apps/server/src/harness/remote/planner-dispatch.test.ts @@ -36,11 +36,7 @@ import { } from "./attachments"; import { MachinePlanners } from "./machine-planners"; import { createDocument } from "../../mcp/hosted"; -import { - createNewDocument, - MAX_DOCUMENTS_PER_TURN, - NewDocumentLimits, -} from "../../agent/new-documents"; +import { createNewDocument } from "../../agent/new-documents"; import type { RepositoryPage } from "../../github/client"; import type { RemotePlanner } from "./registry"; @@ -3307,15 +3303,13 @@ describe("a burst of documents a Planner turn makes", () => { modelChoice: async () => undefined, invoke: async () => undefined, appOrigin: "https://chopin.test", - limits: new NewDocumentLimits(() => Date.now()), }; - let turn = { created: 0 }; - // The turn's fan-out: as many documents as one turn may make, all at once. + let burst = 12; + // The turn's fan-out: many documents all at once, with no per-turn cap. let made = await Promise.all( - Array.from({ length: MAX_DOCUMENTS_PER_TURN }, (_, index) => + Array.from({ length: burst }, (_, index) => createNewDocument(deps, { sourceId: source.id, - turn, creator: { userId: "U_member", handle: "member", @@ -3341,7 +3335,7 @@ describe("a burst of documents a Planner turn makes", () => { if (!result.ok) throw new Error(JSON.stringify(result)); return result.document.id; }); - expect(new Set(ids).size).toBe(MAX_DOCUMENTS_PER_TURN); + expect(new Set(ids).size).toBe(burst); // Chopin asks the creator's machine for all of them in one answer. let asked = await desk.poll([]); expect(asked.kind).toBe("planners"); diff --git a/apps/server/src/main.ts b/apps/server/src/main.ts index c9255f2be..ffdd37595 100644 --- a/apps/server/src/main.ts +++ b/apps/server/src/main.ts @@ -120,7 +120,7 @@ import { researchAnswerDefinition, researchEvidenceDefinition } from "./jobs/res import { JobService } from "./jobs/service"; import { DocumentSummaryCoordinator } from "./jobs/summary-coordinator"; import { invokeRouted, SystemTurns } from "./mcp/invoke"; -import { createNewDocument, NewDocumentLimits } from "./agent/new-documents"; +import { createNewDocument } from "./agent/new-documents"; import type { NewDocumentDeps } from "./agent/new-documents"; import { liveClassifier } from "./tasks/live-gate"; import { LiveSyncCoordinator } from "./tasks/live-sync"; @@ -328,8 +328,6 @@ let ownerBindings: ActiveOwnerBindings | undefined; let plannerAttachments: PlannerAttachments | undefined; /** Each document's recent automatic follow-ups through `invoke_planner`, for their hourly limit. */ let systemTurns = new SystemTurns(); -/** How many documents each turn, and each person in an hour, had the Planner create. */ -let newDocumentLimits = new NewDocumentLimits(); /** Browser sockets by login, so a login that ends closes them before another broadcast. */ let sessionSockets = new SessionSockets(sessionId => hostedAuth.sessions.isLive(sessionId)); const openSockets = new OpenSockets(); @@ -2747,7 +2745,6 @@ function plannerDocuments(): NewDocumentDeps { ); }, appOrigin: hostedAuth.config.origin, - limits: newDocumentLimits, }; } diff --git a/docs/hosted-agent.md b/docs/hosted-agent.md index 9133c27d9..df7f9e73a 100644 --- a/docs/hosted-agent.md +++ b/docs/hosted-agent.md @@ -1985,15 +1985,12 @@ holds its rules: writer lease (`CreateChannel.modelChoice`). A choice that can't be stored creates nothing, so a retry creates the document with it; a retry of a document already made never writes a choice, and so keeps any chosen since. -- **Bounds.** At most 10 documents a turn and 30 an hour for one person, counted - in the process. A turn's count is kept with the turn itself (its active member - request) for as long as it runs, a turn waiting on a Decision included, and - goes with it. The idempotency key is scoped to the creating document, so a +- **Idempotency.** There is no per-turn or hourly cap on how many documents a + turn can create. The idempotency key is scoped to the creating document, so a retried call returns the document the first made and creates and starts nothing again; the same key with a different draft is a conflict. A retry is - looked up in storage first: it is compared against the base the first call - recorded, so a default branch that moved since is no conflict, and it is - answered even after the limits are spent, since it counts toward neither. + looked up in storage first and compared against the base the first call + recorded, so a default branch that moved since is no conflict. - **Order.** The document is stored first. Then the sidebar hears of it through `/ws/sidebar`, the Chat or thread whose turn asked gets one system line naming it with a link (`Chat.Entry.document`), saved before it is shown, and, if an diff --git a/docs/nvx-sandbox.md b/docs/nvx-sandbox.md index 0b9662a84..f621ff1fa 100644 --- a/docs/nvx-sandbox.md +++ b/docs/nvx-sandbox.md @@ -502,8 +502,8 @@ pool before anything else runs, and the others start cold. ### Bursts of new documents -People open several documents at once, and a Planner's `create_document` makes up to -10 in one turn, all in one repository, all wanting a Planner at once: +People open several documents at once, and a Planner's `create_document` can open +many in one turn, all in one repository, all wanting a Planner at once: - **A burst refills more than one spare.** A new document that finds no spare ready within 10 seconds of another of its repository's asking starts a burst