Skip to content

Add schema proposal composition background job#7706

Open
jdolle wants to merge 25 commits intomainfrom
composition-job
Open

Add schema proposal composition background job#7706
jdolle wants to merge 25 commits intomainfrom
composition-job

Conversation

@jdolle
Copy link
Collaborator

@jdolle jdolle commented Feb 19, 2026

Background

Schema proposals need to run composition when they're updated. By creating a workflow, composition can be ran in the background on proposal update.

Description

Screenshot 2026-02-25 at 3 02 58 PM

This adds a background job to run composition when proposals are updated, and adds more columns to the schema proposal record to store the latest composition state.

A subscription was added to allow async updating of the composition state but the frontend logic for the subscription is not yet added because this PR is getting large.

Also, the redis pubsub instance was factored out into a separate package to avoid a circular dependency between the workflows and api packages.

Checklist

  • Testing

@jdolle jdolle self-assigned this Feb 19, 2026
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @jdolle, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the system's ability to manage schema proposals by offloading the composition and validation process to an asynchronous background job. This architectural change improves responsiveness and scalability by preventing blocking operations during schema updates. It establishes the necessary infrastructure within the workflows service to interact with an external schema composition service, laying the groundwork for more robust and efficient schema management.

Highlights

  • Background Job for Schema Composition: A new background job has been introduced to handle schema proposal composition, allowing this computationally intensive task to run asynchronously when schema proposals are updated.
  • SchemaProvider Implementation: A dedicated SchemaProvider has been implemented within the workflows service. This provider encapsulates the logic for composing and validating schemas, as well as retrieving the latest and proposed schema versions from the database.
  • External Schema Service Integration: The workflows service is now configured to connect to an external schema composition service via a SCHEMA_SERVICE_URL environment variable, enabling distributed schema processing.
  • New Workflow Task: A new task, SchemaProposalCompositionTask, has been defined to orchestrate the fetching of proposed schemas, their composition, and validation using the newly introduced SchemaProvider.
Changelog
  • deployment/services/workflows.ts
    • Added schemaServiceUrl as a new parameter to the deployWorkflows function.
    • Injected SCHEMA_SERVICE_URL as an environment variable into the deployed workflow service.
  • packages/services/api/src/modules/shared/providers/storage.ts
    • Removed a // @todo comment related to schema checks.
  • packages/services/workflows/.env.template
    • Added SCHEMA_SERVICE_URL with a default value for local development.
  • packages/services/workflows/src/context.ts
    • Imported SchemaProvider and added it to the Context type definition.
  • packages/services/workflows/src/environment.ts
    • Extended the EnvironmentModel schema to validate the SCHEMA_SERVICE_URL environment variable.
    • Configured env.schema.serviceUrl from the validated environment variable.
  • packages/services/workflows/src/index.ts
    • Imported the schemaProvider function.
    • Initialized the schema property in the application's context object using the schemaProvider.
  • packages/services/workflows/src/lib/schema/provider.ts
    • Added a new file defining the schemaProvider function.
    • Implemented composeAndValidate to interact with an external schema service via tRPC, including timeout handling.
    • Implemented latestSchemas to retrieve the most recent schema version for a given target.
    • Implemented proposedSchemas to fetch and apply schema changes from checks for a specific proposal.
  • packages/services/workflows/src/tasks/schema-proposal-composition.ts
    • Added a new file defining the SchemaProposalCompositionTask using defineTask.
    • Implemented the task to fetch proposed schemas, compose and validate them using the SchemaProvider, and log any composition errors.
Activity
  • The pull request is currently marked as a DRAFT.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 19, 2026

🚀 Snapshot Release (alpha)

The latest changes of this PR are available as alpha on npm (based on the declared changesets):

Package Version Info
hive 9.5.0-alpha-20260226020947-8544455864702df54d566684a7079d0f17acfb1f npm ↗︎ unpkg ↗︎
@graphql-hive/pubsub 0.0.1 npm ↗︎ unpkg ↗︎

@github-actions
Copy link
Contributor

github-actions bot commented Feb 19, 2026

🐋 This PR was built and pushed to the following Docker images:

Targets: build

Platforms: linux/amd64

Image Tag: 1aa49aae1b0fbd2ed6c2779ae652b8a1ac64831f

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a background job for schema proposal composition, including a new workflow and schema provider. However, a critical pagination logic error in proposedSchemas can lead to an infinite loop, causing a Denial of Service (DoS) for background workers. Additionally, there's a risk of worker crashes due to unhandled empty arrays and a missing ownership check (IDOR). Addressing these critical issues, along with other identified data fetching problems, potential runtime errors, and opportunities for improved type safety and style guide adherence, is crucial before merging.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 19, 2026

💻 Website Preview

The latest changes are available as preview in: https://pr-7706.hive-landing-page.pages.dev

query: sql`
ALTER TABLE IF EXISTS "schema_proposals"
ADD COLUMN IF NOT EXISTS "composition_status" TEXT
, ADD COLUMN IF NOT EXISTS "composition_timestamp" TIMESTAMPTZ
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Looking for feedback on this.
Should the composition state for the proposal be per-save or is it acceptable to be per-proposal (latest state only)?

Copy link
Member

Choose a reason for hiding this comment

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

I think the current/latest state is the only relevant composition state in a proposal.

observability,
sentry,
heartbeat: heartbeatsConfig.get('webhooks'),
schema,
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

moved after the schema instance because i need to reference it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants