Skip to content

feat(shader-driver): wire CypherBridge — lg.cypher step_type now routes#258

Merged
AdaWorldAPI merged 2 commits into
mainfrom
claude/cypher-to-arigraph-wire
Apr 24, 2026
Merged

feat(shader-driver): wire CypherBridge — lg.cypher step_type now routes#258
AdaWorldAPI merged 2 commits into
mainfrom
claude/cypher-to-arigraph-wire

Conversation

@AdaWorldAPI

Copy link
Copy Markdown
Owner

Summary

  • Adds CypherBridge (crates/cognitive-shader-driver/src/cypher_bridge.rs), an OrchestrationBridge impl that claims lg.cypher step_types and keeps every other lg.* / nd.* / non-lance-graph step flowing to its existing bridge.
  • Wires it into route_handler in serve.rs as the middle stage of a three-stage chain: CodecResearchBridge (nd.) → CypherBridge (lg.cypher) → planner_bridge (lg. residual, feature-gated).
  • Phase 1 — prefix classifier: CREATE and MATCHStepStatus::Completed + confidence 0.5 with a "stub — actual SPO commit / BindSpace search pending" reasoning; anything else cypher-shaped → StepStatus::Skipped; non-lg.cypherErr(DomainUnavailable) so the handler falls through unchanged.

Phase 2 (real lance_graph::parser::parse_cypher_query + SPO commit + BindSpace label search) is deliberately deferred: pulling lance-graph core (arrow + datafusion + lance) into cognitive-shader-driver would balloon build time for what today is a test-path transport. The stateless CypherBridge struct is explicitly shaped so an SPO store handle slots in when Phase 2 lands.

Closes the {"status":"failed","reasoning":"domain unavailable and planner not compiled in"} hole on /v1/shader/route for lg.cypher.

Test plan

  • cargo test --manifest-path crates/cognitive-shader-driver/Cargo.toml --features serve --lib cypher_bridge — 7 new unit tests pass: create_cypher_parses, match_cypher_parses, unsupported_cypher_skipped, non_cypher_rejected, missing_reasoning_errors, lowercase_cypher_parses, nd_prefix_rejected.
  • Live curl against localhost:3001/v1/shader/route with shader-serve --features serve:
    • CREATE (p:Palantir {id:1}){"status":"completed","reasoning":"cypher CREATE parsed (stub — actual SPO commit pending)","confidence":0.5}
    • MATCH (c:Customer) RETURN c{"status":"completed","reasoning":"cypher MATCH parsed (stub — actual BindSpace search pending)","confidence":0.5}
    • DROP INDEX foo{"status":"skipped","reasoning":"unsupported cypher construct, stub in place: DROP INDEX foo"}
    • step_type:"lg.plan"{"status":"failed","reasoning":"domain unavailable and planner not compiled in"} (unchanged pre-PR behaviour, confirms non-cypher lg.* still falls through).
  • Phase 2 follow-up: add lance-graph = { path = "../lance-graph", optional = true } under a with-cypher feature and wire parse_cypher_query + SPO commit once the CypherBridge has an actual SPO store handle to commit against.

https://claude.ai/code/session_01SbYsmmbPf9YQuYbHZN52Zh


Generated by Claude Code

claude added 2 commits April 24, 2026 20:46
Adds CypherBridge as an OrchestrationBridge implementation for the
`lg.cypher` step_type, closing the "domain unavailable and planner
not compiled in" gap on /v1/shader/route.

Phase 1 (this commit): lightweight prefix classifier that maps
- CREATE (...)           → StepStatus::Completed, confidence 0.5
- MATCH (...) RETURN ... → StepStatus::Completed, confidence 0.5
- anything else          → StepStatus::Skipped (stub-in-place)
- non-lg.cypher step_type → Err(DomainUnavailable) so route_handler
  falls through to the planner bridge as before.

Phase 2 (deferred): wire the real lance_graph::parser::parse_cypher_query
+ SPO commit / BindSpace label search. Pulling the lance-graph core
dep (arrow + datafusion + lance) into cognitive-shader-driver would
balloon build time for what today is a test-path transport; Phase 2
arrives once the SPO store handle is actually consumed downstream.

route_handler in serve.rs is now a three-stage chain:
CodecResearchBridge (nd.*) → CypherBridge (lg.cypher) → planner_bridge.
Each stage falls through only on DomainUnavailable, so execution
failures inside a stage still surface to the client unchanged.

Tests: 7 new unit tests in cypher_bridge.rs (create, match, unsupported,
non-cypher, missing-reasoning, lowercase, nd-reject). Live-verified via
curl against localhost:3001/v1/shader/route for all four cases.

https://claude.ai/code/session_01SbYsmmbPf9YQuYbHZN52Zh
@AdaWorldAPI AdaWorldAPI merged commit cbddc8b into main Apr 24, 2026
0 of 5 checks passed

@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: b56f7d4199

ℹ️ 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 +88 to +92
let preview_len = 50.min(query.len());
step.reasoning = Some(format!(
"unsupported cypher construct, stub in place: {}",
&query[..preview_len]
));

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Avoid byte slicing when truncating unsupported query preview

The unsupported-Cypher path truncates with &query[..preview_len] where preview_len is a byte count (50.min(query.len())). For queries longer than 50 bytes that contain multibyte UTF-8 characters, this can cut through a code point and panic at runtime, turning a normal lg.cypher request into a server error. Please switch to a char-boundary-safe truncation method before building the preview string.

Useful? React with 👍 / 👎.

Comment on lines +397 to +400
if matches!(
cypher_result,
Err(lance_graph_contract::orchestration::OrchestrationError::DomainUnavailable(_))
) {

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 Handle non-domain Cypher routing errors in route handler

After invoking CypherBridge, the handler only checks for DomainUnavailable and ignores RoutingFailed/ExecutionFailed. For invalid lg.cypher inputs (for example, missing reasoning), this leaves the request in a non-terminal state because the bridge error is dropped, and clients can receive running instead of a clear failure. Please explicitly handle non-domain errors from cypher_result as failed responses (or propagate them).

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.

2 participants