Round 1: refactor correctness, UTF-8/determinism, and server ordering (#38, #39, #52, #53, #61, #62)
This commit is contained in:
1 parent
71d13b5fbe
commit
8f5a4fb236
35 files changed
+3637
-320
No files matched your search
@@ -0,0 +1,148 @@
|
||||
<!-- Author: Guoliang Chen, a Senior Digital Design Engineer -->
|
||||
|
||||
# refactor-correctness-r1
|
||||
|
||||
## Goal
|
||||
|
||||
Fix five correctness, panic, and determinism issues in `vlog_refactor`:
|
||||
1. **UTF-8 char-boundary panic in `skip_string` & callers** (`rename/home.rs`, `rename/carry.rs`): advancing past a backslash escape in `"\\é"` or `"\\中"` with `i += 2` lands mid-codepoint and panics subsequent string slices.
|
||||
2. **SipHash nondeterminism and cycle-memoization bug in `carry.rs`**: `HashMap`/`HashSet` iteration order combined with memoizing cycle-tainted `false` results in `Walk::is_binder` (and order-sensitive recursion in `Walk::formals_of`) produces non-deterministic carrier sets for mutually recursive macros.
|
||||
3. **Duplicate-unit member rename ambiguity (`#53`)** (`rename/mod.rs`): `renameable_here` and `Scope::declaration` previously checked `index.units(&name).len() > 1` only for `file_scope` symbols; renaming a member/port/block declared inside a file-scope unit (`module`/`interface`/`package`/`class`/`typedef`) whose unit name appears more than once in `index.units` (matching kind) must refuse unambiguously with `ambiguous(unit_name)`.
|
||||
4. **Cross-module same-file `.port(...)` false body-use hit (`#38`)** (`ports/remove.rs`): `body_uses_in` previously treated all `semantics.references_of(id)` in the file as body uses of the target module, including `.port(...)` connections on instances in another module in the same file.
|
||||
5. **CRLF preservation in `extract` (`#39`)** (`extract/render.rs`, `extract/mod.rs`): preserve `\r\n` vs `\n` from the source file across the extracted module, replacement instantiation, and `\r\n\r\n` same-file insertion.
|
||||
|
||||
## Assumptions
|
||||
|
||||
- `Semantics::file_scope()` owns all units indexed by `WorkspaceIndex::units(name)` (`Module`, `Interface`, `Package`, `Typedef`, `Class`), matching `vlog_semantic/src/workspace/record.rs::is_unit`.
|
||||
- Unit-kind matching treats `Module`/`Interface` (`is_instantiable()`) as sharing the instantiable namespace (matching `ports/find.rs:52`) while keeping `Package`, `Class`, and `Typedef` distinct by `SymbolKind`, so a `package pk` and `module pk` in the same workspace (`top_rooted_paths::qa_f1_*`) are not treated as duplicate declarations of one unit, and two non-duplicated packages `pkg1`/`pkg2` with identically named classes/members remain renameable.
|
||||
- Source files using CRLF consistently contain `\r\n`; mixed line-ending files default to `\r\n` when any `\r\n` is present (matching `rename/layout.rs`), and instantiation line endings are normalized in `extract/render.rs` because `instantiate::InstantiationPlan::render_with` is outside this task's file ownership.
|
||||
|
||||
## Handshakes
|
||||
|
||||
- **`rename/preflight.rs` (`declared_here`)** (implemented in Round 1 Lane 1A QA-fix pass):
|
||||
- Shares `super::enclosing_unit` with `Scope::declaration` (`rename/mod.rs`) so `declared_here` defers (`Ok(())`) before `already_named` whenever `enclosing_unit(semantics, declaration).is_some()` (both file-scope declarations and declarations inside file-scope units). This keeps `rename_preflight` one-directionally consistent with `rename` on duplicate-unit members (`qa_correctness_r1::qa_preflight_same_name_inside_duplicate_unit_matches_rename`). `crates/vlog_refactor/tests/preflight_oracle.rs::renaming_a_symbol_to_the_name_it_already_has_is_refused_from_the_buffer` was updated to test buffer-only `already_named` outside file-scope units (a `$unit` function local) and deferral inside file-scope units (`module sub`).
|
||||
- **`lucisv_server/src/same_file.rs` (`renamed_here`)** (assigned to Lane 1B — untouched here):
|
||||
- `same_file.rs:179-197` treats symbols with `symbol.scope != file_scope()` as eligible for single-file fast-path `prepareRename` when the workspace index is not consulted. Lane 1B owns updating `same_file.rs` for QA finding F2b so single-file `prepareRename` defers members inside file-scope units to match settled `prepare_rename_here`.
|
||||
- **`lucisv_mcp/src/tools/find.rs` (`engine_refusal`)**:
|
||||
- Translates `"which declaration this rename means"` to `"which declaration this position means"`. Reusing `ambiguous(enclosing_unit)` preserves exact parity across `rename::prepare_rename`, `rename::prepare_rename_here`, `Scope::declaration`, and `lucisv_mcp`'s `find_references`.
|
||||
- **`crates/vlog_refactor/tests/qa_rename_implicit.rs` (`qa_a_port_rename_into_a_module_declared_twice_is_refused`)**:
|
||||
- Previously, renaming a port inside duplicated `module leaf` passed `Scope::declaration` and failed downstream in `connections.rs` with ``"`u_leaf` at top.sv:2 connects with `.*` to `leaf`, which lucisv cannot read..."``. With `#53` fixed, `Scope::declaration` now refuses upfront with ``"`leaf` is declared in more than one indexed file; lucisv will not guess which declaration this rename means."``; the test assertion was updated accordingly (while `rename_implicit::a_wildcard_into_a_module_declared_twice_is_refused`, which renames in `top.sv` rather than `leaf.sv`, still exercises the `u_leaf` wildcard refusal unchanged).
|
||||
- **`crates/vlog_refactor/src/instantiate.rs`**:
|
||||
- `InstantiationPlan::render_with` emits `\n`. `extract/render.rs::instantiation` converts emitted `\n` to `\r\n` when the source uses CRLF so `instantiate.rs` stays untouched.
|
||||
|
||||
## Status / TODO
|
||||
|
||||
- [x] Fix UTF-8 char-boundary handling in `rename/home.rs` and `rename/carry.rs`
|
||||
- [x] Replace `HashMap`/`HashSet` and cycle-tainted memoization in `rename/carry.rs` with `BTreeMap`/`BTreeSet` + monotonic fixed-point computation
|
||||
- [x] Refuse renames inside duplicated file-scope units in `rename/mod.rs` (`renameable_here` and `Scope::declaration`)
|
||||
- [x] Filter `ports/remove.rs::body_uses_in` references to `module_span(module)`
|
||||
- [x] Preserve source line endings (`\r\n` vs `\n`) in `extract/render.rs` and `extract/mod.rs`
|
||||
- [x] Add/update regression tests in `crates/vlog_refactor/tests/` and inline unit tests
|
||||
- [x] Fix QA F1 (`ports/remove.rs`, `ports/offer.rs`): pass `find_module`'s full `module ... endmodule` span into `body_uses_in` so empty-body modules check header port default expressions
|
||||
- [x] Fix QA F2a (`rename/preflight.rs`, `rename/mod.rs`): share `enclosing_unit` in `declared_here` so same-name renames inside file-scope units defer to the ambiguity check
|
||||
- [x] Pass formatting, clippy, full test suite, and author-stamp check
|
||||
|
||||
## Work log
|
||||
|
||||
- Changed `rename/home.rs::skip_string` to accept `&str` and step past escaped multi-byte UTF-8 characters (`1 + char::len_utf8`), and guarded string/slice indexing in `home.rs` (`includes_in`, `macro_names`, `skip_string`) and `carry.rs` (`invocations`, `split_arguments`) with `.get(..)` and UTF-8 character stepping.
|
||||
- Changed `carry::Defs`, `Carriers::formals`, and `Carriers::binders` from `HashMap`/`HashSet` to `BTreeMap`/`BTreeSet`; replaced `Walk::is_binder` and `Walk::formals_of` with order-independent monotonic fixed-point loops (`find_binders` least fixed point and `compute_formals` greatest fixed point so cycles remain carried/`true`).
|
||||
- Added `enclosing_unit` and `is_duplicate_unit` in `rename/mod.rs`, shared between `renameable_here` and `Scope::declaration`, refusing members/ports/blocks inside duplicated same-kind file-scope units with `ambiguous(unit)`.
|
||||
- Filtered `ports/remove.rs::body_uses_in` references to `module_span(module)` so `.port(...)` connections in other modules within the same file are ignored.
|
||||
- Threaded `line_ending(text)` (`\r\n` vs `\n`) through `extract/mod.rs` (`ensure_newline`, `module_text`, `instantiation`, and `{eol}{eol}{module_text}` same-file insertion) and `extract/render.rs` (`new_module`, `instantiation`).
|
||||
- Added regression unit and integration tests in `rename/home.rs`, `rename/carry.rs`, `tests/rename_macro_carry.rs`, `tests/rename.rs`, `tests/ports.rs`, and `tests/extract.rs`, and updated `tests/qa_rename_implicit.rs`.
|
||||
- Production non-blank non-comment line counts (`<= 600` limit):
|
||||
- `crates/vlog_refactor/src/rename/home.rs`: 211 lines
|
||||
- `crates/vlog_refactor/src/rename/carry.rs`: 233 lines
|
||||
- `crates/vlog_refactor/src/rename/mod.rs`: 495 lines
|
||||
- `crates/vlog_refactor/src/ports/remove.rs`: 288 lines
|
||||
- `crates/vlog_refactor/src/extract/render.rs`: 322 lines
|
||||
- `crates/vlog_refactor/src/extract/mod.rs`: 409 lines
|
||||
|
||||
### 2026-11-26 — Round 1 Lane 1A QA-fix pass (F1 & F2a)
|
||||
|
||||
- **QA F1 (`crates/vlog_refactor/src/ports/remove.rs`, `crates/vlog_refactor/src/ports/offer.rs`)**: Removed `module_span(module)` and updated `body_uses_in` to take `module_range: TextRange` directly from `find_module`'s `item.span` (which covers the entire `module ... endmodule` declaration including header ports and default expressions while excluding sibling modules in the same file). Updated both `plan_remove` (`ports/remove.rs`) and `removal` (`ports/offer.rs`) to pass that range.
|
||||
- **QA F2a (`crates/vlog_refactor/src/rename/mod.rs`, `crates/vlog_refactor/src/rename/preflight.rs`)**: Promoted `enclosing_unit` to `pub(super) fn` in `rename/mod.rs` and updated `declared_here` in `rename/preflight.rs` to defer (`Ok(())`) whenever `enclosing_unit(semantics, declaration).is_some()`, matching `Scope::declaration`'s ambiguity-before-`already_named` ordering without duplicating logic.
|
||||
- Updated `crates/vlog_refactor/tests/preflight_oracle.rs::renaming_a_symbol_to_the_name_it_already_has_is_refused_from_the_buffer` to verify `already_named` still refuses from buffer outside file-scope units (`$unit` function local) and defers for declarations inside file-scope units (`module sub`).
|
||||
- Un-ignored and expanded `crates/vlog_refactor/tests/qa_correctness_r1.rs::qa_remove_port_empty_body_module_with_default_expr_using_removed_port` and `qa_preflight_same_name_inside_duplicate_unit_matches_rename`.
|
||||
- Updated production non-blank non-comment line counts (`<= 600` limit):
|
||||
- `crates/vlog_refactor/src/rename/home.rs`: 211 lines
|
||||
- `crates/vlog_refactor/src/rename/carry.rs`: 233 lines
|
||||
- `crates/vlog_refactor/src/rename/mod.rs`: 495 lines
|
||||
- `crates/vlog_refactor/src/rename/preflight.rs`: 33 lines
|
||||
- `crates/vlog_refactor/src/ports/remove.rs`: 283 lines
|
||||
- `crates/vlog_refactor/src/ports/offer.rs`: 286 lines
|
||||
- `crates/vlog_refactor/src/extract/render.rs`: 322 lines
|
||||
- `crates/vlog_refactor/src/extract/mod.rs`: 409 lines
|
||||
|
||||
## QA log
|
||||
|
||||
### 2026-11-26 — QA agent: FAIL — core fixes 1/2/5 hold, two concrete findings on #38 (`module_span`) and #53 (`preflight` / `same_file` handshakes)
|
||||
|
||||
**Verdict: FAIL.** Two concrete findings (F1 inside owned `ports/remove.rs`, F2 in the `#53` handshakes noted as untouched by DEV). Fixes 1 (UTF-8 `skip_string`), 2 (`carry.rs` determinism), and 5 (`extract` CRLF) survived every adversarial attack.
|
||||
|
||||
#### Findings
|
||||
|
||||
- **F1 (BLOCKING — `crates/vlog_refactor/src/ports/remove.rs:248-251`):** `module_span(module)` computes `end = module.items.last().map_or(module.name_span.end, |item| item.span.end)` and returns `TextRange::new(module.name_span.start, end.max(module.name_span.end))`. When `module.items` is empty (e.g., `module leaf (\n input logic a,\n input logic b = a\n);\nendmodule\n`), `module_span` covers only `leaf` (`name_span`), excluding the port header. As a result, `body_uses_in` (`ports/remove.rs:223-227`) fails to find port `a` (`module_range.contains(s.name_span.start)` is `false`) and returns `Vec::new()`:
|
||||
- `port_offers` (`crates/vlog_refactor/src/ports/offer.rs:302`) falsely offers `"lucisv: remove port `a` (no instantiation in scope)"` despite `b = a` using `a`.
|
||||
- `remove_port` bypasses the `"is still used inside ..."` refusal and fails later in `verify_splice` with `"removing port `a` from `leaf` would change what `a` means in leaf.sv; no edits were made."` instead of ``"`a` is still used inside `leaf` at leaf.sv:3; remove those uses first."``.
|
||||
- Reproduction: `crates/vlog_refactor/tests/qa_correctness_r1.rs::qa_remove_port_empty_body_module_with_default_expr_using_removed_port` (`#[ignore = "QA finding 1..."]`; `find_module` at `ports/find.rs:95` already returns the full `item.span` covering `module ... endmodule`, which `ports/remove.rs:99` and `ports/offer.rs:298` currently discard).
|
||||
|
||||
- **F2 (BLOCKING — `#53` parity breaks in `crates/vlog_refactor/src/rename/preflight.rs:79-81` and `crates/lucisv_server/src/same_file.rs:196`):** Both files were left untouched by DEV under strict file ownership and documented in `## Handshakes`, but `#53` breaks their invariants with concrete user-visible mismatches:
|
||||
- **F2a (`crates/vlog_refactor/src/rename/preflight.rs:79-81`):** `declared_here` only skips `already_named` when `declaration.scope == semantics.file_scope()`. With `Scope::declaration` now rejecting members inside duplicated file-scope units before `already_named`, renaming a member `sig` to `"sig"` inside duplicated `module dup` returns `Err("`sig` is the name it already has.")` from `rename_preflight` while `rename` returns `Err("`dup` is declared in more than one indexed file; lucisv will not guess which declaration this rename means.")`. Since `crates/lucisv_server/src/rename.rs:85` calls `rename_preflight` first, the LSP server returns the wrong refusal.
|
||||
- Reproduction: `crates/vlog_refactor/tests/qa_correctness_r1.rs::qa_preflight_same_name_inside_duplicate_unit_matches_rename` (`#[ignore = "QA finding 2..."]`).
|
||||
- **F2b (`crates/lucisv_server/src/same_file.rs:196`):** `renamed_here` only defers to the workspace index when `symbol.scope == doc.semantics.file_scope()`. With `prepare_rename_here` now reading `index.units(...)` for members inside file-scope units, an early/mid-scan `textDocument/prepareRename` (`ahead.rs`) on `logic d;` in `dup_b.sv` (`module dup; logic d; endmodule`) answers `Ok({"placeholder": "d", ...})` while the settled server refuses with `"lucisv: `dup` is declared in more than one indexed file; lucisv will not guess which declaration this rename means."`.
|
||||
- Reproduction: Adding `"dup_b.sv"` (already written in `shapes` at `crates/lucisv_server/src/server/tests/fast_actions_differential.rs:245`) to the loop at line 272 fails `early_answers_equal_settled_over_the_locality_shapes` with `differed=3` on `dup_b.sv` line 1 cols 8–9 (`lucisv_server` was immediately reverted so no unowned files remain modified).
|
||||
|
||||
#### Verification Summary
|
||||
|
||||
- **Diff / Ownership / Standards:**
|
||||
- Modified/added files confined to `crates/vlog_refactor/` (6 prod files, 5 existing test files, new `tests/qa_correctness_r1.rs`) and `docs/features/refactor-correctness-r1/README.md`.
|
||||
- Production non-blank, non-comment line counts before `mod tests`: `home.rs` 211, `carry.rs` 233, `rename/mod.rs` 495, `ports/remove.rs` 288, `extract/render.rs` 322, `extract/mod.rs` 409 (all `<= 600`).
|
||||
- Zero `unwrap()`, `expect()`, `panic!`, or `unsafe` in modified production code.
|
||||
- `python3 tools/stamp_author.py --check`: pass (`would stamp 0 files; left 249 untouched`).
|
||||
- **Adversarial Checks (`crates/vlog_refactor/src/rename/{home,carry}.rs` + `crates/vlog_refactor/tests/qa_correctness_r1.rs`):**
|
||||
- UTF-8 `skip_string` (`home.rs`, `carry.rs`): tested `"\\\\"`, `"\\\\\\"`, `"\\é"`, `"\\🚀"`, `"\\` at EOF, multi-line strings in `invocations`/`split_arguments`, and non-ASCII comments/identifiers near strings — all passed without panic.
|
||||
- Determinism (`carry.rs`): tested 3-cycles (`M1 -> M2 -> M3 -> M1` with binder and cross-position forwarding), reversed key names (`Z3/Z2/Z1`), and reversed definition order across 10 iterations — identical deterministic carrier/warning behavior.
|
||||
- Duplicate-unit member rename (`rename/mod.rs`): same-named `module m` + `package m` do not collide; two `interface bus_if` files refuse ports/signals/modports; `module bus` + `interface bus` collide; nested `generate`/`for`/`if` inside `dup` refuses; non-duplicated `unique_m` in the same file renames cleanly; duplicate file-scope `typedef struct` and `class` refuse; byte-for-byte `prepare_rename` vs `prepare_rename_here` parity holds on `mixed.sv`.
|
||||
- `#38` (`ports/remove.rs`): same-file `.p(sig)` in another module + body use of `p` still refuses; same-file positional refuses; same-file `.*` warns; non-ANSI port and nested same-named port succeed; **fails** F1 on empty-body module with `b = a` port default.
|
||||
- `#39` (`extract/render.rs`, `extract/mod.rs`): CRLF with imports + params + ports + `//` and `/* */` comments + no trailing EOL (`SameFile` & `NewFile`) and zero-port/zero-param CRLF emit zero bare `\n`; LF control emits zero `\r`.
|
||||
- **Gates (post-final-edit):**
|
||||
- `cargo fmt -p vlog_refactor -- --check`: pass.
|
||||
- `./tools/guard.sh -m 6 -t 600 -- cargo clippy -p vlog_refactor -p lucisv_server -p lucisv_mcp --all-targets -- -D warnings`: pass.
|
||||
- `./tools/guard.sh -m 6 -t 600 -- cargo test -p vlog_refactor --all-targets`: pass (`qa_correctness_r1`: 7 passed, 0 failed, 2 ignored for F1/F2a; full `vlog_refactor` suite green).
|
||||
- `./tools/guard.sh -m 6 -t 600 -- cargo test -p lucisv_mcp --all-targets`: pass.
|
||||
- `./tools/guard.sh -m 6 -t 600 -- cargo test -p lucisv_server --all-targets`: pass.
|
||||
|
||||
### 2026-11-26 — QA re-check (post DEV fix pass): PASS (Lane 1A F1 & F2a resolved; F2b remains with Lane 1B)
|
||||
|
||||
**Verdict: PASS.** Re-verified Round 1, Lane 1A after the DEV fix pass. Both Lane 1A findings (**F1** in `ports/remove.rs` & `ports/offer.rs`, **F2a** in `rename/preflight.rs` & `rename/mod.rs`) are fixed and survived expanded adversarial attacks; **F2b** (`crates/lucisv_server/src/same_file.rs`) remains tracked under Lane 1B per `## Handshakes`.
|
||||
|
||||
#### Re-Verification Summary
|
||||
|
||||
- **Diff / Ownership / Standards:**
|
||||
- `git status` / `git diff`: only `crates/vlog_refactor/` (8 modified prod files, 6 modified test files, `tests/qa_correctness_r1.rs`) and `docs/features/refactor-correctness-r1/README.md` are modified/untracked.
|
||||
- Non-blank, non-comment prod lines before `mod tests` (`<= 600`): `extract/mod.rs` 409, `extract/render.rs` 322, `ports/offer.rs` 286, `ports/remove.rs` 283, `rename/carry.rs` 234, `rename/home.rs` 212, `rename/mod.rs` 495, `rename/preflight.rs` 33.
|
||||
- Zero `unwrap()`, `expect()`, `panic!`, or `unsafe` in modified production code.
|
||||
- `python3 tools/stamp_author.py --check`: exit 0 (`would stamp 0 files; left 249 untouched`).
|
||||
- **F1 Attack (`crates/vlog_refactor/src/ports/{remove,offer}.rs`):**
|
||||
- `qa_correctness_r1::qa_remove_port_empty_body_module_with_default_expr_using_removed_port` runs un-ignored and passes.
|
||||
- Added `qa_correctness_r1::qa_remove_port_non_ansi_param_default_and_sibling_before_target_edge_cases`: passes across sibling `module top (input logic a)` placed before `leaf` with parameter defaults `P = 8, Q = P + 1` and `b = a` (refuses `a` in `remove_port` & empty `port_offers`, offers & removes `b` while ignoring sibling `.b(y)` in body checks), non-ANSI `(a, b); input logic a; input logic b = a;` + sibling `.a(x), .b(y)`, shared non-ANSI `input logic a, b;` with `port_offers` (`PortOfferKind::Remove`), and sibling parameter `a` alongside target parameter default `Q = P`.
|
||||
- **F2a Attack (`crates/vlog_refactor/src/rename/{preflight,mod}.rs`):**
|
||||
- `qa_correctness_r1::qa_preflight_same_name_inside_duplicate_unit_matches_rename` runs un-ignored and passes; all 11 tests in `tests/preflight_oracle.rs` pass.
|
||||
- Added `qa_correctness_r1::qa_preflight_parity_sweep_unit_local_vs_duplicate_module_nested_members`: passes for `$unit` function local/arg renamed to itself (immediate `already_named`), duplicated `module dup` nested `generate`/`function`/`class` members renamed to themselves (`rename_preflight` defers with `Ok(())` to `ambiguous("dup")`), and full byte-by-byte parity sweeps for `prepare_rename` vs `prepare_rename_here` and `rename_preflight` vs `rename` on both shapes.
|
||||
- **Guarded Gates (post-final-code-edit):**
|
||||
- `cargo fmt -p vlog_refactor -- --check`: pass.
|
||||
- `./tools/guard.sh -m 6 -t 600 -- cargo clippy -p vlog_refactor -p lucisv_server -p lucisv_mcp --all-targets -- -D warnings`: pass (0 warnings in crates).
|
||||
- `./tools/guard.sh -m 6 -t 600 -- cargo test -p vlog_refactor --all-targets`: pass (`qa_correctness_r1`: 11 passed, 0 failed, 0 ignored; `preflight_oracle`: 11 passed, 0 failed; total 765 passed, 0 failed, 6 pre-existing ignored across `corpus`/`opentitan_top_rooted`/`qa_rename_implicit`/`rename_bind`).
|
||||
- `./tools/guard.sh -m 6 -t 600 -- cargo test -p lucisv_mcp --all-targets`: pass (388 passed, 0 failed, 4 pre-existing ignored).
|
||||
- `./tools/guard.sh -m 6 -t 600 -- cargo test -p lucisv_server --all-targets`: pass (2139 passed, 0 failed, 52 pre-existing ignored).
|
||||
|
||||
## Review
|
||||
|
||||
### 2026-11-26 — Lead review: PASS (merged with Lane 1B in Round 1)
|
||||
|
||||
- Inspected combined diff across `vlog_refactor` and `lucisv_server`; cross-lane handshake F2b (`same_file::renamed_here` + `dup_b.sv` differential check) landed cleanly in Lane 1B and passes together with Lane 1A on trunk.
|
||||
- Removed stray duplicate `// Author:` line at line 3 of this README.
|
||||
- Handshakes closed in `docs/topo.md`: `#38`, `#39`, `#53` (engine half). Full `tools/gates.sh` verified green on merged `master`.
|
||||
|
||||
<!-- Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com -->
|
||||
@@ -0,0 +1,137 @@
|
||||
<!-- Author: Guoliang Chen, a Senior Digital Design Engineer -->
|
||||
|
||||
# Server Ordering, Versioned Edits, and Startup Race Fixes (Round 1)
|
||||
|
||||
## Goal
|
||||
|
||||
Close four ordering and protocol-soundness bugs identified in `docs/topo.md` (`#53`, `#52`, `#61`, `#62`):
|
||||
|
||||
1. **Topo #53 (Startup scan race for workspace-wide mutating requests)**: Hold `textDocument/rename`, `codeAction/resolve`, `workspace/executeCommand`, and `workspace/willRenameFiles` until an active background scan (`self.scanning == true`) finishes completely rather than letting them run mid-scan once `head_owed` clears, while preserving read-only `same_file` fast-action early answers and avoiding O(N) re-drain spinning across scan publishes.
|
||||
2. **Topo #52 (Versioned `DocumentChanges` edits)**: Track client-announced `i32` buffer versions across `didOpen`, `didChange`, dirty flushes, `didSave`, `didClose`, and large-file reclassification; detect `workspace.workspaceEdit.documentChanges` in `ClientAbilities`; and emit deterministic, sorted `DocumentChanges::Edits` (`OptionalVersionedTextDocumentIdentifier { uri, version }`) in `rename.rs` and `ports.rs`, falling back to `WorkspaceEdit { changes: Some(...), .. }` when unsupported or when no edited buffer carries a version.
|
||||
3. **Topo #61 (Stale `didChangeConfiguration` replay during staging)**: When `take_the_answer_out_of_held` plucks a pulled `Pending::Configuration` response during startup staging, drop any older `workspace/didChangeConfiguration` notifications sitting earlier in `self.held` so they cannot replay after staging ends and overwrite newer pulled settings, while retaining any pushes that arrived after the pull response.
|
||||
4. **Topo #62 (Exact state-index oracle in `fast_actions_bursts`)**: Record the server's exact `applied_changes` counter whenever `answered_ahead` emits an early response and assert in `fast_actions_bursts.rs` both `applied >= required` (no skipped affecting state change) and `e == reference_at[applied]` against the single-message reference stream.
|
||||
|
||||
## Assumptions
|
||||
|
||||
- Read-only requests exempted via `same_file` / `viewport` (`answer_from_the_buffer`) remain eligible mid-scan whenever their own preconditions hold; only whole-workspace mutating requests (`textDocument/rename`, `codeAction/resolve`, `workspace/executeCommand`, `workspace/willRenameFiles`) must wait for `self.scanning == false`.
|
||||
- Unopened on-disk files touched alongside an open versioned buffer in `DocumentChanges::Edits` carry `OptionalVersionedTextDocumentIdentifier { uri, version: None }`, matching LSP 3.16+ semantics (and existing `extract.rs` conventions). When no edited file has an attached version (for instance, direct workspace unit tests or closed-file commands) or when `document_changes` capability is false, `WorkspaceEdit::new(changes)` is used.
|
||||
|
||||
## Handshakes
|
||||
|
||||
- **`crates/lucisv_server/src/server/index.rs` (`waiting_for_this_scan`)**: Untouched per lane file ownership. Whole-scan mutators arriving during `self.scanning == true` are staged into `Server::after_scan` in `server/mod.rs` (checked alongside `held` in `must_wait`, `must_hold`, `ahead.rs::nothing_unapplied_for`, `ahead.rs::answer_ahead_mid_widen`, `Server::run`, and `server/tests/scan_ordering.rs::settle`) so `waiting_for_this_scan` does not re-drain and re-hold them on each intermediate scan file. A follow-up lane can fold `after_scan` into `index.rs` if desired.
|
||||
- **`crates/lucisv_server/src/server/probe.rs` (`went_ahead`)**: Untouched per lane file ownership. Exact `applied_changes` recording at `answered_ahead` lives in `#[cfg(test)]` `server/ahead.rs::AHEAD_APPLIED` (`take_ahead_applied()`) paired with `#[cfg(test)] Server::applied_changes` incremented in `server/mod.rs`, `server/startup.rs`, and `server/notification.rs`. A follow-up lane can fold `AHEAD_APPLIED` into `probe::Probe`.
|
||||
- **`crates/lucisv_server/src/state/buffers.rs` / `server/diagnostics.rs` / `server/large_file.rs`**: Untouched per lane file ownership. Because `Workspace::set_document` rebuilds `Document` without a version parameter, `Server::versions: HashMap<Uri, i32>` and `Server::sync_document_versions()` re-attach versions after dirty flushes, `didSave(text)`, `apply_settings`, and `take_the_answer_out_of_held`.
|
||||
- **Remaining `WorkspaceEdit` producers (`imports.rs`, `instantiate.rs`, `extract.rs`, `inline_module.rs`, `code_action.rs`, `file_ops.rs`)**: Untouched beyond lane ownership. `rename.rs` and `ports.rs` now share `ports::encode_edit` and honor `ClientAbilities::document_changes`; follow-up lanes can pass `self.abilities.document_changes` and document versions to `imports`, `instantiate`, `extract`, `inline_module`, `code_action`, and `file_ops::will_rename`.
|
||||
- **Cross-lane handshake F2b (`crates/lucisv_server/src/same_file.rs` + `server/tests/fast_actions_differential.rs`)**: Lane 1A fixed `#53` in `vlog_refactor::prepare_rename_here` to check `index.units(enclosing_unit)` for symbols inside a file-scope unit (`Module`/`Interface`/`Package`/`Typedef`/`Class`), not only `scope == file_scope`. Updated `same_file::renamed_here` to walk `Semantics` parent scopes up to `file_scope` and defer (`false`) whenever the symbol sits inside a file-scope unit, updated `same_file/tests.rs`, and added `"dup_b.sv"` to `fast_actions_differential::early_answers_equal_settled_over_the_locality_shapes` (passes both before and after Lane 1A merges).
|
||||
|
||||
## Status / TODO
|
||||
|
||||
- [x] Topo #53: Hold workspace-wide mutating requests across `self.scanning` via `after_scan` + `waits_for_whole_scan`.
|
||||
- [x] Topo #52: Track `Document::version` atomically, parse `workspace.workspaceEdit.documentChanges`, and emit `DocumentChanges::Edits` in `rename.rs` and `ports.rs` via shared `ports::encode_edit` (including non-canonical client URIs and immediate version sync after `flush_dirty` / `flush_buffer`).
|
||||
- [x] Topo #61: Drain superseded `workspace/didChangeConfiguration` notifications preceding plucked `Pending::Configuration` answers in `take_the_answer_out_of_held`.
|
||||
- [x] Topo #62: Record exact `applied_changes` on early answers and tighten `fast_actions_bursts.rs` oracle to exact state equality (`e == reference_at[applied]` and `applied >= required`).
|
||||
- [x] Cross-lane F2b: Align `same_file::renamed_here` with `vlog_refactor::prepare_rename_here` for symbols enclosed by file-scope units and cover `"dup_b.sv"` in `fast_actions_differential.rs`.
|
||||
- [x] Add regression suite `crates/lucisv_server/src/server/tests/ordering_r1.rs` plus unit tests in `main.rs`, `rename.rs`, and `ports.rs`.
|
||||
|
||||
## Work log
|
||||
|
||||
- Added `AtomicI64` buffer `version` storage (`version()`, `set_version()`) on `Document` in `crates/lucisv_server/src/state/document.rs` without changing `Document: Sync` or existing constructors.
|
||||
- Added `document_changes_support` in `crates/lucisv_server/src/main.rs` and `ClientAbilities::document_changes` in `crates/lucisv_server/src/server/mod.rs`.
|
||||
- Added `Server::after_scan`, `Server::versions`, `must_wait_for`, `waits_for_whole_scan`, and `sync_document_versions` in `crates/lucisv_server/src/server/mod.rs`, updating `Server::run`, `process_batch`, `hold`, and `must_hold`.
|
||||
- Updated `crates/lucisv_server/src/server/startup.rs` (`take_the_answer_out_of_held`) to drain older `DidChangeConfiguration` notifications prior to the last plucked `Pending::Configuration` response while keeping newer pushes intact; updated `crates/lucisv_server/src/server/tests/fast_actions_precondition.rs::what_staging_held_behind_a_push_is_not_released_ahead_of_it` so its test `push(1000)` arrives after `settings_answer(0)` rather than relying on the pre-#61 stale-replay bug.
|
||||
- Updated `crates/lucisv_server/src/server/notification.rs` and `crates/lucisv_server/src/server/dispatch.rs` to record/sync document versions and dispatch `document_changes` capability to `rename::rename_traced_for` and `ports::{code_actions_for, resolve_for, execute_for}`.
|
||||
- Extracted shared `ports::encode_edit` helper used by both `ports.rs` and `rename.rs`.
|
||||
- Tightened `crates/lucisv_server/src/server/tests/fast_actions_bursts.rs` with `ahead::take_ahead_applied()` and `applied >= required` + exact state equality, and added regression tests in `crates/lucisv_server/src/server/tests/ordering_r1.rs`, `rename.rs`, `ports.rs`, and `main.rs`.
|
||||
|
||||
### 2026-11-26 — QA fix pass + F2b handshake
|
||||
|
||||
- **QA F1 (`crates/lucisv_server/src/ports.rs::encode_edit`)**: Matched open documents via `ws.open_documents()` (`doc.path.as_deref() == Some(path)`) instead of canonical `path_to_uri(path)` + `ws.document(&target)`, preserving the client's open URI (`file://localhost/...`, lowercase percent-encoding, etc.) and `doc.version()` across both `DocumentChanges::Edits` and unversioned `changes` maps. Added unit and integration tests in `ports.rs` and `ordering_r1.rs`.
|
||||
- **QA F2 (`crates/lucisv_server/src/server/{notification,ahead}.rs`)**: Added `self.sync_document_versions()` immediately after `self.flush_dirty()` in `notification.rs` and `self.flush_buffer(&uri)` in `ahead.rs` so `Document::version()` remains `Some(v)` immediately after `didSave(text: None)`, `didClose(other)`, `didChangeWatchedFiles`, or mid-scan buffer flushes. Added regression test `qa_f2_document_version_survives_flush_dirty_and_flush_buffer_immediately` in `ordering_r1.rs`.
|
||||
- **Cross-lane F2b (`crates/lucisv_server/src/same_file.rs`, `same_file/tests.rs`, `server/tests/fast_actions_differential.rs`)**: Updated `same_file::renamed_here` with `enclosed_by_unit` so `textDocument/prepareRename` defers (`false`) for symbols inside file-scope units (`Module`, `Interface`, `Package`, `Typedef`, `Class`), updated `same_file/tests.rs`, and added `"dup_b.sv"` to `early_answers_equal_settled_over_the_locality_shapes` in `fast_actions_differential.rs`.
|
||||
|
||||
## QA log
|
||||
|
||||
### 2026-11-26 — QA agent (Round 1, Lane 1B)
|
||||
|
||||
**Verdict: FAIL** (two concrete Topo #52 bugs found; Topo #53, Topo #61, and Topo #62 passed all adversarial checks and live OpenTitan probing).
|
||||
|
||||
#### Ownership, hygiene, and size checks
|
||||
|
||||
- **File ownership (`git status` / `git diff --stat`)**: All DEV changes are inside the lane's allowed files (`main.rs`, `ports.rs`, `rename.rs`, `server/{mod,startup,dispatch,notification,ahead}.rs`, `state/document.rs`, `server/tests/{mod,fast_actions_bursts,fast_actions_precondition,scan_ordering,ordering_r1}.rs`, `docs/features/server-ordering-r1/README.md`). QA added 5 passing adversarial regression tests in `crates/lucisv_server/src/server/tests/ordering_r1.rs` (`qa_topo_53_*`, `qa_topo_52_full_version_lifecycle_*`, `qa_topo_61_attack_burst_*`).
|
||||
- **Production line counts (non-blank, non-comment lines before `mod tests {`)**: All modified production files are `<= 600` lines (`dispatch.rs`: 522, `main.rs`: 400, `ports.rs`: 367, `server/mod.rs`: 311, `notification.rs`: 261, `ahead.rs`: 250, `startup.rs`: 192, `state/document.rs`: 135, `rename.rs`: 88).
|
||||
- **Safety / author stamps**: `0` occurrences of `unwrap(`, `expect(`, `panic!`, or `unsafe` in modified production code. `python3 tools/stamp_author.py --check` exits `0`.
|
||||
|
||||
#### Verification & adversarial attacks
|
||||
|
||||
1. **Topo #53 (`after_scan` & `waits_for_whole_scan`) — PASS**:
|
||||
- Inspected `Server::hold`, `must_wait`, `must_wait_for`, `must_hold`, `after_scan` drain in `Server::run`, `waiting_for_this_scan`, `nothing_unapplied_for`, and `answer_ahead_mid_widen`. `held` and `after_scan` remain mutually exclusive across `hold`, `answer_ahead_mid_widen`, and `run`, preserving arrival order on nested `process_batch` scans and avoiding O(N) re-drain spinning (`handed_back <= 1`).
|
||||
- Added and passed QA tests in `ordering_r1.rs` covering: `$/cancelRequest` arriving in a later burst while `rename` sits in `after_scan`; `$/cancelRequest` in the same burst as `rename` while `head_owed == true` (transitioning `held -> after_scan`); incremental `didChange` behind `rename` in `after_scan` followed by a second incremental `didChange` and mid-scan `didSave` (`rescan_wanted = true`, two scan `end`s before `after_scan` drains).
|
||||
- **Live OpenTitan 10-spawn probe** (`./tools/guard.sh -m 6 -t 600 -- cargo build --release -p lucisv_server` -> `target/release/lucisv-server --verbose` against `/Users/lucio/repo/opentitan`, `hw/top_englishbreakfast/ip/ast/rtl/adc.sv` line 81 col 42 `rst_adc_ni`, workspace scope with `persist: false` and scratch `/tmp` storage dirs): 5 startup-burst spawns + 5 mid-scan `$/progress` `report` spawns (`4044 files`) all logged `textDocument/rename HELD behind a rescan`, answered strictly after `$/progress` `end`, exited `0`, and returned **10/10 identical** deterministic refusal (`code: -32803`, ``"lucisv: `rst_adc_ni` is declared in more than one indexed file; lucisv will not guess which declaration this rename means."``). `git -C /Users/lucio/repo/opentitan status --porcelain` remained empty.
|
||||
|
||||
2. **Topo #52 (versioned `documentChanges`) — FAIL (2 findings)**:
|
||||
- Passing lifecycle checks (`qa_topo_52_full_version_lifecycle_open_change_save_empty_change_rename_and_overlay` + `topo_52_session_tracks_versions_and_emits_versioned_document_changes`): `didOpen(v=1)` -> `didChange(v=2)` -> `didSave(None)` -> `didChange(v=3, contentChanges=[])` -> `watched` (`Document::refresh_overlay`) -> `rename` (mixed `Some(3)` and `None`, `changes` fallback when `document_changes=false`), eager `codeAction`, `codeAction/resolve`, `executeCommand` (`workspace/applyEdit`), `largeFile.threshold` reclassification, and `didClose` resetting version to `None` all pass for canonical `file:///` URIs.
|
||||
- **Finding 1 (Medium/High — wire bug): `crates/lucisv_server/src/ports.rs:555-571` (`encode_edit`) drops document versions and emits unversioned `changes` (or `version: None`) for valid non-canonical `file:` URIs.**
|
||||
- At `ports.rs:555`, `ws.text_of(path)` resolves open buffers via `d.path.as_deref() == Some(path)` (`state/buffers.rs:103`), whereas `ports.rs:570` computes `target = path_to_uri(path)` and looks up `ws.document(&target).and_then(Document::version)`.
|
||||
- Whenever the client opened the file with a valid `file:` URI whose serialization differs from `path_to_uri(path)` — e.g. `file://localhost/...` (explicitly supported by `uri.rs:38`), lowercase percent-encoding such as `caf%c3%a9.sv` vs `path_to_uri`'s `%C3%A9`, or Windows VS Code's `file:///c%3A/...` vs `file:///C:/...` — `ws.document(&target)` returns `None`, silently losing the buffer's version (`Some(v)` -> `None`) and falling back to unversioned `changes` (and `target` also fails to echo the client's open URI).
|
||||
- **Reproduction**: Open `caf%c3%a9.sv` (or `file://localhost/<tree>/sub.sv`) at `version: 12` with `ClientAbilities { document_changes: true, ..Default::default() }`, then issue `textDocument/rename` on it (or cross-file from `top.sv`). `rename` returns `{"changes": ...}` (or `version: null` for `sub.sv` in cross-file `documentChanges`) instead of `documentChanges` with `version: 12`.
|
||||
- **Finding 2 (Low/Medium — state invariant leak): `crates/lucisv_server/src/server/notification.rs:71` (`handle_notification` `flush_dirty`) and `crates/lucisv_server/src/server/ahead.rs:195` (`flush_buffer`) rebuild `Document` without re-attaching `self.versions`.**
|
||||
- `notification.rs:71` runs `self.flush_dirty()` on non-`didChange` notifications such as `didSave` with `text: None` (the default because `main.rs:221` advertises `include_text: Some(false)`), `didClose` of another file, or `didChangeWatchedFiles`. `flush_dirty()` calls `set_document`, replacing the `Document` with `version = NO_VERSION` (`None`). Only `didSave(Some(text))` (`notification.rs:167`) and `apply_settings` (`notification.rs:366`) call `self.sync_document_versions()`. Similarly `ahead.rs:195` (`flush_buffer`) does not sync versions.
|
||||
- Currently masked on LSP wire requests because `dispatch.rs:172` (`answer_request`) calls `self.sync_document_versions()` before `answer_flushed`, but `Document::version()` on `Workspace` is `None` immediately after `didSave(None)` until the next request or debounce timeout.
|
||||
- **Reproduction**: `didOpen(uri, v=1)` -> `didChange(uri, v=2, text)` -> `didSave(uri)` (no `text` field). Immediately inspecting `session.server.workspace.document(&uri).unwrap().version()` returns `None` instead of `Some(2)`.
|
||||
|
||||
3. **Topo #61 (`take_the_answer_out_of_held`) — PASS**:
|
||||
- Tested attack burst `[didOpen, (optional lens), push(A: threshold=0), hover, settings_answer(B: threshold=100), push(C: threshold=4MiB)]` in `qa_topo_61_attack_burst_didopen_push_a_hover_answer_b_push_c`: `B` beats `A` (`hover` sees threshold=100 -> `Null`), `hover` is not dropped, `C` beats `B` once `held` drains (`threshold=4MiB`), and `applied_changes` matches exact applied state transitions (`2`/`3` at staging end, `+1` after `push(C)`).
|
||||
|
||||
4. **Topo #62 (`fast_actions_bursts`) — PASS**:
|
||||
- Inspected `fast_actions_bursts.rs:403-511`: `ahead_applied` records `self.applied_changes` at `answered_ahead` (`ahead.rs:237`) and asserts both `applied >= required` (prior reaching `can_reach` or config changes) and `e == reference_at[applied]`.
|
||||
- Ran `fast_actions_bursts` (`1448 requests, 384 answered ahead (0 from a later state), 1280 settled comparisons`), 300-round `answers_given_ahead_equal_a_one_message_at_a_time_server_long_run` (`seed 7: 1313 requests, 400 answered ahead (0 from a later state), 1200 settled comparisons, 0 differ`), and `ordering_random` (`12 seeds × 10 rounds`, pass).
|
||||
- Verified oracle sensitivity via temporary mutations (reverted immediately): subtracting 1 from `applied` failed immediately at `seed 1, round 0` (`6 answered at applied=1 ahead of reaching change 2`), and skipping `self.flush_buffer(&uri)` in `ahead.rs:195` failed at `seed 2, round 5` (`28 went ahead at applied=4 (required >= 4) with wrong state`).
|
||||
|
||||
#### Full crate gates (worktree, after final edits)
|
||||
|
||||
- `python3 tools/stamp_author.py --check` -> exit 0
|
||||
- `cargo fmt -p lucisv_server -- --check` -> exit 0
|
||||
- `./tools/guard.sh -m 6 -t 600 -- cargo clippy -p lucisv_server --all-targets -- -D warnings` -> exit 0
|
||||
- `./tools/guard.sh -m 6 -t 600 -- cargo test -p lucisv_server --all-targets` -> `2,043` passed (`47` ignored) unit + `106` passed (`3` ignored) e2e + `3` grammar + `1` ifdef_folding + `0` passed (`2` ignored) opentitan_references; `0` failed
|
||||
|
||||
### 2026-11-26 — QA re-check (Round 1, Lane 1B)
|
||||
|
||||
**Verdict: PASS** (F1, F2, and cross-lane F2b all verified fixed; full crate gates green).
|
||||
|
||||
#### Ownership, hygiene, and size checks
|
||||
|
||||
- **File ownership (`git status` / `git diff --stat`)**: Only owned `crates/lucisv_server/` files (`main.rs`, `ports.rs`, `rename.rs`, `same_file.rs`, `same_file/tests.rs`, `server/{mod,startup,dispatch,notification,ahead}.rs`, `state/document.rs`, `server/tests/{mod,fast_actions_bursts,fast_actions_differential,fast_actions_precondition,ordering_r1,scan_ordering}.rs`) and `docs/features/server-ordering-r1/README.md` are modified or untracked. QA added 2 passing re-check regression tests (`qa_r2_f1_*`, `qa_r2_f2_*`) in `crates/lucisv_server/src/server/tests/ordering_r1.rs`.
|
||||
- **Production line counts (non-blank, non-comment before inline `mod tests {`)**: All modified production files remain `<= 600` lines (`dispatch.rs`: 522, `main.rs`: 400, `ports.rs`: 374, `server/mod.rs`: 311, `notification.rs`: 262, `ahead.rs`: 251, `startup.rs`: 192, `state/document.rs`: 134, `same_file.rs`: 126, `rename.rs`: 88).
|
||||
- **Safety / author stamps**: `0` occurrences of `unwrap(`, `expect(`, `panic!`, or `unsafe` in modified production code. `python3 tools/stamp_author.py --check` exits `0`.
|
||||
|
||||
#### Re-verification & adversarial attack results
|
||||
|
||||
1. **Attack F1 (`ports.rs::encode_edit`) — PASS**:
|
||||
- Verified `ws.open_documents().find(|(_, doc)| doc.path.as_deref() == Some(path))` preserves client non-canonical URIs (`file://localhost/...` and lowercase percent-encoded `caf%c3%a9.sv`) and `doc.version()`, while closed files fall back to canonical `path_to_uri(path)` with `version: None`.
|
||||
- Verified `qa_f1_non_canonical_client_uris_preserve_uri_and_version_in_edits` and QA-added `qa_r2_f1_multifile_rename_open_noncanonical_and_closed_doc_with_and_without_document_changes` pass: multi-file `textDocument/rename` touching one open non-canonical URI (`file://localhost/...` or `caf%c3%a9.sv`) plus one closed file (`version: null`) emits `documentChanges` when enabled and uses the client's open URI as the `changes` map key when `documentChanges` is disabled.
|
||||
|
||||
2. **Attack F2 (`notification.rs` / `ahead.rs` version sync) — PASS**:
|
||||
- Verified `qa_f2_document_version_survives_flush_dirty_and_flush_buffer_immediately` passes.
|
||||
- Audited all `Document` reconstruction call sites across `server/` and `state/`: every `Server::set_document`, `flush_dirty`, `flush_buffer`, and `reclassify_large_buffers` caller (`notification.rs`, `ahead.rs`, `dispatch.rs`, `server/mod.rs`, `startup.rs`) immediately runs `record_document_version` or `sync_document_versions()`.
|
||||
- Verified QA-added `qa_r2_f2_document_version_survives_reclassify_incremental_apply_changes_and_didsave_with_text` passes across incremental `apply_changes_at` + flush, `didSave(text: Some(...))`, and `reclassify_large_buffers` (`normal -> large -> normal`).
|
||||
|
||||
3. **Attack F2b (`same_file.rs::renamed_here` + `fast_actions_differential.rs`) — PASS**:
|
||||
- Verified `enclosed_by_unit` matches `vlog_semantic`'s 5 unit kinds (`Module`, `Interface`, `Package`, `Typedef`, `Class`) at `file_scope` and walks parent scopes so declarations/uses inside file-scope units wait for the index.
|
||||
- Confirmed `"dup_b.sv"` runs in `fast_actions_differential::early_answers_equal_settled_over_the_locality_shapes` (`early=3378 waited=614 differed=0`), `same_file::tests::prepare_rename_waits_at_file_scope_inside_units_and_on_an_unresolved_use` passes, and `fast_actions_bursts::answers_given_ahead_equal_a_one_message_at_a_time_server` passes (`1448 requests, 284 answered ahead (0 from a later state), 1280 settled comparisons`).
|
||||
|
||||
#### Full crate gates (worktree, after final edits)
|
||||
|
||||
- `python3 tools/stamp_author.py --check` -> exit 0
|
||||
- `cargo fmt -p lucisv_server -- --check` -> exit 0
|
||||
- `./tools/guard.sh -m 6 -t 600 -- cargo clippy -p lucisv_server --all-targets -- -D warnings` -> exit 0
|
||||
- `./tools/guard.sh -m 6 -t 600 -- cargo test -p lucisv_server --all-targets` -> `2,048` passed (`47` ignored) unit + `106` passed (`3` ignored) e2e + `3` grammar + `1` ifdef_folding + `0` passed (`2` ignored) opentitan_references; `0` failed
|
||||
|
||||
## Review
|
||||
|
||||
### 2026-11-26 — Lead review: PASS (merged with Lane 1A in Round 1)
|
||||
|
||||
- Inspected combined diff across `lucisv_server` and verified `after_scan` exclusivity, non-canonical URI/version tracking in `ports::encode_edit`, immediate `sync_document_versions` after `flush_dirty`/`flush_buffer`, staging push draining (`#61`), exact `applied_changes` oracle (`#62`), and `same_file::renamed_here` parity (`F2b`) with Lane 1A's duplicate-unit check.
|
||||
- Live 10-spawn OpenTitan `adc.sv:81` probe confirmed 10/10 deterministic refusal with `/Users/lucio/repo/opentitan` untouched.
|
||||
- Handshakes closed in `docs/topo.md`: `#52`, `#53` (server half), `#61`, `#62`. Full `tools/gates.sh` verified green on merged `master`.
|
||||
|
||||
<!-- Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com -->
|
||||
+6
-6
@@ -763,8 +763,8 @@ update the filing README(s) and this file.
|
||||
| 35 | **MCP-5 → `vlog_parser`:** lift the server's `expand.rs` (one-step macro expansion) into `vlog_parser::defines` as a pure move so `lucisv-mcp`'s `defines` can offer expansion — *moot since M7: `defines` folded into `find`, which lists a macro's definitions and no expansion* | mcp-navigation | vlog_parser |
|
||||
| 36 | **MCP-6 → `lucisv_server` (possible bug):** LSP `references` omits three real `aes` instantiations in the `*_pd_main.sv` tops (and their `.clk_i` connections) that `lucisv-mcp`'s whole-set answer lists; stable after a 30 s settle, not investigated | mcp-navigation | lucisv_server |
|
||||
| 37 | **MCP-7 → `vlog_refactor`:** a `find_references` variant taking `&dyn KnownFacts` (like `rename_traced_with`) so whole-set callers feed cached records instead of re-parsing 3 944 files (≈2 s per opentitan call today) | mcp-navigation | vlog_refactor |
|
||||
| 38 | **MCP-8 → `vlog_refactor`:** false `remove_port` refusal when the only "use" of the port is a named connection from another module in the same file (`ports/remove.rs::body_uses_in`) | mcp-edit-tools | vlog_refactor |
|
||||
| 39 | **MCP-10 → `vlog_refactor`:** `extract_module` writes LF into a CRLF file (`extract/render.rs`) | mcp-edit-tools | vlog_refactor |
|
||||
| ~~38~~ | ~~**MCP-8 → `vlog_refactor`:** false `remove_port` refusal when the only "use" of the port is a named connection from another module in the same file (`ports/remove.rs::body_uses_in`)~~ — **closed 2026-11-26 by `refactor-correctness-r1` (Round 1):** `body_uses_in` takes `find_module`'s full `module ... endmodule` span (`item.span`) and filters references to that range. | mcp-edit-tools | ~~vlog_refactor~~ done |
|
||||
| ~~39~~ | ~~**MCP-10 → `vlog_refactor`:** `extract_module` writes LF into a CRLF file (`extract/render.rs`)~~ — **closed 2026-11-26 by `refactor-correctness-r1` (Round 1):** `extract/mod.rs` and `extract/render.rs` detect source `\r\n` vs `\n` and preserve it across new-module, instantiation, and same-file insertion. | mcp-edit-tools | ~~vlog_refactor~~ done |
|
||||
| 40 | **MCP-11/12 → `vlog_refactor`/`vlog_semantic`:** a batched `find_references` for several declarations; ~~`find_references` misses a hierarchical use into a generate loop (`gen_l[0].z`)~~ — **second half answered 2026-09-30 by generate-label-rename (TODO §65.1, row 43)**; the batched `find_references` stays open | mcp-structural-edits | vlog_refactor, vlog_semantic |
|
||||
| 41 | **MCP-13 → `vlog_linter`:** a forced deletion of a non-ANSI body port leaves a header port with no direction and no lint reports it | mcp-structural-edits | vlog_linter |
|
||||
| 42 | **Parser leniency → `vlog_parser`:** a trailing `,` in a named connection list, an empty concatenation element `{d,, d}`, and `type(x)'(y)` in a connection parse without a diagnostic (the rename verifier's position rule covers the rename; every other splice contract is exposed) | refactor-rename (M3.5) | vlog_parser |
|
||||
@@ -777,8 +777,8 @@ update the filing README(s) and this file.
|
||||
| 49 | **A buffer the scope would not take stays indexed after `didClose`** (excluded or unlisted, taken in by a scan or the one-file path), and **closing an unsaved in-scope buffer a rescan indexed leaves its text in the index** (QA-7a). One root: a close does not touch the index. A one-file remove costs ~225 ms on OpenTitan (fixed and reverted in scan-ordering); wanted: a cheap removal, e.g. a tombstone the next scan or publish folds in (TODO §71 waves 5–6) | localized-reindex (QA P2); scan-ordering (QA-1, QA-7a) | vlog_semantic (index removal) / lucisv_server (`state/`) |
|
||||
| 50 | **An unheld buffer opened while a scan runs is never taken in** by that scan or afterwards; opened before the scan it is held — the same final state answers differently by timing (TODO §71 wave 6) | scan-ordering (QA-2) | lucisv_server (`state/scan.rs`, `server/index.rs`) |
|
||||
| 51 | **Symlinked files are held under one spelling or both** depending on what was open at scan time (`discover.rs`'s `Aliased`); incremental and rebuild answers disagree in all six `filelink.py` variants. Rule to adopt: one file, one spelling, whatever is open — in the walk, the overlay and the one-file path together (TODO §71 waves 5–6) | localized-reindex (QA P3); scan-ordering | lucisv_server (`state/discover.rs`, `state/incremental.rs`) |
|
||||
| 52 | **A request held during a scan is answered against the newest text**, so a position-based request can resolve a different symbol when an edit moved the text under it; rename edits carry no document version for the client to reject (TODO §71 wave 6) | scan-ordering (QA) | lucisv_server (`server/`, `rename.rs`) |
|
||||
| 53 | **Renaming a port of a module defined twice** gives an edit or a refusal at random across fresh servers (`top_englishbreakfast/ip/ast/rtl/adc.sv:81`, `qa717/drv/dup.py`); not diagnosed (TODO §71 wave 6) | scan-ordering (QA-7c) | vlog_refactor / lucisv_server (`module_select.rs`) — undiagnosed |
|
||||
| ~~52~~ | ~~**A request held during a scan is answered against the newest text**, so a position-based request can resolve a different symbol when an edit moved the text under it; rename edits carry no document version for the client to reject (TODO §71 wave 6)~~ — **closed 2026-11-26 by `server-ordering-r1` (Round 1):** `Document` tracks client `version: Option<i32>`, and `ports::encode_edit` (shared by `rename.rs` and `ports.rs`) emits versioned `DocumentChanges::Edits` preserving open client URIs when `workspace.workspaceEdit.documentChanges` is advertised. | scan-ordering (QA) | ~~lucisv_server (`server/`, `rename.rs`)~~ done |
|
||||
| ~~53~~ | ~~**Renaming a port of a module defined twice** gives an edit or a refusal at random across fresh servers (`top_englishbreakfast/ip/ast/rtl/adc.sv:81`, `qa717/drv/dup.py`); not diagnosed (TODO §71 wave 6)~~ — **closed 2026-11-26 by Round 1 (`refactor-correctness-r1` + `server-ordering-r1`):** `lucisv_server` holds workspace-wide mutating requests (`rename`, `codeAction/resolve`, `executeCommand`, `willRenameFiles`) in `after_scan` across `self.scanning`, and `vlog_refactor::rename` + `preflight` + `same_file::renamed_here` refuse members inside duplicated file-scope units; verified 10/10 deterministic on OpenTitan `adc.sv:81`. | scan-ordering (QA-7c) | ~~vlog_refactor / lucisv_server~~ done |
|
||||
| 54 | **`lucisv-mcp` re-reads a file with a future mtime on every call**, forever (67 ms against 7 ms per `find` on 4 000 files) — the racy rule never settles (TODO §70) | linux-test-portability (Round 2) | lucisv_mcp (`project/files.rs`) |
|
||||
| 55 | `crates/lucisv/tests/cli.rs:2149` (`a_stdin_buffer_reads_the_rule_options_too`) asserts only an empty stdout, no exit code (TODO §70) | linux-test-portability (Round 2) | crates/lucisv (tests) |
|
||||
| 56 | `crates/lucisv_mcp/tests/qa_m3.rs` uses `std::os::unix` with no `cfg`, so `cargo check --all-targets` for Windows fails (tests only; the `cross` gate checks binaries only) (TODO §70) | linux-test-portability (Round 2) | lucisv_mcp (tests) |
|
||||
@@ -786,8 +786,8 @@ update the filing README(s) and this file.
|
||||
| 58 | **The discovery walk at the start of every scan drains nothing** (25–80 ms on OpenTitan): what is left of the first-colour wait in workspace scope (62–86 ms late open) and the rescan hold (70–159 ms). Wanted: a resumable walk in `state/discover.rs` (it holds `&mut Workspace` throughout `begin_scan`), with its own identical-result proof (TODO §71 wave 7) | viewport-highlight (Handshake request 2) | lucisv_server (`state/discover.rs`) |
|
||||
| 59 | **A `range` answered during a rescan always counts as a guess** (`Viewport::guessed`) and costs one refresh at settle even when nothing changed (TODO §71 wave 7) | viewport-highlight (QA) | lucisv_server (`server/viewport.rs`) |
|
||||
| 60 | **An edit in one file that changes how another open file colours sends no refresh** (a package type renamed) — as before this lane (TODO §71 wave 7) | viewport-highlight | lucisv_server (`server/viewport.rs`) |
|
||||
| 61 | **Inside the startup settings wait, the client's answer to the pull is applied ahead of an older settings push held with it** (`server/startup.rs`, `take_the_answer_out_of_held`); predates fast-actions; needs a client whose push and answer disagree in one burst (TODO §71 wave 8; fast-actions QA F1) | fast-actions (QA) | lucisv_server (`server/startup.rs`) |
|
||||
| 62 | **`tests/fast_actions_bursts.rs`'s oracle accepts an answer the reference gives after any later message of the round**: 2–9 % of injected stale answers pass when a later message restores the state; every mutation is still caught and the directed tests lack the weakness (TODO §71 wave 8; fast-actions QA F4) | fast-actions (QA) | lucisv_server (tests) |
|
||||
| ~~61~~ | ~~**Inside the startup settings wait, the client's answer to the pull is applied ahead of an older settings push held with it** (`server/startup.rs`, `take_the_answer_out_of_held`); predates fast-actions; needs a client whose push and answer disagree in one burst (TODO §71 wave 8; fast-actions QA F1)~~ — **closed 2026-11-26 by `server-ordering-r1` (Round 1):** `take_the_answer_out_of_held` drains older `DidChangeConfiguration` pushes preceding the plucked pull answer while keeping newer pushes. | fast-actions (QA) | ~~lucisv_server (`server/startup.rs`)~~ done |
|
||||
| ~~62~~ | ~~**`tests/fast_actions_bursts.rs`'s oracle accepts an answer the reference gives after any later message of the round**: 2–9 % of injected stale answers pass when a later message restores the state; every mutation is still caught and the directed tests lack the weakness (TODO §71 wave 8; fast-actions QA F4)~~ — **closed 2026-11-26 by `server-ordering-r1` (Round 1):** `ahead::take_ahead_applied` records exact `applied_changes` and the oracle asserts `applied >= required` and `e == reference_at[applied]`. | fast-actions (QA) | ~~lucisv_server (tests)~~ done |
|
||||
| 63 | **Whether a large open buffer is in the index depends on when it was opened, saved or scanned** — a fast-path buffer contributes nothing when open at scan or save time but keeps its disk record when opened after the scan; 77–98 answers differ between a settled session and a fresh server on OpenTitan. Predates fast-actions; wanted: always keep, or always drop, the disk record of a fast-path buffer at open, save, flip and scan alike (TODO §71 wave 8; fast-actions QA S2, Handshake request 8) | fast-actions (QA) | lucisv_server (`state/`, the index lane) |
|
||||
| 64 | **The 40 000-file rescan after a delete takes either 12.3 s or 14.5–15.5 s**, on 0.65.10 and 0.65.11 alike; cause not found (TODO §71 wave 8) | fast-actions | undiagnosed (lucisv_server scan) |
|
||||
| 65 | **`ci.yml` runs `cargo test --workspace` bare in both jobs**, not through `tools/guard.sh` as CLAUDE.md's runaway guard asks of every `cargo test`; predates 0.65.9 for the macOS job, the Linux runner is resource-capped. Recorded, not judged (topo refresh 2026-11-19) | topo refresh (draft discrepancy 10) | CI (lead) |
|
||||
|
||||
Reference in new issue
Block a user