Skip to content

F20: coalesce exact Graphile builds and fence stale publication - #1854

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

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

Conversation

@Zetazzz

@Zetazzz Zetazzz commented Sep 21, 2026 •

Copy link
Copy Markdown
Contributor

Implements F20 from constructive-io/constructive-planning#1693. Its logical prerequisites are F04 (#1747) and F17 (#1852); it is stacked on F19 (#1853) so cached producers share one admitted publication owner.

Server and Explorer synchronously register an exact-key build flight and share its promise. Joined callers observe the same failure without a retry cascade. Readiness and capacity checks complete before publication.

Invalidation fences pending work before removing resident entries. Service/database/pool invalidation, direct deletion, and cache clear reject old callers and dispose late results without overwriting a replacement. A preparation scope covers asynchronous compute lookup before the exact key is known. The server reuses the context-owned pool and settings throughout this lifecycle; canonical errors preserve their HTTP status and internal cause.

Closing caches drains underlying work before pool teardown and reports resident cleanup failures. Reopening requires the prior flight registry to be drained. The existing LRU retains F19's dynamic configured capacity and TTL behavior.

Validation: all 83 graphile-cache tests passed, including flight invalidation, late publication, failed release and runtime configuration. Errors, graphile-cache, server and Explorer builds passed. Real HTTP coverage and final stack validation are recorded in #1855.

Next layer: #1855 (F21) bounds and serializes unique builds with watchdog and shutdown drain.

@tenki-reviewer

tenki-reviewer Bot commented Sep 21, 2026 •

Copy link
Copy Markdown

Review complete. No issues found — approved ✅.


This PR introduces a new module that coalesces concurrent schema builds by exact key using fenced flight scopes, refactors the existing in-flight map, and threads the new lifecycle through the server/explorer middleware with new 503-refusal error codes. The refactor keeps scope-fencing, drain ordering, and invalidation semantics intact, and ships with focused tests.

Files Change
graphile/graphile-cache/src/build-flights.ts, admitted-build.ts, graphile-cache.ts, index.ts New ScopeRegistry/flight coalescing replacing the simple in-flight map; fenced scope capture/release, drain, and exact-key dedup.
graphile/graphile-cache/src/tests/build-flights.test.ts, flight-publication.test.ts Tests covering coalescing, publication, and race behavior.
graphql/server/src/middleware/graphile.ts, graphql/explorer/src/server.ts Server and explorer build handlers moved onto the new registry with reopen/close integration.
packages/errors/src/registry.ts, tests/schema-build.test.ts Registers SCHEMA_BUILD_* lifecycle-refusal codes (HTTP 503) and covers their classification.

Two candidate concerns (lifecycle refusals surfaced as internal failures; close leaving prep scopes that block reopen) were verified with sub-threshold confidence and are not reported as inline findings.

Reviewed commit: f61aca9

@Zetazzz

Zetazzz commented Sep 21, 2026

Copy link
Copy Markdown
Contributor Author

Reviewed the approval summary; there are no inline findings to resolve. Updated this PR with the reviewed F17/F19 dependency commits in 4931d07. Missing service keys now return before either resident eviction or flight invalidation.

The two lower-confidence observations remain outside this slice's behavior change: HTTP classification/admission of build-readiness refusals belongs to F23, and a closed flight registry must retain preparation scopes until their owners release them so reopen cannot abandon in-progress metadata work (broader server shutdown integration is F26). This PR keeps that ownership boundary.

Validation: 20 focused admission/invalidation/flight tests at this layer; the complete stack passes 84 graphile-cache tests, 8 server flush tests and the graphile-cache build.

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