Skip to content

feat: add module indexing and call graph - #6

Open
moshloop wants to merge 66 commits into
mainfrom
feat/module-indexing-and-call-graph
Open

moshloop wants to merge 66 commits into
mainfrom
feat/module-indexing-and-call-graph

Conversation

@moshloop

@moshloop moshloop commented Oct 1, 2026

Copy link
Copy Markdown
Member

What

  • Migrate storage and indexing to module-root delta architecture
  • Implement type-checked symbol indexing, compact query syntax, and symbol diff engine
  • Add call graph queries with dispatch call support and package filters
  • Update web UI with explorer views, command palette, dependency viewer, and call graphs

Why

  • Enable precise cross-module symbol querying, revision diffing, and call graph analysis

Notes

  • Contains breaking changes removing project-centric CLI commands and database schema

…ndexing

Remove legacy project-based tables and CLI commands, migrating to module-root storage with immutable delta snapshots. The new model tracks Go module paths as roots, registers checkout locations, and publishes immutable snapshots with optional base references. Source revisions store AST projections as JSON; deltas record set or delete operations per snapshot. Snapshot heads are published atomically with version-checked updates. Query expressions now use --root (module path), --location (checkout), and --snapshot (historical ID) instead of project keys. The browser lists roots and their checkouts with effective source views. Opening an older database discards legacy tables; back up first if history is needed.

BREAKING CHANGE: The uir project ... CLI, project GORM tables, and project browser API are removed. Use uir add [path], uir reindex [path], and uir query instead. Database schema changes from project-centric to module-root-centric with source deltas. Existing project snapshots are not imported.
…snapshots

Snapshots now capture each go.mod requirement, its declared/selected version, and the linked target snapshot, resolving local workspace modules, directory replacements, and versioned tags or pseudo-versions from registered checkouts.

Dirty worktrees record `git-{commit}-dirty-{latest UTC mtime}` as the revision and keep the raw SHA in a new git_commit column, so a linked local dependency changing no longer collides with the parent's clean commit. Source bytes for dirty and non-Git snapshots are stored in source_blobs and served hash-verified, so later local edits cannot change what a snapshot shows.

Historical commits resolve modules standalone, ignoring current workspaces and local replacements, and fall back to syntax coverage with dependency diagnostics when package loading fails. Unchanged-snapshot reuse now also requires the dependency set hash and re-verified indexing inputs.

BREAKING CHANGE: dirty Git-backed snapshots use a new revision format (`git-{commit}-dirty-{mtime}`) instead of the raw commit, and pre-existing snapshots report dependencies as not captured until reindexed.
…ule dependencies route

Adds refactor-preview/refactor-apply module routes that shell out to gopatch from the explorer, plus a dependencies route exposing declared requirements and linked snapshots.

Preview returns a diff and hash; apply refuses unless the hash matches so a changed workspace or input cannot silently apply a stale edit, and it reindexes affected registered checkouts afterwards.

Refactor routes require a current, fully indexed local checkout and are limited to loopback same-origin requests to avoid remote code modification.

The UIR DSN is passed to gopatch so current indexed references across the module and its consumers are checked, with relative SQLite paths resolved before gopatch changes directory.

Also resolve snapshots by git_commit in symboldiff selection and drop the deprecated strings.Title call.
Surface module dependency edges for the selected immutable snapshot so users can navigate to resolved targets or see why an edge is unresolved.
Add guarded rename/move actions that always preview the gopatch diff, apply it against the exact previewed hash, and refresh the explorer with the resulting snapshot.
Introduce API clients and types for dependencies and refactor preview/apply, and cover them with tests.
This commit introduces a bounded call graph query feature and models dispatch calls—calls whose target is chosen at run time among candidates.

The `graph` package builds nodes-and-edges graphs from any Source of neighbours: relationships UIR extracts from lowered bodies or an index. Build walks breadth-first from roots, bounded by depth and node limit, cycle-safe by tracking first-seen depths. A Theme renames and restyles nodes and edges; an index-backed source lives in `query/` beside the index.

The `golang` package lowers Go syntax into UIR expressions: identifiers, selectors, literals, binary, unary, parenthesised and call expressions are structured; every other kind is kept as source text. It reads syntax alone, never types.

`DispatchCallStmt` models a call to an interface method or rule name with several implementations. It carries the declared target by call and each candidate by dispatch. `CollectRelationships` yields one call to the declared target plus one dispatch per candidate, each with the guards that must hold to reach it.

The statement walker (`walk_stmt.go`) and guard extraction (`query/graph_guards.go`) support traversing bodies and extracting conditions from nested control flow. Themes centralize style class strings; `StyleBold`, `StyleKeyword`, etc. are roles, not colours.
Add import command to publish non-Go producer symbols and documents from JSON files. Enables external tools to contribute module metadata via CLI or HTTP. Updates document decoding to support custom symbol kinds from non-Go producers.
…reference recording

Claude-Session-Id: 8063198d-9298-4e94-bd97-3de019d70f3d
…er source, guards and cache helpers

