Skip to content

feat(ogar-adapter-surrealql): wire surrealdb-parser deps + syntax validation (ADR-017 partial close)#24

Merged
AdaWorldAPI merged 2 commits into
mainfrom
claude/surrealql-parser-wire-up
Jun 5, 2026
Merged

feat(ogar-adapter-surrealql): wire surrealdb-parser deps + syntax validation (ADR-017 partial close)#24
AdaWorldAPI merged 2 commits into
mainfrom
claude/surrealql-parser-wire-up

Conversation

@AdaWorldAPI

Copy link
Copy Markdown
Owner

ogar-adapter-surrealql parse wire-up — deps + syntax validation + smoke tests

Follow-up to PR #23 (rust-version 1.85 → 1.95 bump + ecosystem pin matrix). Now that the rust-version blocker is cleared, this PR wires up surrealdb-ast + surrealdb-parser under the surrealdb-parser feature flag and drives the parser for syntax validation.

What lands

Cargo.toml:

  • surrealdb-parser feature now activates real deps: surrealdb-ast + surrealdb-parser, both taken from the workspace's pinned git refs (AdaWorldAPI/surrealdb#main, per PR chore: bump rust-version 1.85 -> 1.95 (mandatory ecosystem pin alignment) #23's [workspace.dependencies]).
  • Default build (no features) doesn't pull the deps in — keeps the crate lightweight for consumers that only need emit_surrealql_ddl.

