Skip to content

SY-3498: Oracle Code Generation#1921

Merged
emilbon99 merged 65 commits intorcfrom
pr-1-oracle-tool
Feb 20, 2026
Merged

SY-3498: Oracle Code Generation#1921
emilbon99 merged 65 commits intorcfrom
pr-1-oracle-tool

Conversation

@emilbon99
Copy link
Contributor

@emilbon99 emilbon99 commented Feb 2, 2026

Summary

  • Introduces Oracle, a schema-first code generation framework
  • Generates types for Go, TypeScript, Python, and C++
  • Produces Protocol Buffers with translators for cross-language serialization

Review Guide

  • The code in this PR is purely for code generation purposes, and does not affect runtime execution of Synnax.
  • The majority of this code was generated by Claude and refined to match the Synnax coding standards. I don't think that this code should be reviewed or maintained to the same exacting standards as our runtime critical software.
  • Oracle includes a standardized parse and analyzer, and then a set of plugins used to genrate code.

Context

This is PR 1 of 9 in the Oracle code generation series. PRs must be merged in order.

Merge sequence: 1 → 2 → 3 → 4 → 5 → 6 → 7 → 8 → 9

Dependencies

  • Depends on: None (first PR)

Greptile Overview

Greptile Summary

Introduces Oracle, a comprehensive schema-first code generation framework that generates types and serialization code for Go, TypeScript, Python, and C++ from a single source of truth.

Key Components:

  • ANTLR4-based parser for Oracle schema language (.oracle files)
  • Multi-pass analyzer with type resolution, generics support, and inheritance validation
  • Plugin-based architecture for extensible code generation
  • Language-specific type generators (Go, TS, Python, C++) with domain-specific features
  • Protocol Buffers integration with automatic translator generation
  • LSP server for IDE support with completion, hover, and semantic highlighting
  • Path security with validation to prevent directory traversal attacks
  • Smart file syncing that only writes changed files

Architecture:

  • Schema files define structs, enums, and type aliases with domain annotations
  • Analyzer builds a resolution table with type references and validation
  • Plugins query the resolution table and generate language-specific code
  • Post-processors run formatters and linters on generated code
  • VSCode extension provides syntax highlighting and language server integration

Code Quality:

  • Comprehensive test coverage across all components (129 test files)
  • Proper error handling with diagnostics system for parse/analysis errors
  • Security-conscious path handling with traversal prevention
  • Clean separation of concerns between parsing, analysis, and generation phases

Confidence Score: 5/5

  • Safe to merge - well-architected foundation with comprehensive testing and security considerations
  • Clean implementation of a code generation framework with proper error handling, comprehensive test coverage, security-conscious path validation, and well-separated concerns. All 129 new files follow consistent patterns with no critical issues identified.
  • No files require special attention

Important Files Changed

Filename Overview
oracle/oracle.go Main entry point for Oracle code generation framework with plugin orchestration
oracle/analyzer/analyzer.go Schema analyzer that parses Oracle files and builds type resolution tables
oracle/parser/parser.go ANTLR4-based parser wrapper for Oracle schema language with error handling
oracle/plugin/plugin.go Plugin interface and registry for language-specific code generators
oracle/resolution/type.go Type resolution system with support for generics, inheritance, and field merging
oracle/plugin/go/types/types.go Go code generator plugin for struct types with import management
oracle/plugin/ts/types/types.go TypeScript code generator plugin with zod validation support
oracle/plugin/go/pb/pb.go Protobuf translator generator for Go with bidirectional conversion functions
oracle/paths/paths.go Path utilities ensuring repo-relative resolution with security validation
oracle/exec/exec.go Command execution utilities for running formatters and linters on generated code

Sequence Diagram

sequenceDiagram
    participant User
    participant CLI as CLI (cmd/oracle)
    participant Oracle as Oracle Core
    participant Analyzer
    participant Parser as ANTLR Parser
    participant Loader as File Loader
    participant ResTable as Resolution Table
    participant Registry as Plugin Registry
    participant GoTypes as go/types Plugin
    participant TSTypes as ts/types Plugin
    participant PBTypes as pb/types Plugin
    participant GoPB as go/pb Plugin
    participant PostWriter as Formatter/Linter

    User->>CLI: oracle sync [files]
    CLI->>Oracle: Generate(files, repoRoot, registry)
    
    Oracle->>Analyzer: Analyze(files, loader)
    loop For each file
        Analyzer->>Loader: Load(file)
        Loader-->>Analyzer: source, filePath
        Analyzer->>Parser: Parse(source)
        Parser-->>Analyzer: AST
        Analyzer->>ResTable: Add(Type)
        Note over Analyzer: Collect structs, enums, typedefs<br/>Resolve type references<br/>Validate inheritance
    end
    Analyzer-->>Oracle: Resolution Table
    
    loop For each plugin
        Oracle->>Registry: Get plugin dependencies
        alt Has dependencies
            Oracle->>Registry: Check dependency staleness
        end
        Oracle->>GoTypes: Generate(Request{table, repoRoot})
        GoTypes->>ResTable: Query types with @go domain
        GoTypes-->>Oracle: Response{Files}
        
        Oracle->>TSTypes: Generate(Request{table, repoRoot})
        TSTypes->>ResTable: Query types with @ts domain
        TSTypes-->>Oracle: Response{Files}
        
        Oracle->>PBTypes: Generate(Request{table, repoRoot})
        PBTypes->>ResTable: Query types with @pb domain
        PBTypes-->>Oracle: Response{Files}
        
        Oracle->>GoPB: Generate(Request{table, repoRoot})
        Note over GoPB: Requires go/types and pb/types
        GoPB->>ResTable: Query types with @pb domain
        GoPB-->>Oracle: Response{translator.gen.go}
    end
    
    Oracle-->>CLI: GenerateResult{files by plugin}
    CLI->>Oracle: SyncFiles(outputDir)
    Note over Oracle: Only write changed files
    Oracle-->>CLI: SyncResult{written, unchanged}
    
    CLI->>PostWriter: Run formatters/linters
    loop For each file group
        PostWriter->>PostWriter: gofmt, prettier, eslint, etc.
    end
    PostWriter-->>CLI: Success
    
    CLI-->>User: Summary (X files generated)