Claude-Session-Id: 8063198d-9298-4e94-bd97-3de019d70f3d
….work

Claude-Session-Id: 8063198d-9298-4e94-bd97-3de019d70f3d
# Conflicts:
#	cmd/uir/diff_command.go
#	cmd/uir/history_command.go
#	cmd/uir/main.go
#	cmd/uir/module_commands.go
#	cmd/uir/module_query_render.go
#	cmd/uir/refactor_service.go
#	cmd/uir/serve.go
#	cmd/uir/serve_test.go
#	codec_regression_test.go
#	comment.go
#	docs/module-indexing.md
#	docs/query.md
#	docs/serve.md
#	docs/symbol-index-storage.md
#	docs/symbols.md
#	docs/uir-gorm-erd.tsx
#	enums.go
#	go.mod
#	go.sum
#	indexer/check_current.go
#	indexer/check_current_test.go
#	indexer/dependency_cycle_publish.go
#	indexer/dependency_cycles_integration_test.go
#	indexer/dependency_targets.go
#	indexer/discovery.go
#	indexer/module_dependencies_integration_test.go
#	indexer/module_documents_integration_test.go
#	indexer/module_extraction.go
#	indexer/module_integration_test.go
#	indexer/module_test_helpers_test.go
#	indexer/module_trigger_integration_test.go
#	indexer/modules.go
#	indexer/modules_documents.go
#	indexer/modules_locations.go
#	indexer/revision.go
#	indexer/symbol_deltas_integration_test.go
#	indexer/symbol_identity.go
#	indexer/symbol_identity_test.go
#	indexer/task.go
#	indexer/typed_index_integration_test.go
#	indexer/typed_load.go
#	indexer/unchanged_skip_integration_test.go
#	indexer/verify_inputs.go
#	indexer/versioned_dependency_graph.go
#	node_codec.go
#	packages/api/test/serve.spec.ts
#	pretty.go
#	python/statement_kinds.py
#	query/compact_execute.go
#	query/compact_graph.go
#	query/compact_parser_test.go
#	query/compact_query_test.go
#	query/compact_relation.go
#	query/compact_resolve.go
#	query/compact_selector.go
#	query/compact_suggest.go
#	query/compact_suggest_test.go
#	query/grammar.peg
#	query/grammar.peg.go
#	query/module_browse_test.go
#	query/module_content.go
#	query/module_documents.go
#	query/module_index.go
#	query/module_index_handles.go
#	query/module_index_ops.go
#	query/module_index_test.go
#	query/module_symbols.go
#	query/module_test_helpers_test.go
#	query/modules.go
#	query/modules_scope.go
#	query/parser.go
#	query/query.go
#	query/references.go
#	query/references_test.go
#	query/selector_glob.go
#	query/selector_ranges.go
#	query/selector_ranges_test.go
#	query/selector_suggest.go
#	query/structured.go
#	relationship.go
#	schema/uir.schema.json
#	statement.go
#	statement_decl_call.go
#	storage/README.md
#	storage/active_documents.go
#	storage/allocation.go
#	storage/database.go
#	storage/document.go
#	storage/document_type_form.go
#	storage/document_typed.go
#	storage/handle_cutover.go
#	storage/handle_cutover_integration_test.go
#	storage/migrations/04_module_roots.hcl
#	storage/migrations/06_symbol_index.hcl
#	storage/migrations/07_symbol_handles.hcl
#	storage/module_browse.go
#	storage/module_models.go
#	storage/module_storage_integration_test.go
#	storage/readonly.go
#	storage/schema_assertions_test.go
#	storage/symbol_handles.go
#	storage/symbol_handles_integration_test.go
#	storage/symbol_models.go
#	storage/symbolhandle/handle.go
#	storage/symbolhandle/handle_test.go
#	storage/symbolhandle/kind.go
#	symboldiff/delta_integration_test.go
#	symboldiff/diff.go
#	symboldiff/documents.go
#	symboldiff/fixtures_test.go
#	symboldiff/history.go
#	symboldiff/history_integration_test.go
#	symboldiff/render.go
#	symboldiff/selection.go
#	symboldiff/selection_integration_test.go
#	symboldiff/types.go
#	table.go
#	web/e2e/query-command-palette.spec.ts
#	web/src/App.tsx
#	web/src/ExplorerRefactorDialog.tsx
#	web/src/ExplorerView.tsx
#	web/src/HistoryView.tsx
#	web/src/SymbolDetails.tsx
#	web/src/SystemDetails.tsx
#	web/src/api.ts
#	web/src/explorer-navigation.test.ts
#	web/src/explorer-navigation.ts
#	web/src/query-completion.test.ts
#	web/src/query-completion.ts
#	web/src/query-language.test.ts
#	web/src/query-language.ts
#	web/src/route.test.ts
#	web/src/route.ts
@moshloop
moshloop added this pull request to stack #9 October 6, 2026 06:41

This branch has not been deployed

No deployments
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