Skip to content

Begin adding typescript frontend for CLDK#158

Closed
rahlk wants to merge 6 commits into
mainfrom
claude/python-sdk-neo4j-backend-7bv1ny
Closed

Begin adding typescript frontend for CLDK#158
rahlk wants to merge 6 commits into
mainfrom
claude/python-sdk-neo4j-backend-7bv1ny

Conversation

@rahlk

@rahlk rahlk commented Jun 20, 2026

Copy link
Copy Markdown
Collaborator

Signed-off-by: Rahul Krishna rkrsn@ibm.com

rahlk and others added 6 commits June 18, 2026 08:39
Signed-off-by: Rahul Krishna <rkrsn@ibm.com>
…analyzer-ts graph)

Add TSNeo4jBackend, a drop-in alternative to the in-memory TSCodeanalyzer that
answers the exact same get_* query surface (call graph, callers/callees, class
hierarchy, call sites, decorators, symbol/method/field lookups, imports/exports/
variables, ...) by running Cypher over a live Neo4j graph instead of walking the
pydantic / NetworkX structures.

The graph is the one codeanalyzer-typescript emits with `--emit neo4j` (schema
schema.neo4j.json). The backend can populate the database for you over Bolt
(running the analyzer with --emit neo4j --neo4j-uri), or query a DB that is
already loaded (build_db=False). Results are re-hydrated into the same
cldk.models.typescript pydantic objects the in-memory backend returns; lossy
fields inherent to the projection (collapsed comments/type-params, aggregated
import edges, the three round-tripped CALLS tag keys) are reconstructed
best-effort and documented inline.

- cldk/analysis/typescript/neo4j/: backend, model reconstruction, Neo4jConnectionConfig.
- TypeScriptAnalysis / CLDK.analysis: optional neo4j_config selects the backend;
  default behavior unchanged.
- pyproject: optional `neo4j` extra for the driver.
- tests: live-DB integration tests (skipped when no Neo4j reachable) mirroring the
  in-memory backend's sample-app expectations, plus no-DB backend-selection unit tests.
Extract TSAnalysisBackend (cldk/analysis/typescript/backend.py), an abstract base
declaring the full 40-method query surface the TypeScriptAnalysis facade delegates
to. Both backends now implement it:
  - TSCodeanalyzer (in-memory pydantic / NetworkX)
  - TSNeo4jBackend (Cypher over Neo4j)

The facade<->backend relationship is now enforced by the type system and at
instantiation time, instead of matching only by convention. Facade `backend` is
typed against the ABC. Added a contract test asserting both backends subclass it,
fully implement it, and preserve every method signature.
Mirror the TypeScript TSAnalysisBackend pattern for Java and Python, in
anticipation of Neo4j/Cypher backends for those languages too:

  - cldk/analysis/java/backend.py:   JavaAnalysisBackend (36-method surface);
    JCodeanalyzer now subclasses it.
  - cldk/analysis/python/backend.py: PythonAnalysisBackend (21-method surface);
    PyCodeanalyzer now subclasses it.

Both facades type their `backend` attribute against the ABC, so a future
alternative backend can be selected without touching the facade. Added contract
tests for each (subclass, abstract/not-instantiable, fully-implemented, and that
the ABC covers every method the facade delegates to).
use_ray is already lifted all the way up (CLDK.analysis → PythonAnalysis →
PyCodeanalyzer → AnalysisOptions.using_ray), but unlike use_codeql and cache_dir
it had no regression test. Add test_use_ray_forwarded_through_facade mirroring the
existing use_codeql guard, so the facade can't silently drop the flag.
@rahlk rahlk force-pushed the claude/python-sdk-neo4j-backend-7bv1ny branch from f0188ad to 0a4f6da Compare June 20, 2026 04:22
@rahlk rahlk closed this Jun 20, 2026

rahlk commented Jun 20, 2026

Copy link
Copy Markdown
Collaborator Author

Closing in favor of #159, which tracks the same changes from the feat/neo4j-backend-support branch with an accurate title.


Generated by Claude Code

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