Loading

Oracle is a schema-first code generation system that produces type definitions
and serialization code across multiple languages (Go, TypeScript, Python, C++)
from centralized .oracle schema files.

Key components:
- Parser: ANTLR-based lexer/parser for .oracle schema files
- Analyzer: Schema validation and import resolution
- Resolution: Type system with namespace support and topological sorting
- Plugins: Language-specific code generators (ts/types, go/types, py/types,
  cpp/types, cpp/json, cpp/pb, go/pb, pb/types)
- LSP: Language Server Protocol support for IDE integration
- CLI: Commands for sync, check, fmt, and lsp

This establishes the foundation for schema-driven type generation used
throughout the Synnax platform.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

10 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

@emilbon99 emilbon99 requested a review from pjdotson February 3, 2026 17:21
Copy link
Contributor

@pjdotson pjdotson left a comment

Choose a reason for hiding this comment

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

  1. Can you make sure to add CI tests
  2. Can you make sure base branch is `rc

@pjdotson
Copy link
Contributor

pjdotson commented Feb 3, 2026

@emilbon99 ignore comment and approval that was fat fingers

@pjdotson pjdotson self-requested a review February 3, 2026 19:09
Copy link
Contributor

@pjdotson pjdotson left a comment

Choose a reason for hiding this comment

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

  1. Add workflow for this to CI.
  2. Can you improve the install.sh file to make errors more descriptive? it is failing for me and I don't know why.

@codecov
Copy link

codecov bot commented Feb 11, 2026

Codecov Report

❌ Patch coverage is 66.13130% with 1202 lines in your changes missing coverage. Please review.
✅ Project coverage is 53.83%. Comparing base (4cd7c60) to head (8b7371c).
⚠️ Report is 1 commits behind head on rc.

Files with missing lines Patch % Lines
oracle/plugin/cpp/pb/pb.go 51.33% 321 Missing and 62 partials ⚠️
oracle/plugin/cpp/json/json.go 46.62% 211 Missing and 50 partials ⚠️
oracle/analyzer/analyzer.go 69.59% 165 Missing and 29 partials ⚠️
oracle/formatter/formatter.go 77.60% 103 Missing and 24 partials ⚠️
oracle/parser/oracleparser_base_listener.go 0.00% 72 Missing ⚠️
oracle/parser/oracleparser_base_visitor.go 0.00% 66 Missing ⚠️
oracle/paths/paths.go 65.78% 20 Missing and 6 partials ⚠️
oracle/lsp/server.go 85.81% 18 Missing and 2 partials ⚠️
oracle/domain/doc/doc.go 92.45% 7 Missing and 5 partials ⚠️
oracle/analyzer/context.go 15.38% 11 Missing ⚠️
... and 8 more
Additional details and impacted files
@@            Coverage Diff             @@
##               rc    #1921      +/-   ##
==========================================
+ Coverage   53.53%   53.83%   +0.30%     
==========================================
  Files        2407     2460      +53     
  Lines      138700   150696   +11996     
  Branches     7106     7096      -10     
==========================================
+ Hits        74249    81124    +6875     
- Misses      62646    67108    +4462     
- Partials     1805     2464     +659     
Flag Coverage Δ
alamos-go 55.25% <ø> (ø)
arc-go 74.50% <ø> (ø)
aspen 69.30% <ø> (-0.13%) ⬇️
cesium 83.14% <ø> (+0.05%) ⬆️
client-py 86.51% <ø> (ø)
core 66.91% <ø> (-0.02%) ⬇️
freighter-go 63.26% <ø> (ø)
freighter-integration 1.50% <ø> (ø)
freighter-py 79.47% <ø> (ø)
x-go 78.54% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@emilbon99 emilbon99 changed the base branch from sy-3498-oracle-v2 to sy-3760-oracle-prep-7-extract-common-oracle-lsp-diagnostics February 12, 2026 04:22
@emilbon99
Copy link
Contributor Author

Fixed the oracle flags. I don't think I ended up adding any of those helpers to go I just removed them in places where they weren't necessary.

@emilbon99 emilbon99 changed the base branch from sy-3768-oracle-prep-10-fix-mypy-type-checking-in-client to rc February 18, 2026 17:53
@emilbon99 emilbon99 changed the base branch from rc to sy-3768-oracle-prep-10-fix-mypy-type-checking-in-client February 18, 2026 17:53
Base automatically changed from sy-3768-oracle-prep-10-fix-mypy-type-checking-in-client to rc February 20, 2026 03:03
@emilbon99 emilbon99 merged commit 86299a6 into rc Feb 20, 2026
34 of 36 checks passed
@emilbon99 emilbon99 deleted the pr-1-oracle-tool branch February 20, 2026 03:04
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.

2 participants