Skip to content

refactor: use module-root deltas - #3

Merged
moshloop merged 46 commits into
mainfrom
refactor/module-root-delta-indexing
Sep 30, 2026
Merged

moshloop merged 46 commits into
mainfrom
refactor/module-root-delta-indexing

Conversation

@moshloop

Copy link
Copy Markdown
Member

What

  • Replace project-based storage with module-root delta indexing.
  • Remove legacy uir project CLI commands, GORM tables, and project browser API.
  • Introduce uir add, uir reindex, and uir query commands using module paths and delta snapshots.

Notes

  • BREAKING CHANGE: Legacy project tables are discarded when opening older databases. Back up databases first if history is required.

…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.
…ed database config

Add structured query flags for fine-grained symbol selection, implement reindex --all for unindexed registrations, support environment variables for database configuration, and enhance query result rendering with declaration code and usage lines.

Additions:
- Structured query options (--methods, --vars, --types, --modules, --packages, --callers, --calls, --implements, --inherits, --include, --exclude, --group-by) enable building queries without positional expressions
- reindex --all reindexes only registered checkouts lacking indexed heads
- UIR_DSN and UIR_SCHEMA environment variables provide database defaults
- Query results now populate declaration code, definition line numbers, and usage context from source
- Missing-head warnings alert users when query scope is incomplete
- New history show subcommand displays a commit's logical changes
- Query rendering displays symbol trees with code snippets, respecting grouping preferences

Breaking change: query expression argument is now optional when structured flags are provided; query without both fails with clear error.
Comment thread storage/symbol_fingerprints.go Fixed
…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.
… linting

Claude-Session-Id: 01a0f1ee-f195-7960-81ef-60837de2c356
@moshloop
moshloop merged commit d931dcc into main Sep 30, 2026
11 checks passed
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