Skip to content

fix(index): address qodo review findings on batch write and parse progress#11

Merged
prom3theu5 merged 1 commit into
mainfrom
fix/qodo-review-index-clones-progress-race
Jun 2, 2026
Merged

fix(index): address qodo review findings on batch write and parse progress#11
prom3theu5 merged 1 commit into
mainfrom
fix/qodo-review-index-clones-progress-race

Conversation

@prom3theu5

Copy link
Copy Markdown
Member

Addresses the four qodo PR-review findings.

Changes

1. Avoid large clones in write_files_batch (src/graph/ladybug_store.rs)
The stage loop cloned every row list per stage, including the large single-use symbol_rows/declares_rows. Replaced it with a run_stage helper that moves the Vec<Value> into Value::List. Single-use lists move in by value (no clone); only the small shared path_rows is cloned for its first two of three stages. Query semantics unchanged.

2. Correct the manifest-error comment (src/indexer/mod.rs)
The comment claimed parse errors abort "exactly as the previous inline ? did". The new pipeline defers writes until after parse/drain, so a parse error now aborts the run before the batched write stage — a more atomic failure mode than the old write-as-you-go loop. Comment rewritten to describe the actual behaviour.

3. Harden the parse-progress observer race (src/indexer/mod.rs)
The observer could break on done == true without having observed the final parsed_count, leaving the last update below total. Reordered to read done first, then load + emit the counter, breaking only after that final emission. Strengthened the worker increment to fetch_add(Release) so — paired with the collect() join before done.store(Release) and the Acquire loads — there's a real happens-before guarantee on the final count.

4. Sync Cargo.lock with the version bump
The root synapse entry was still 0.2.1 while Cargo.toml is 0.2.2, which fails --locked CI/release builds. Bumped via cargo update -p synapse.

Verification

  • cargo fmt --check, cargo clippy --all-targets, cargo test --locked (47 pass) — all clean.
  • Built a release binary and ran three independent index --force runs of a 1,593-file repo (10,935 symbols / 61,547 reference edges). Symbol dump, package list, and depth-2 related edge traversals were byte-identical across all runs (matching SHA-256) — confirming the batch-write reorder and parallel-parse changes preserve determinism. The only pack diff was the git commit hash, which is a property of the test setup, not the indexer.

…gress

- ladybug_store: move single-use row lists into Value::List instead of
  cloning them per stage; only the small shared path_rows is cloned. Adds
  a run_stage helper so each stage executes directly.
- indexer: correct the manifest-error comment — parse errors now abort the
  run before the batched write stage (a more atomic failure mode than the
  old write-as-you-go loop).
- indexer: harden the parse progress observer against a termination race —
  read `done` before the counter and always emit the final count before
  breaking; strengthen the worker increment to Release for a real
  happens-before on the final count.
- Cargo.lock: bump synapse entry 0.2.1 -> 0.2.2 to match Cargo.toml so
  --locked CI/release builds pass.

Verified: cargo fmt --check, clippy --all-targets, test --locked (47 pass),
and three independent re-index runs of a 1,593-file repo produce
byte-identical symbol/package/edge output (determinism preserved).
@prom3theu5 prom3theu5 merged commit af342c6 into main Jun 2, 2026
1 check passed
@prom3theu5 prom3theu5 deleted the fix/qodo-review-index-clones-progress-race branch June 2, 2026 11:08
@qodo-code-review

Copy link
Copy Markdown

Review Summary by Qodo

Fix batch write clones, progress race, and Cargo.lock version sync

🐞 Bug fix ✨ Enhancement

Grey Divider

Walkthroughs

Description
• Eliminate unnecessary clones in batch write by moving single-use row lists into Value::List
  instead of cloning per stage; only the small shared path_rows is cloned
• Correct manifest-error comment to reflect actual atomic failure mode: parse errors now abort
  before batched write stage, not during write-as-you-go loop
• Harden parse-progress observer race condition by reading done before counter and always emitting
  final count; strengthen worker increment to Release ordering for happens-before guarantee
• Sync Cargo.lock synapse entry from 0.2.1 to 0.2.2 to match Cargo.toml for --locked
  CI/release builds
Diagram
flowchart LR
  A["Batch write stage<br/>with clones"] -->|"Extract run_stage<br/>helper"| B["Move single-use lists<br/>Clone only path_rows"]
  C["Parse progress observer<br/>race condition"] -->|"Reorder reads<br/>Strengthen ordering"| D["Read done first<br/>Emit final count<br/>Release semantics"]
  E["Cargo.lock<br/>out of sync"] -->|"cargo update"| F["synapse 0.2.2<br/>matches Cargo.toml"]
  B --> G["Determinism verified<br/>3 runs byte-identical"]
  D --> G

Loading

Grey Divider

File Changes

1. src/graph/ladybug_store.rs ✨ Enhancement +25/-24

Eliminate batch write clones with run_stage helper

• Added run_stage helper function that moves Vec into Value::List to avoid unnecessary clones
• Refactored write_files_batch to use run_stage for each stage, eliminating per-stage clones of
 large single-use lists (symbol_rows, declares_rows)
• Only the small shared path_rows list is cloned for its first two of three stages; third stage
 moves it by value
• Added detailed comment explaining the clone strategy and why each list is handled differently

src/graph/ladybug_store.rs


2. src/indexer/mod.rs 🐞 Bug fix +18/-5

Fix progress observer race and correct error handling comment

• Corrected manifest-error comment to accurately describe the new atomic failure mode: parse errors
 abort before batched write stage, not during write-as-you-go loop
• Hardened parse-progress observer by reordering to read done flag before loading counter,
 ensuring final count is always emitted before breaking
• Strengthened worker fetch_add from Relaxed to Release ordering to establish happens-before
 guarantee with the observer's Acquire loads
• Added detailed comment explaining the synchronization logic and memory ordering guarantees

src/indexer/mod.rs


3. Cargo.lock ⚙️ Configuration changes +0/-0

Sync synapse version to 0.2.2

• Bumped synapse root entry version from 0.2.1 to 0.2.2 to match Cargo.toml
• Ensures --locked CI/release builds pass without version mismatch errors

Cargo.lock


Grey Divider

Qodo Logo

@qodo-code-review

qodo-code-review Bot commented Jun 2, 2026

Copy link
Copy Markdown

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0)

Grey Divider

Great, no issues found!

Qodo reviewed your code and found no material issues that require review

Grey Divider

Qodo Logo

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