Skip to content

Refactor server backend structure#35

Draft
ViTeXFTW wants to merge 4 commits into
agent/issue-21-model-parsingfrom
agent/refactor-server-structure
Draft

Refactor server backend structure#35
ViTeXFTW wants to merge 4 commits into
agent/issue-21-model-parsingfrom
agent/refactor-server-structure

Conversation

@ViTeXFTW

Copy link
Copy Markdown
Owner

Depends on #33; merge #33 first.

What changed

  • Extract asset discovery, BIG/W3D parsing, caching, bounded workers, and scan tests into asset_index.
  • Encapsulate live documents, virtual BIG files, incremental/full/bulk parsing, diagnostic caches, semantic history, and source precedence in DocumentStore.
  • Move reference-copy quick-fix decisions into analysis, with the server supplying only a URI-keyed source loader.

Why

backend.rs had accumulated asset ingestion, mutable document invariants, and analysis-specific quick-fix logic alongside LSP protocol handling. These deeper modules give each concern one concrete owner while keeping protocol adaptation together.

Compatibility

No schema, cache version/shape/path, LSP command, editor setting, or user-visible behavior changes are intended. Existing cache files remain compatible, scan ordering and invalidation are preserved, and cache clear/rebuild commands remain advertised.

After #33 merges, retarget this PR to dev.

Validation

  • cargo test
  • cargo clippy --workspace --all-targets -- -D warnings
  • ignored 3,000-W3D timing harness: serial 580 ms, parallel 409 ms, warm 334 ms median
  • server stdio E2E, including cache clear/rebuild and live-index refresh
  • npm run compile in editors/vscode

cargo fmt --all -- --check still reports a pre-existing formatting difference in untouched crates/analysis/src/completion.rs.

@greptile-apps

greptile-apps Bot commented Jul 12, 2026

Copy link
Copy Markdown

Greptile Summary

This PR breaks the server backend into smaller modules for asset indexing and document state. The main changes are:

  • Moves asset discovery, BIG/W3D parsing, cache handling, and scan tests into asset_index.
  • Adds DocumentStore for live documents, virtual BIG files, diagnostics caches, semantic history, and source lookup.
  • Moves reference-copy quick-fix source loading into analysis, with the server passing a URI-based loader.
  • Keeps LSP command wiring and backend protocol handling in backend.rs.

Confidence Score: 4/5

Mostly safe to merge after the quick-fix correctness issue is fixed.

The refactor is well-contained and covered by targeted tests, but the moved reference-copy logic can return incorrect code actions when same-name definitions use different block kinds.

crates/analysis/src/actions.rs

T-Rex T-Rex Logs

What T-Rex did

  • Reviewed the reference-copy quick-fix path and confirmed that the base location is chosen by kind while the copied parsed block is found by name; I located the existing unit test reference_copy_uses_source_loader_and_requires_source as the narrowest repro template; no repro harness was written and no command was run.
  • Ran the harness; it exited with code 0 and reported both clearIndexCache and rebuildIndexCache as invoked, a pre-scanned workspace MappedImage symbol was found, a live CommandButton symbol appeared, and after a document change the renamed symbol appeared while the old name was absent.

View all artifacts

T-Rex Ran code and verified through T-Rex

Important Files Changed

Filename Overview
crates/analysis/src/actions.rs Moves reference-copy quick-fix generation into analysis and adds a source loader; found a kind-matching bug when extracting the source block.
crates/server/src/asset_index.rs Extracts asset discovery, BIG/W3D parsing, persistent cache handling, and scan tests into a dedicated module.
crates/server/src/backend.rs Refactors the LSP backend to delegate document state and asset indexing while preserving protocol-facing behavior.
crates/server/src/document.rs Introduces DocumentStore for synchronized live document snapshots, diagnostic caches, semantic history, virtual files, and source precedence.
crates/analysis/tests/spec.rs Updates action test helper calls to pass the new source-loader callback.
crates/server/src/main.rs Registers the new asset_index and document modules.

Reviews (1): Last reviewed commit: "refactor: move origin copy fixes to anal..." | Re-trigger Greptile

Comment on lines +124 to +127
.find(|node| {
Block(node.clone())
.name()
.is_some_and(|token| token.text().eq_ignore_ascii_case(&name))

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 Match definition kind
The reference-copy fix finds the base location using kind, but then copies the first parsed block with the same name without checking the block keyword. When one INI contains two definition kinds with the same name, the action can insert the wrong reference copy for the overrides diagnostic.

@ViTeXFTW
ViTeXFTW force-pushed the agent/issue-21-model-parsing branch from f50615b to f911605 Compare July 13, 2026 07:51
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