-
Notifications
You must be signed in to change notification settings - Fork 0
Implement realtime sync, event bus, and job scheduling protocols #81
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
…ve tests Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
|
This PR is very large. Consider breaking it into smaller PRs for easier review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Adds new ObjectOS system protocols (Realtime Sync, Event Bus, Job Scheduling) to packages/spec, including Zod schemas, Vitest coverage, and generated JSON Schema + MDX reference pages.
Changes:
- Introduces new Zod protocols:
realtime,events, andjobunderpackages/spec/src/system. - Adds comprehensive Vitest suites for the new protocols and exports them via
packages/spec/src/system/index.ts. - Generates corresponding JSON Schema artifacts and MDX reference documentation pages.
Reviewed changes
Copilot reviewed 49 out of 49 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/spec/src/system/realtime.zod.ts | Adds realtime sync protocol schemas (transport, subscriptions, presence, events). |
| packages/spec/src/system/realtime.test.ts | Adds Vitest coverage for realtime protocol schemas. |
| packages/spec/src/system/events.zod.ts | Adds event bus protocol schemas (event, handler, routes, persistence). |
| packages/spec/src/system/events.test.ts | Adds Vitest coverage for event bus protocol schemas. |
| packages/spec/src/system/job.zod.ts | Adds job scheduling protocol schemas (schedule union, retry policy, execution logs). |
| packages/spec/src/system/job.test.ts | Adds Vitest coverage for job scheduling protocol schemas. |
| packages/spec/src/system/index.ts | Exports the newly added system protocols. |
| packages/spec/json-schema/TransportProtocol.json | JSON Schema output for TransportProtocol. |
| packages/spec/json-schema/SubscriptionEvent.json | JSON Schema output for SubscriptionEvent. |
| packages/spec/json-schema/Subscription.json | JSON Schema output for Subscription. |
| packages/spec/json-schema/RealtimeEventType.json | JSON Schema output for RealtimeEventType. |
| packages/spec/json-schema/PresenceStatus.json | JSON Schema output for PresenceStatus. |
| packages/spec/json-schema/Presence.json | JSON Schema output for Presence. |
| packages/spec/json-schema/RealtimeAction.json | JSON Schema output for RealtimeAction. |
| packages/spec/json-schema/RealtimeEvent.json | JSON Schema output for RealtimeEvent. |
| packages/spec/json-schema/CronSchedule.json | JSON Schema output for CronSchedule. |
| packages/spec/json-schema/IntervalSchedule.json | JSON Schema output for IntervalSchedule. |
| packages/spec/json-schema/OnceSchedule.json | JSON Schema output for OnceSchedule. |
| packages/spec/json-schema/Schedule.json | JSON Schema output for Schedule union. |
| packages/spec/json-schema/RetryPolicy.json | JSON Schema output for RetryPolicy. |
| packages/spec/json-schema/Job.json | JSON Schema output for Job. |
| packages/spec/json-schema/JobExecutionStatus.json | JSON Schema output for JobExecutionStatus. |
| packages/spec/json-schema/JobExecution.json | JSON Schema output for JobExecution. |
| packages/spec/json-schema/EventMetadata.json | JSON Schema output for EventMetadata. |
| packages/spec/json-schema/Event.json | JSON Schema output for Event. |
| packages/spec/json-schema/EventHandler.json | JSON Schema output for EventHandler. |
| packages/spec/json-schema/EventRoute.json | JSON Schema output for EventRoute. |
| packages/spec/json-schema/EventPersistence.json | JSON Schema output for EventPersistence. |
| content/docs/references/system/TransportProtocol.mdx | MDX reference page for TransportProtocol. |
| content/docs/references/system/SubscriptionEvent.mdx | MDX reference page for SubscriptionEvent. |
| content/docs/references/system/Subscription.mdx | MDX reference page for Subscription. |
| content/docs/references/system/RealtimeEventType.mdx | MDX reference page for RealtimeEventType. |
| content/docs/references/system/PresenceStatus.mdx | MDX reference page for PresenceStatus. |
| content/docs/references/system/Presence.mdx | MDX reference page for Presence. |
| content/docs/references/system/RealtimeAction.mdx | MDX reference page for RealtimeAction. |
| content/docs/references/system/RealtimeEvent.mdx | MDX reference page for RealtimeEvent. |
| content/docs/references/system/CronSchedule.mdx | MDX reference page for CronSchedule. |
| content/docs/references/system/IntervalSchedule.mdx | MDX reference page for IntervalSchedule. |
| content/docs/references/system/OnceSchedule.mdx | MDX reference page for OnceSchedule. |
| content/docs/references/system/Schedule.mdx | MDX reference page for Schedule (currently empty). |
| content/docs/references/system/RetryPolicy.mdx | MDX reference page for RetryPolicy. |
| content/docs/references/system/Job.mdx | MDX reference page for Job. |
| content/docs/references/system/JobExecutionStatus.mdx | MDX reference page for JobExecutionStatus. |
| content/docs/references/system/JobExecution.mdx | MDX reference page for JobExecution. |
| content/docs/references/system/EventMetadata.mdx | MDX reference page for EventMetadata. |
| content/docs/references/system/Event.mdx | MDX reference page for Event. |
| content/docs/references/system/EventHandler.mdx | MDX reference page for EventHandler. |
| content/docs/references/system/EventRoute.mdx | MDX reference page for EventRoute. |
| content/docs/references/system/EventPersistence.mdx | MDX reference page for EventPersistence. |
Comments suppressed due to low confidence (1)
content/docs/references/system/Schedule.mdx:6
- This reference page is empty (no details on the discriminated union variants). Since
ScheduleSchemais a core public protocol type, the docs should describe each variant (cron,interval,once) and their required fields, or the doc generator should be updated so union schemas render properly.
---
title: Schedule
description: Schedule Schema Reference
---
| export const EventRouteSchema = z.object({ | ||
| from: z.string().describe('Source event pattern (supports wildcards, e.g., user.* or *.created)'), | ||
| to: z.array(z.string()).describe('Target event names to route to'), | ||
| transform: z.function().optional().describe('Optional function to transform payload'), | ||
| }); |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EventRouteSchema.transform is declared as z.function() without .args(...)/.returns(...), so the inferred type becomes overly permissive ((...args: any[]) => any) and loses useful contract validation. Define the expected signature (e.g., (payload) => payload) with .args(...) and .returns(...) to keep the protocol self-describing and type-safe.
| export const EventPersistenceSchema = z.object({ | ||
| enabled: z.boolean().default(false).describe('Enable event persistence'), | ||
| retention: z.number().int().positive().describe('Days to retain persisted events'), | ||
| filter: z.function().optional().describe('Optional filter function to select which events to persist'), | ||
| }); |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EventPersistenceSchema.filter is typed as a bare z.function() with no argument/return contract, which makes it hard to understand/validate what the filter should receive and return. Consider constraining it to something like (event: Event) => boolean via .args(EventSchema).returns(z.boolean()).
| type: z.literal('cron'), | ||
| expression: z.string().describe('Cron expression (e.g., "0 0 * * *" for daily at midnight)'), | ||
| timezone: z.string().optional().default('UTC').describe('Timezone for cron execution (e.g., "America/New_York")'), | ||
| }); |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
timezone uses .optional().default('UTC'). In Zod, .default(...) already makes the field optional, so the extra .optional() is redundant and inconsistent with other schemas in this repo (e.g., QueryContextSchema.timezone uses .default('UTC') without .optional()).
Adds three core system protocols for ObjectStack's metadata-driven runtime: realtime synchronization, event-driven architecture, and job scheduling.
Realtime Sync Protocol (
realtime.zod.ts)Event Bus Protocol (
events.zod.ts)user.*,*.created)Job Scheduling Protocol (
job.zod.ts)Coverage
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.