Skip to content

feat(query): implement self-hosted Query API (Phase 4)#131

Merged
graydeon merged 1 commit intomainfrom
feat/query-api-phase4-123
Apr 9, 2026
Merged

feat(query): implement self-hosted Query API (Phase 4)#131
graydeon merged 1 commit intomainfrom
feat/query-api-phase4-123

Conversation

@graydeon
Copy link
Copy Markdown
Contributor

@graydeon graydeon commented Apr 9, 2026

Summary

Implements Phase 4 of the self-hosting roadmap: Query API in Gradient.

New File: compiler/query.gr

Core Types

  • Session: compilation session holding parsed/type-checked results
  • QueryEngine: query execution engine
  • CheckResult: result of type checking with diagnostics
  • SymbolInfo: information about top-level symbols
  • TypeAtResult: type information at specific positions
  • Diagnostic: error/warning/info messages with position

Enums

  • Severity: Error/Warning/Info
  • Phase: Lexer/Parser/Typechecker/IR/Codegen
  • SymbolKind: Function/Extern/Variable/Type/Actor/Trait/Impl

Core Functions

  • new_query_engine, new_session, new_session_from_file
  • check, get_symbols, type_at, symbol_at
  • has_errors, error_count

Utilities

  • severity_to_string, phase_to_string, symbol_kind_to_string

Self-Hosting Tests (All 10 Passing)

  • 2 new tests added for query module
  • All previous tests continue to pass

Related Issues

Implements Phase 4 of the self-hosting roadmap: Query API in Gradient.

**New File: compiler/query.gr**

Core Types:
- Session: compilation session holding parsed/type-checked results
- QueryEngine: query execution engine
- CheckResult: result of type checking with diagnostics
- SymbolInfo: information about top-level symbols
- TypeAtResult: type information at specific positions
- Diagnostic: error/warning/info messages with position

Enums:
- Severity: ErrorSeverity, WarningSeverity, InfoSeverity
- Phase: LexerPhase, ParserPhase, TypecheckerPhase, IrPhase, CodegenPhase
- SymbolKind: FunctionSymbol, ExternFunctionSymbol, VariableSymbol, etc.

Core Functions:
- new_query_engine: create query engine
- new_session: create session from source code
- new_session_from_file: create session from file
- check: check source and return diagnostics
- get_symbols: return all top-level symbols
- type_at: query type at specific position
- symbol_at: get symbol info at position
- has_errors, error_count: error checking utilities

Utility Functions:
- severity_to_string: convert severity to string
- phase_to_string: convert phase to string
- symbol_kind_to_string: convert symbol kind to string

**Tests:**
- all_modules_plus_query_concatenated_parses_and_typechecks_clean ✅
- query_gr_concatenated_exposes_expected_symbols ✅

All 10 self-hosting tests now pass.

Part of #116 (Self-Hosting Epic)
Closes #123 (Phase 4: Query API)
@graydeon graydeon merged commit 04f38a0 into main Apr 9, 2026
4 checks passed
@graydeon graydeon deleted the feat/query-api-phase4-123 branch April 9, 2026 16:12
graydeon added a commit that referenced this pull request Apr 11, 2026
Implements Phase 4 of the self-hosting roadmap: Query API in Gradient.

**New File: compiler/query.gr**

Core Types:
- Session: compilation session holding parsed/type-checked results
- QueryEngine: query execution engine
- CheckResult: result of type checking with diagnostics
- SymbolInfo: information about top-level symbols
- TypeAtResult: type information at specific positions
- Diagnostic: error/warning/info messages with position

Enums:
- Severity: ErrorSeverity, WarningSeverity, InfoSeverity
- Phase: LexerPhase, ParserPhase, TypecheckerPhase, IrPhase, CodegenPhase
- SymbolKind: FunctionSymbol, ExternFunctionSymbol, VariableSymbol, etc.

Core Functions:
- new_query_engine: create query engine
- new_session: create session from source code
- new_session_from_file: create session from file
- check: check source and return diagnostics
- get_symbols: return all top-level symbols
- type_at: query type at specific position
- symbol_at: get symbol info at position
- has_errors, error_count: error checking utilities

Utility Functions:
- severity_to_string: convert severity to string
- phase_to_string: convert phase to string
- symbol_kind_to_string: convert symbol kind to string

**Tests:**
- all_modules_plus_query_concatenated_parses_and_typechecks_clean ✅
- query_gr_concatenated_exposes_expected_symbols ✅

All 10 self-hosting tests now pass.

Part of #116 (Self-Hosting Epic)
Closes #123 (Phase 4: Query API)
graydeon added a commit that referenced this pull request Apr 11, 2026
Implements Phase 4 of the self-hosting roadmap: Query API in Gradient.

**New File: compiler/query.gr**

Core Types:
- Session: compilation session holding parsed/type-checked results
- QueryEngine: query execution engine
- CheckResult: result of type checking with diagnostics
- SymbolInfo: information about top-level symbols
- TypeAtResult: type information at specific positions
- Diagnostic: error/warning/info messages with position

Enums:
- Severity: ErrorSeverity, WarningSeverity, InfoSeverity
- Phase: LexerPhase, ParserPhase, TypecheckerPhase, IrPhase, CodegenPhase
- SymbolKind: FunctionSymbol, ExternFunctionSymbol, VariableSymbol, etc.

Core Functions:
- new_query_engine: create query engine
- new_session: create session from source code
- new_session_from_file: create session from file
- check: check source and return diagnostics
- get_symbols: return all top-level symbols
- type_at: query type at specific position
- symbol_at: get symbol info at position
- has_errors, error_count: error checking utilities

Utility Functions:
- severity_to_string: convert severity to string
- phase_to_string: convert phase to string
- symbol_kind_to_string: convert symbol kind to string

**Tests:**
- all_modules_plus_query_concatenated_parses_and_typechecks_clean ✅
- query_gr_concatenated_exposes_expected_symbols ✅

All 10 self-hosting tests now pass.

Part of #116 (Self-Hosting Epic)
Closes #123 (Phase 4: Query API)
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.

[Self-Hosting] Phase 6: Implement IR Builder in Gradient

1 participant