Skip to content

F19: bound Graphile resident admission and heap headroom - #1853

Open
Zetazzz wants to merge 4 commits into
graphile-build-identity-c8f5bfd9from
graphile-resident-admission-c8f5bfd9
Open

Zetazzz wants to merge 4 commits into
graphile-build-identity-c8f5bfd9from
graphile-resident-admission-c8f5bfd9

Conversation

@Zetazzz

@Zetazzz Zetazzz commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Implements F19 from constructive-io/constructive-planning#1693, stacked on #1852 (F17) and #1747 (F04).

Cache misses reserve resident count and process-heap headroom before allocating preset services. The existing LRU remains the resident owner. Admission counts reservations, residents, and disposal in progress, awaits evicted resources, and disposes oversized completed builds before publication. Failed cleanup latches admission unavailable until process restart: acknowledging a failure does not prove resources were released.

graphql-env owns parsing, defaults, and final validation for graphile.cache max, TTL, heap watermark, and build reserve. File < environment < runtime precedence is preserved, including runtime values above environment defaults. Explicit malformed values fail. Defaults are 50 residents, a five-minute development TTL or 366-day production TTL, an 85% V8 heap watermark, and 64 MiB per pending build.

The first owner can replace fallback limits; subsequent owners share the strictest limits. The same LRU now enforces the configured resident ceiling dynamically, including values above 50. Expired entries are reclaimed before admission. Capacity cannot be lowered below current ownership, and TTL cannot change while residents exist. This is process-heap admission, not exact per-instance measurement or an RSS guarantee. Upstream background subscriber cleanup remains outside F04's public release boundary.

Validation: 65 cache/admission/release tests verified at this layer; 90 environment tests and snapshot; canonical 503 normalization tests. Errors, graphql-types/env, graphile-cache, server and Explorer builds passed. Frozen-lockfile installation, dependency policy, and test registration checks passed. Final stack validation is recorded in #1855.

Next layers: #1854 (F20), then #1855 (F21).

@tenki-reviewer

tenki-reviewer Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Review complete. 🟠 1 high

💬 Inline comments (1)

  • 🟠 Disposal failure permanently bricks all schema admission — admission.ts:71

This PR introduces a memory-aware admission and eviction controller for the plan cache: admission.ts gates schema builds against a heap budget, admitted-build.ts tracks per-owner reservations and released entries, and graphile-cache.ts/create-instance.ts route build and disposal through it. The GraphQL server wires the new build flow into the request-lifecycle middleware and explorer server with single-flight deduplication, while graphql/env gains parsing/validation/merge helpers used to feed cache and config options. A single high-severity finding remains in the admission controller's failure latch.

Files Change
graphile/graphile-cache/src/admission.ts, admitted-build.ts, graphile-cache.ts, create-instance.ts Add heap-budget admission, per-owner reservations, and eviction/disposal semantics for the plan cache.
graphql/server/src/middleware/graphile.ts, graphql/explorer/src/server.ts Route instance building through the new admission flow with single-flight deduplication.
graphql/env/src/env.ts, merge.ts, validation.ts Add env parsing, cross-field validation, and merge-priority helpers for cache/config options.
graphql/types, packages/errors Wire new cache/config types and schema-capacity error registry entries.

Reviewed commit: c83256e

@tenki-reviewer tenki-reviewer Bot left a comment •

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adds a process-heap admission/eviction controller for the schema plan cache, wires it through the GraphQL server instance build path, and adds env/config validation helpers in the graphql/env package.

Key findings

  • 🟠 Disposal failure permanently bricks all schema admission — admission.ts:71

Comment thread graphile/graphile-cache/src/admission.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant