Skip to content

Commit c7836c7

Browse files
committed
docs(rest): the batch cap is embedder policy, not deployment policy
`enforceBatchSize`'s docblock called `RestServerConfig.batch.maxBatchSize` "deployment policy". That is false of every shipped boot path: a `RestServerConfig` is the argument a host passes at construction, there is exactly one door (`createRestApiPlugin({ api })`, whose `start()` is the only non-test site reaching `new RestServer(...)`), and neither shipped boot path opens it with a `batch` config — `os serve` forwards two `api.*` keys and the dev plugin passes none. A CLI-started deployment always gets the 200 default and cannot move it. Narrow the prose onto that fact using the vocabulary already landed on the spec side: `Reachability: EMBEDDER-ONLY`, matching the `BatchEndpointsConfigSchema` docblock, the WHO CAN WRITE THIS CONFIG header in `packages/spec/src/api/rest-server.zod.ts` and the per-key REACHABILITY row in `packages/spec/liveness/batch_endpoints.json`. Two wordings for one fact in two packages is how this defect survived the spec-side fix. No behaviour change: the 1..1000 range and the 200 default are correct and still enforced. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015QE8qk46e5CHJxyQEUjbf8
1 parent 70f7d6d commit c7836c7

1 file changed

Lines changed: 29 additions & 5 deletions

File tree

packages/rest/src/rest-server.ts

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2061,7 +2061,7 @@ export class RestServer {
20612061
}
20622062

20632063
/**
2064-
* [#3939] Enforce the deployment's batch-size cap on a bulk write route.
2064+
* [#3939] Enforce the configured batch-size cap on a bulk write route.
20652065
* Returns `true` when a response was sent (the caller must return).
20662066
*
20672067
* The cap was declared in three places in `batch.zod.ts` (`.max(200)` on
@@ -2076,10 +2076,34 @@ export class RestServer {
20762076
* own result), which turns a 10k-id body into 10k sequential engine
20772077
* round-trips inside one request instead of one statement.
20782078
*
2079-
* The cap is deployment policy — `RestServerConfig.batch.maxBatchSize`
2080-
* (1..1000, default 200) — so it lives here and the schemas carry shape
2081-
* only. One place decides it, and it is the place that knows the
2082-
* deployment's configured value.
2079+
* The cap is `RestServerConfig.batch.maxBatchSize` (1..1000, default 200),
2080+
* so it lives here and the schemas carry shape only: one place decides it,
2081+
* and it is the place that holds the constructed config.
2082+
*
2083+
* Reachability: EMBEDDER-ONLY (#15543, #16801). ⛔ It is NOT deployment
2084+
* policy — this docblock said exactly that until #16801, and no shipped
2085+
* boot path makes it true. A `RestServerConfig` is the ARGUMENT a host
2086+
* passes when it constructs the server, and there is exactly ONE door:
2087+
* `createRestApiPlugin({ api })` (`packages/rest/src/rest-api-plugin.ts`),
2088+
* whose `start()` is the only non-test site that reaches
2089+
* `new RestServer(...)`. Neither shipped boot path opens it with a `batch`
2090+
* config — `os serve` (`packages/cli/src/commands/serve.ts`) forwards
2091+
* exactly two keys out of the stack config's `api:` block
2092+
* (`api.enableProjectScoping`, `api.projectResolution`), and the dev plugin
2093+
* (`packages/plugins/plugin-dev/src/dev-plugin.ts`) calls
2094+
* `createRestApiPlugin()` with no config at all. ⇒ A CLI-started
2095+
* deployment always gets the schema default of 200, and no flag, config
2096+
* file or CLI option moves it.
2097+
*
2098+
* This is the recorded posture, not a gap awaiting a fix, and it is written
2099+
* the same way on the spec side — the `BatchEndpointsConfigSchema` docblock
2100+
* and the WHO CAN WRITE THIS CONFIG header in
2101+
* `packages/spec/src/api/rest-server.zod.ts`, plus the per-key REACHABILITY
2102+
* row in `packages/spec/liveness/batch_endpoints.json`. Keep the two
2103+
* wordings together: threading a `batch` config through a boot path would
2104+
* be a NEW authorable key, which the spec-side siblings were denied for
2105+
* want of measured demand, so reversing that is its own decision and
2106+
* ⛔ not a docblock's to take.
20832107
*/
20842108
private enforceBatchSize(res: any, count: number, max: number, object?: string): boolean {
20852109
if (count <= max) return false;

0 commit comments

Comments
 (0)