src/lib.rs:

  • ParseError gains Unimplemented(String) variant + Display + std::error::Error impls (proper error type, no more todo!() panic).
  • parse_surrealql_ddl(input):
    • Without feature: returns Err(ParseError::Unimplemented("…feature not enabled…")).
    • With --features surrealdb-parser: drives Parser::enter_parse::<surrealdb_ast::Query>(input, Config). On parse-OK, returns Err(ParseError::Unimplemented("DDL parsed successfully; AST → Class walk pending follow-up sprint")). On syntax error, returns Err(ParseError::Parse(error_message)).
  • Three smoke tests gated by feature combo: feature-on valid DDL → Unimplemented(parsed-OK); feature-on invalid DDL → Parse(error); feature-off any DDL → Unimplemented(feature off).
  • Crate docs reframed: the rust-version blocker note removed (no longer applies post PR chore: bump rust-version 1.85 -> 1.95 (mandatory ecosystem pin alignment) #23), replaced with a "Status post PR chore: bump rust-version 1.85 -> 1.95 (mandatory ecosystem pin alignment) #23" section + a canonical parser invocation pattern documenting the full Query → TopLevelExpr → Expr::DefineTable / DefineField → Ident.text arena-walk chain. Future follow-up walk impl doesn't have to re-derive it.

Scope honesty: partial close, not full close, of ADR-017

This PR moves ADR-017 from "blocked, scaffold only" to "deps wired, parser driven, syntax validation working" — but the AST → Class walk itself is the substantive follow-up sprint because:

  • The surrealdb-ast is arena-allocated (NodeId<T>-indexed via Ast<L>).
  • Each DefineTable / DefineField walk goes through ~6 layers of indirection (Query.exprsNodeListId<TopLevelExpr>TopLevelExpr::ExprNodeId<Expr>Expr::DefineTable(NodeId<DefineTable>)DefineTable.name: NodeId<Expr>Expr::Ident(NodeId<Ident>)Ident.text: NodeId<String>).
  • DefineField has ty: Option<NodeId<Type>> — the Type enum represents record<X> / option<X> / scalar / etc., each needing a different Class mapping per OGAR-AST-CONTRACT.md §2.
  • Realistic walk impl is ~250-400 lines + handles all the Type variants + supports ASSERT $value IN [...] for EnumDecl::Static mapping.

Shipping it as a separate, focused follow-up PR avoids overcommitting on a complex internal-API walk in one PR (the EnterEffect cascade lesson from PR #13/#15).

What this enables for the follow-up

The follow-up walk PR can directly target the canonical pattern documented in src/lib.rs crate docs. The smoke tests provide the wiring proof; the walk impl just has to fill in the body.

register_class_knowable_from still stubbed

That's the §10.3 producer side of the knowable_from meet-point (ADR-010). It needs a Lance dataset writer in addition to the parser-side wiring. Tracked as a separate follow-up that pairs with the lance-bind Sprint-5b boundary.

Verification

  • cargo check --workspace should succeed (no consumers of the new deps yet by default).
  • cargo test --workspace should succeed (existing 12 emit tests + 1 feature-off smoke test).
  • cargo test --workspace --features ogar-adapter-surrealql/surrealdb-parser (or however the workspace exposes it) should succeed (12 emit + 2 feature-on smoke tests; 1 feature-off test skipped).
  • Note: I haven't been able to run cargo locally in this session, so CI is the ground truth.

https://claude.ai/code/session_01PBTGaPCSnnt6u3pjXpbLwY

…eps under feature flag

Activates the surrealdb-parser feature flag — deps from the workspace
(AdaWorldAPI/surrealdb#main, pinned in PR #23's [workspace.dependencies]).
Available now that PR #23 cleared the 1.85 -> 1.95 rust-version blocker.

By default (no features), the deps are not built. With
--features surrealdb-parser, both surrealdb-ast and surrealdb-parser
are pulled in for the parse_surrealql_ddl + register_class_knowable_from
wire-ups (this PR implements syntax validation; AST walk is a follow-up
sprint).

https://claude.ai/code/session_01PBTGaPCSnnt6u3pjXpbLwY
…ation + smoke tests

Now that PR #23 cleared the rust-version blocker, parse_surrealql_ddl:
  - Without the `surrealdb-parser` feature: returns ParseError::Unimplemented
    with a 'feature off' rationale (was: todo!() panic).
  - With the feature: drives Parser::enter_parse::<Query>(input, Config)
    for syntax validation. On parse-OK, returns Unimplemented with a
    'parsed successfully; AST -> Class walk pending follow-up' message.
    On syntax error, returns ParseError::Parse with the error message.

Three smoke tests:
  - With feature: valid DDL returns Unimplemented(parsed-OK)
  - With feature: invalid DDL returns Parse(error)
  - Without feature: any DDL returns Unimplemented(feature off)

ParseError gains Unimplemented(String) variant + Display + std::error::Error
impls (proper error type, not panic).

Crate docs reframed: rust-version blocker note removed, replaced with a
'Status post PR #23' section documenting the wire-up state + a canonical
parser invocation pattern for the follow-up walk sprint. The pattern
documents the full Query -> TopLevelExpr -> Expr::DefineTable / DefineField
-> Ident.text arena-walk chain so the follow-up impl doesn't have to
re-derive it.

Partially closes ADR-017: deps usable from OGAR's workspace, parser drives
real input, smoke tests prove the wiring. Full close awaits the AST walk
(substantive sprint — ~250-400 lines + handles record<X>/option<X>/scalar
TYPE clauses + ASSERT $value IN [...] for enums per contract §2 mapping).

https://claude.ai/code/session_01PBTGaPCSnnt6u3pjXpbLwY
@AdaWorldAPI AdaWorldAPI merged commit 274d739 into main Jun 5, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 79884570db

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +25 to +26
surrealdb-ast = { workspace = true, optional = true }
surrealdb-parser = { workspace = true, optional = true }

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Avoid resolving parser git deps in default builds

With these optional git dependencies in the package manifest, Cargo still resolves/fetches them while generating the dependency graph even when surrealdb-parser is not enabled, so emit-only/default users are no longer insulated from the private/remote SurrealDB fork. I checked cargo test -p ogar-adapter-surrealql --no-default-features, and it failed before compiling because Cargo tried to update https://github.com/AdaWorldAPI/surrealdb for surrealdb-ast; in offline CI or consumers without access to that fork, the default build now breaks despite the feature being off.

Useful? React with 👍 / 👎.

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