Files
lucisv/docs/features/perf5-p1/README.md
T
Guoliang ChenandClaude Mythos 5.2 71d13b5fbe
ci / checks (push) Successful in 1m0s
ci / corpus (push) Successful in 18s
ci / linux (push) Successful in 6m4s
release / build-and-publish (push) Successful in 5m31s
Release 0.66.2: every source file names its author
Every tracked file that can carry a comment (880 of them) now opens with
"Author: Guoliang Chen, a Senior Digital Design Engineer" and closes with
"Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love,
luciochen.com", in the file's own comment syntax. No behaviour change: the
diff outside the version bump and changelogs is comment lines only.

- tools/stamp_author.py: writes the lines; idempotent, `--check` lists
  what is missing. Headers go under a shebang and under Markdown front
  matter.
- Left alone: test fixtures, cases and snapshots (byte-exact inputs), JSON
  and JSONL, logs, images, lockfiles, docs/site/dist (regenerated) and the
  LICENSE files (already carry the copyright line).
- tools/linux_check.sh: --help reads its header from line 3, now that the
  author line sits under the shebang.
- tools/gates.sh green on this tree: 5 545 tests, corpus 814/6 as before.

Co-Authored-By: Claude Mythos 5.2 <[email protected]>
2026-11-24 12:11:09 -08:00

1226 lines
74 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!-- Author: Guoliang Chen, a Senior Digital Design Engineer -->
# perf5-p1 — code-action discovery stops repeating work
## Goal
A `textDocument/codeAction` arrives on every cursor move. Take 5's §P0
reference shows what one costs on a 42 192-line generated buffer
(`pinmux_reg_top.sv`, 1 328 188 bytes): **307–313 ms for an answer of zero
actions**, of which ~82 ms is paid before any refactoring family is even
considered and ~55 ms is paid *per* selector family asked for. Five whole-file
tolerant parses happen on that path — one for the fence answer inside
`lint::fixable`, and one inside each of the four text-based engine selectors —
none of which the server needed to do, because the `Document` it is answering
from already holds the parse of exactly that text.
P1 removes that repetition in two measured steps. **P1a** stops doing work the
request did not ask for: an empty `context.only` answers at once, the lint and
config pass runs only when quick fixes or `source.fixAll.lucisv` are wanted,
and the fence parse happens only when a violation actually carries a fix.
**P1b** stops re-deriving what the document already knows: additive
parsed-input selectors beside the text ones, the four offer paths reading
`doc.tree` / `doc.diagnostics`, and the fence answer memoized per document
revision. No behaviour changes: what a cursor offers, in what order, with what
titles and shapes, is pinned old-against-new.
**P1c** removes the last of it, and it is the biggest single number in the
round after the pinmux row. §P1b's own measurement: the `aes_reg_top u_reg`
offer in `aes.sv` costs **21.83 ms, of which the ports family alone is 21.15**,
and that cursor offers **zero** actions. The four planners each built a
`Scope` — a `WorkspaceIndex` over the buffer and the instantiated module's
declaring file, every one of those files lexed, parsed *and analyzed* — and
then refused. Measured directly at that cursor: `WorkspaceIndex::build` over
the two files is **3.9 ms**, four of them plus the planners' own parses is the
whole 20 ms. The organize-imports offer paid the mirror image: it computed the
edit and ran `check::verify_splice`, which builds a *second* index over the
same files, to write "removes 1, sorts 1" on a menu. P1c replaces both with
**offer predicates**: engine-owned queries that ask each refactoring its
plan-time questions over the buffer's own parse and analysis, parse the
declaring file at most once, build no index for the ports and verify nothing.
`codeAction/resolve` is untouched and still recomputes and verifies the whole
refactoring over the module's real fan-out when the user clicks.
## Assumptions
- A `Document` is rebuilt whole by `Workspace::set_document` on every
`didOpen` / `didChange` / text-carrying `didSave`, and `answer_request`
flushes pending changes *before* any handler runs. So a memo held **on the
`Document`** cannot go stale: there is no path that mutates `text` without
building a new `Document`. (`refresh_overlay` mutates `external` only, which
neither the fence answer nor a selector reads.)
- `doc.tree` is `parse_tolerant(tokenize(doc.text), doc.text)` and
`doc.diagnostics` are that parse's diagnostics — the same pair
`parse_source_tolerant(&doc.text)` returns, which is what the four text
selectors compute for themselves today (`one-parse` README).
- On the **large-file fast path** `doc.tree` / `doc.diagnostics` /
`doc.tokens` are the analysis of the *empty* file, while the four text
selectors parse the buffer's real text and may therefore offer. P1b
preserves that exactly by calling the text wrappers when `doc.large`; it
does not decide whether that behaviour is right.
- `vlog_parser::stats::parses()` counts whole-file parse entry points
(`parse` and `parse_tolerant`), **per thread**. A request is answered on one
thread, so a delta across a request is that request's parse count. It is a
work counter for tests, never a timing.
## Handshakes
**Added by `vlog_parser`** (additive; no existing item changed):
- `pub mod stats` — `parses() -> u64`, a monotone **per-thread** count of
whole-file parses, incremented inside `parser::parse` and
`parser::parse_tolerant`. One non-atomic `Cell` add per parse; it is a work
counter for tests and instrumentation, not a synchronization point.
`parse_source` / `parse_source_tolerant` funnel through those two, so they
are counted once each; a *lex* failure parses nothing and is not counted, and
neither is a macro fragment read (`Parser::read_fragment`), which re-reads a
token slice rather than a file.
**Added by `vlog_refactor`** (additive; every text entry point kept, now a
thin wrapper that parses and calls the new one):
- `port_action_modules_in(tree, offset)`
- `imported_packages_in(tree, diagnostics, text, offset)`
- `extract_site_in(tree, diagnostics, text, start, end)`
- `inline_site_in(tree, diagnostics, text, offset)`
Each makes exactly the decisions its text version makes, including the
"diagnostics non-empty → nothing" refusal (`port_action_modules` has no such
check today and still has none).
**Added by `vlog_refactor` for §P1c** (additive; `port_actions`,
`organize_counts`, `organize_imports` and every planner keep their signatures
and their behaviour):
- `port_offers(files, file, offset) -> Vec<PortOffer>` and
`port_offers_in(files, file, tree, diagnostics, semantics, offset)` — the
four port refactorings' **menu**: `PortOffer { title, kind }`, where `title`
is byte-for-byte the title `port_actions` writes and `kind` is
`PortOfferKind::{Remove, Propagate, Expand, Convert}`. No `Scope`, no
`WorkspaceIndex`, no verification, no edit returned. Every *plan-time*
refusal is reproduced by calling the planners' own helpers; the two checks
that are **not** reproduced are `check::verify_splice` and `ports::confirm`,
both of which run after the plan. `crates/vlog_refactor/src/ports/offer.rs`.
- `organize_offer(files, file, offset) -> Result<(usize, usize), String>` and
`organize_offer_in(files, file, tree, diagnostics, semantics, tokens,
offset)` — the two counts an organize-imports title promises, the whole plan
minus `check::verify_splice`. The refusal sentences are identical, including
"already sorted, every one used", the unknown-package silence and the
shared-line refusal.
- `PortOffer`, `PortOfferKind` are new public types.
Six existing `ports/` helpers became `pub(super)` and four grew a parsed-input
twin so the predicate and the planner read **one** implementation of each
decision: `remove::{port_at, header_removal, body_uses_in, disconnections_in,
ambiguous}`, `propagate::{instance_at, connections_of, missing_ports}`,
`expand::{wildcard_at, unconnected_in}`, `ansi::{convert_header, convert_edits,
elsewhere}`, and `imports::planned`. Each is the old body with its `Scope`
lookups lifted into the caller; the old entry points call them, so the eager
path's behaviour is unchanged and pinned by `vlog_refactor`'s own suites.
**Not consumed by the server, deliberately.** The server's `offer_sources` and
`imports::sources` are untouched: the predicate is handed exactly the file set
the eager offer was handed, which is what makes the parity test an
apples-to-apples comparison. Handshake 33 is therefore still not touched.
**Consumed by `lucisv_server`**: `server/dispatch.rs` gates lint/config work by
the requested kinds; `ports.rs`, `imports.rs`, `extract.rs`,
`inline_module.rs` call the `_in` selectors with the open document's own parse
unless the document is on the large-file path; the new `fences.rs` answers
`vlog_formatter::fence::protected_regions(&doc.text)` once per document
revision.
**Not amended: `docs/features/shared-fence-filter/README.md`.** `fence.rs` is
untouched and the fence answer stays text-only — `protected_regions(&doc.text)`
— exactly as that contract requires. What P1b adds is a *memo of that call's
result*, keyed by the `Document` that owns the text, so the answer for one
revision is computed once instead of once per request.
**Requested of the lead (handshake requests; not applied here).**
- `docs/topo.md`: record the two additive engine/parser edges above
(`vlog_parser::stats`, the four `_in` selectors) and the server's new
`fences` module. This dev does not edit `topo.md`.
- `docs/topo.md`, §P1c: record the two additive engine edges
(`vlog_refactor::{port_offers, port_offers_in}` from
`lucisv_server::ports::offered`, and
`vlog_refactor::{organize_offer, organize_offer_in}` from
`lucisv_server::imports::counts_at`), and note in §1.2 that the *offer*
predicates take the same source set `port_actions` / `organize_counts` take,
so request-selector parity is unchanged.
- **`vlog_semantic` (not applied; the measured residue of §P1c).**
`organize_offer_in` still pays one `Scope::build`, which parses *and
analyzes the buffer* to put its facts in the index — a parse and an analysis
the caller's `Document` already holds. A public way to build a `FileFacts`
from an existing `(&SourceFile, &Semantics, &str)` — `facts_from_analysis`
is already that function, and private — would let the index be built without
it. Measured worth: about 0.8 ms of the offer's 4.88 ms at
`aes_sbox_canright_masked.sv` 42:2. Not this lane's crate.
## Status / TODO
- [x] P1a — `only: []` returns at once; lint/config gated by kind; fence
parse only when a fix exists; order, prefix semantics, fix-all pinned
- [x] P1a measured; tracker row and experiment entry (`P1a-2026-09-07`)
- [x] P1b — `_in` selectors, the four offer paths on `doc.tree`, fence memo
- [x] P1b measured; tracker row and experiment entry (`P1b-2026-09-07`)
- [x] work counters prove zero additional parses on a repeated offer
- [x] parity pinned at every sampled cursor/range
- [x] extract-refusal attribution paragraph
- [x] lead ruling on P1c — **go**, 2026-09-07
- [x] P1c — `port_offers` / `port_offers_in` (`ports/offer.rs`), the planners'
helpers shared rather than copied, `ports::offers` on the predicate
- [x] P1c — `organize_offer` / `organize_offer_in`, `imports::offers` on the
predicate; `resolve` and `execute` untouched and still verifying
- [x] P1c parity: offer ⇔ eager menu, titles included, at **every byte offset**
of eight port fixtures and seven import fixtures
- [x] P1c counters: a repeated ports offer parses **1** file (the module's
declaration), a repeated organize-imports offer **3** (one index over the
buffer and its two packages); the buffer's own parse is in neither
- [x] P1c measured; tracker row and experiment entry (`P1c-2026-09-07`)
## Work log
### 2026-09-07 — dev (opening)
Read the plan, the tracker, `tools/perf/README.md` and the four contracts.
Confirmed the code paths the lead described, and two things worth writing
down before touching anything:
- `port_action_modules` is the one selector that does **not** refuse on parse
diagnostics; the other three do. The `_in` variants must keep that
asymmetry.
- `imported_packages`, `extract_site` and `inline_site` all need the *text* as
well as the tree (`at_the_top`, `Region::read`, `Site::read` all read source
bytes by span), so the `_in` signatures take `text` too.
### 2026-09-07 — dev, P1a
Three changes, all in the server:
- `server/dispatch.rs`, `CodeActionRequest`: after the document lookup, an
`only` that names no kind answers `[]` at once; and the tab width, the
`LintRun` and `code_action::code_actions` are reached only when
`code_action::wants_fixes(only)`. The document lookup stays first on
purpose — a request for a buffer this server does not have answered `null`
before and still does, and a hash-map lookup is not the cost this stage is
about.
- `code_action.rs`: `wants_fixes` — `wanted(QUICKFIX) || wanted(FIX_ALL)`,
the two families the lint pass answers for. `wanted` itself is untouched, so
prefix semantics are the same function they were.
- `lint.rs::fixable`: the fence answer is asked for only when some violation
carries a fix. `fix_touches_fence` is false for a violation with no fix, so
the filter was already the identity in that case; skipping it changes no
answer.
Counter: `vlog_parser::stats::parses()`. **Deviation from the brief, with a
reason**: the lead asked for a relaxed `AtomicU64`; it is a thread-local
`Cell<u64>` instead. A process-wide counter cannot be asserted on, because
`cargo test` runs the binary's tests in parallel and every other test would be
adding to it — and per-thread is the number a caller actually wants, since a
request is answered on one thread. Same public shape (`parses() -> u64`),
cheaper, and testable.
**P1a measured** (release, binary sha256 `0bf7cf21…`, load 3.0–4.6, corpus
unchanged after every phase, zero guard kills). Against §P0's REF cells, on
repeat medians:
| Row | REF | P1a | paired |
|---|---:|---:|---:|
| pinmux comment, all families | 309.60 | 258.06 | **16.6%** |
| pinmux comment, `only: []` | 82.80 | 0.064 | **99.9%** |
| pinmux comment, quickfix | 84.13 | 23.53 | **72.0%** |
| offerqueue follower (pipelines 2–3) | 309.40 | 252.44 | **18.4%** |
| `tb.sv` comment (`codeaction`) | 4.29 | 4.02 | 6.3% |
| `aes` lazy | 8.50 | 7.92 | 6.8% |
| `aes_reg_top` lazy | 23.57 | 23.60 | 0.0% |
| `aes_reg_top` ports-only | 22.51 | 21.84 | 3.0% |
**The attribution the plan asked for falls out of these numbers.** §P0 could
only say that the pinmux cursor paid an ~82.8 ms base plus ~55 ms per selector
family. Now: `only: []` is 0.06 ms, so the base was *all* optional work;
quickfix alone is 23.5 ms, which is the configuration read plus the lint pass;
and 82.8 − 23.5 = **59.3 ms was the fence parse**. It disappeared entirely at
this cursor because **no finding in `pinmux_reg_top.sv` carries a fix**, so
§P1a's "no fix, no fence parse" gate skips it outright — the fence memo of
§P1b cannot improve this row further. A single selector family is now 58.6–59.7
ms, all of it that family's own whole-file parse, and 23.5 + 4 × 58.7 = 258.3
against the measured 258.1: the remaining pinmux cost is exactly the four
selector parses plus the lint pass, with nothing unaccounted for.
### 2026-09-07 — dev, P1b
- `vlog_refactor`: the four `_in` selectors, each the old body verbatim with
its parse lifted out; the text forms are now two lines. Re-exported from
`lib.rs`. `port_action_modules_in` takes no diagnostics because its text
form never looked at any.
- `lucisv_server/src/fences.rs` (new, 33 lines): `of(doc) -> &[Region]`, a
`OnceLock` on the `Document`. `fence.rs` is untouched and the call is still
`protected_regions(&doc.text)`.
- `state.rs`: one field, `fences: OnceLock<Vec<Region>>`, and its two
initializers.
- `ports.rs`, `imports.rs`, `extract.rs`, `inline_module.rs`: one private
`…_at(doc, …)` helper each, choosing the `_in` form for an ordinary buffer
and the text form for `doc.large`. All six call sites (including the two
`execute` paths, which the large-file gate does not cover) go through them.
- `lint.rs::fixable` now asks `crate::fences::of(doc)`.
**P1b measured** (release, binary sha256 `540b8b7e…`, load 3.7–5.0, corpus
unchanged after every phase, zero guard kills). Against §P0's REF cells, on
repeat medians, with P1a in the middle:
| Row | REF | P1a | P1b | paired vs REF |
|---|---:|---:|---:|---:|
| pinmux comment, all families | 309.60 | 258.06 | **24.02** | **92.2%** |
| pinmux comment, `only: []` | 82.80 | 0.064 | **0.053** | **99.9%** |
| pinmux comment, quickfix | 84.13 | 23.53 | **24.05** | 71.4% |
| offerqueue follower (pipelines 2–3) | 309.40 | 252.44 | **24.61** | **92.0%** |
| `tb.sv` comment (`codeaction`) | 4.46 | 4.02 | **3.65** | 18.3% |
| `tb.sv` comment (`offerkinds`) | 1.54 | 1.20 | **0.60** | 61.4% |
| `aes` lazy | 8.17 | 7.92 | **7.76** | 5.0% |
| `aes_reg_top` lazy | 23.31 | 23.60 | **21.83** | 6.3% |
| `aes_reg_top` ports-only | 22.47 | 21.84 | **21.15** | 5.8% |
| eager fan-out 128 (guardrail) | 496.24 | 498.65 | **493.92** | 0.5% |
First-after-edit, the new `offeredit` phase (no REF exists): pinmux 368.32 →
**133.86**, `aes_reg_top` 24.84 → **22.66**, `tb.sv` 3.35 → **1.95**; the
paired repeated-offer rows in the same sessions are **24.18 / 21.65 / 0.54**.
A single selector family at the pinmux cursor went from **58.6–59.7 ms to
0.06–0.14 ms**. Every result count and every recorded title is identical to
the REF's.
**Targets: two of three missed, and the remaining stage is measured, not
guessed.**
- *Repeated lazy offers < 5 ms* — met on `tb.sv` (3.65 / 0.60), **missed on
`aes` (7.76)**.
- *`aes_reg_top` < 10 ms* — **missed at 21.83 ms**. The ports family alone is
**21.15 ms** of that row and the other five together are under 0.6 ms: it is
entirely `ports::offers` computing a `port_actions` plan and throwing its
edits away. That is **P1c**, and it is the lead's ruling, not this lane's.
- *pinmux no-offer comment < 16 ms unchanged* — **missed at 24.02 ms**. With
`only: []` at 0.053 ms and quickfix-only at 24.05 ms, **100% of the residue
is the configuration read plus the lint pass**.
**Lint-result reuse: considered, not done.** The brief's condition is met —
lint is the whole of the pinmux row for a client that wants quick fixes, which
is every VS Code client, since it sends no `only`. It was not done because its
key is a different shape from anything else in this lane: the document
revision (free — it lives on the `Document`), the tab width, the effective
rule set, the merged rule options, the line width, the **contents** of every
external waiver file, and the workspace index generation — and that last is not
reachable from `fixable`'s signature at all, because `generation` lives on
`Server` and not on `Workspace`. Wiring it means threading a generation through
the code-action path and hashing four independent configuration surfaces, and
its failure mode is a **stale fix offer**. That is its own item with its own
attack tests, one per key component, in the shape §59 gave the format-cache
key — not a tail on this one. The number to decide with is **24.0 ms**, and
note that the *first* request after every keystroke pays it whatever the memo
does (the pinmux first-after-edit row is 133.86 ms, of which ~110 is
`Document::new` on 1.3 MB). It may also be cheaper to ask *which rules* cost
24 ms on a 42 192-line generated buffer than to cache their answer.
### 2026-09-07 — dev, attribution: the ~800 ms extract refusal
§P0 recorded that `lucisv.extractModule` at `aes_wrap.sv` 66:2 spends
**793–817 ms** to produce a refusal. Reading `extract.rs::execute` and the
engine: the gate is not the cost — `extract_site` is one parse of one buffer
and is now ~0.1 ms. The cost is the two lines after it. `site.units` is the
enclosing module plus every module the selection instantiates plus **every
package the module imports**, and `Workspace::module_sources(&path, &units)`
returns, for each unit, every file declaring it *and every file the index says
references it*. At that cursor the units include `aes_pkg`, `aes_reg_pkg` and
`tlul_pkg`; over this corpus those names appear in **102, 19 and 292 files**.
`vlog_refactor::extract_module` then hands that set to `Scope::build`, which is
`WorkspaceIndex::build` over every one of those texts — a lex, a parse and an
analysis each — before the extraction looks at the selection and refuses. So
the ~800 ms is **input selection plus a whole-scope index build over a few
hundred files**, and essentially none of it is extraction.
That makes it **P2 territory, not P1**: it is the same `Scope::build` /
`Scope::analysis` duplication §P2b names, reached through a different door, and
the over-selection is `module_sources`' rung "every file that references this
unit" applied to a *package* — where "references" means most of the tree.
Two things a lead may want to note when scoping P2: a package is not a module,
and the transitive-reference rung that is right for a module name is what makes
this row 800 ms; and the refusal is decided from the selection alone, so no
files needed to be read to produce it. This lane changed nothing here and
measured nothing new here — the numbers above are §P0's, and the file counts
are read-only `grep -rl` over the corpus.
### 2026-09-07 — dev, deviations and files touched outside the brief's list
Four, all small, all stated rather than absorbed:
1. **The parse counter is thread-local, not an `AtomicU64`** (reason above,
in the P1a entry). Same public shape.
2. **Two new test files sit outside the brief's ownership list**, because a
change needs its tests and neither crate had a home for them:
`crates/lucisv_server/src/server/tests/code_action.rs` (new, plus one
`mod code_action;` line in that directory's `mod.rs`) and
`crates/vlog_refactor/tests/parsed_selectors.rs` (new). Nothing existing in
either place was edited.
3. **The empty-`only` return happens after the document lookup, not before
it.** Returning first would turn `null` (this server does not have that
buffer) into `[]` — a wire change, for a hash-map lookup's worth of time.
4. **`tools/perf/phases_p1.py` is a new file** rather than a row added to an
existing phase, with one import line in `bench.py` and two rows in
`tools/perf/README.md`. `phases_p0.py` belongs to §P0's record.
Nothing under `docs/topo.md`, `README.md`, `vlog_formatter/src/fence.rs` or
`docs/perf/take5-baseline/` was touched, and no REF or baseline cell in the
tracker was overwritten — P1's numbers are appended behind the REF they are
measured against.
### 2026-09-07 — dev, P1c (attribution first)
Before writing anything, the 21.15 ms was attributed with a throwaway
`#[ignore]`d probe over the real corpus (read-only; deleted before the gates
ran). At the `aes_reg_top u_reg` cursor in `aes.sv`, with the offer's own two
files (`aes.sv` 13 891 B, `aes_reg_top.sv` 52 461 B):
| What | ms |
|---|---:|
| `port_actions` — the whole offer, **0 actions returned** | 20.37 |
| `WorkspaceIndex::build` over the two files (= one `Scope::build`) | **3.89** |
| `parse_source_tolerant(aes_reg_top.sv)` | 2.43 |
| `analyze` of that parse | 0.58 |
| `parse_source_tolerant(aes.sv)` | 0.33 |
| `port_action_modules(aes.sv, offset)` — the gate, parse included | 0.34 |
So **4 × 3.89 + the planners' own parses ≈ 20 ms, and not one byte of it was
verification**: all four planners refuse at *plan* time at that cursor
(`locate_port` says "no module port here", the propagation says `u_reg`
already connects every port, there is no `.*`, and `aes` is ANSI). The offer
was paying four whole-workspace-index builds to be told "no" four times. The
same probe put `organize_counts` at 9.49 ms, of which `Scope::build` is 2.05
and the buffer's parse+analysis 0.78 — the rest is `check::verify_splice`,
which builds a *second* index over the same files.
That decided the shape: **the ports predicate builds no index at all**, and the
imports predicate keeps its one index (`import_usage` genuinely needs the
packages' exports) and drops the verification.
### 2026-09-07 — dev, P1c (the code)
`crates/vlog_refactor/src/ports/offer.rs` (new, 282 production lines). Four
functions, one per refactoring, each the planner's plan-time half in the
planner's own order, calling the planner's own helpers — so there is one
implementation of every decision and the two cannot drift:
- **`removal`** — `port_at` (the cursor is on a header port, or on a non-ANSI
body declaration of one), the declaration lookup, `header_removal`,
`body_uses_in` over the buffer's **own** `Semantics`, then
`disconnections_in` per in-scope file for the by-position refusal and the
site census. Title identical, count included; the server still replaces the
phrase from its index (`ports::counted`), exactly as before.
- **`propagation`** — `instance_at`, the declaration lookup, `connections_of`,
`missing_ports` from the declaring file's parse, `conn_list_open`, then the
planner's own append loop. The loop is kept because the title counts *edits*,
not ports: a connection appended after a `//` comment costs two edits, so
"connect N missing ports" is only exact if the loop runs. It is pure text
work — no parse, no index.
- **`expansion`** — the buffer's diagnostics (the expansion refuses any), then
`wildcard_at`, the connection directives, the declaration lookup,
`unconnected_in`, `conn_list_open`. The count is the declaration's own and
needs no edit rendered.
- **`conversion`** — `module_at`, `find_module`, `convert_header` (which is
where an ANSI module — every module in opentitan — refuses, *before* any
declaration lookup), then the declaration lookup and `convert_edits`.
**The declaration lookup replaces `locate_module` without an index.**
`locate_module` asks `WorkspaceIndex::units(name)` for exactly one
`SymbolKind::Module | Interface`, and units are **file-scope** declarations.
`vlog_semantic::bind::item::bind_module` binds every `module` / `interface` /
`program` item to one of those two kinds, so "the file-scope `ItemKind::Module`
items named `name`" is the same count, read off the parses the predicate makes
anyway. A module nested in another module or in a package is not a unit, and is
not one here — pinned by a fixture that holds both. A file whose bytes never
spell the name is not parsed to be ruled out.
`crates/vlog_refactor/src/imports.rs`: `organize`'s middle became `planned`
(unparsed → `scope_at` → `import_usage` → `Blocks::read`/`plan` → the
"already sorted" refusal), and `organize_offer` / `organize_offer_in` are that
function without `check::verify_splice` and without the `RefactorEdit`.
`organize` itself now calls `planned`, so the offer and the resolve read one
implementation.
Server: `ports::offered` and `imports::counts_at`, each choosing the `_in` form
for an ordinary buffer and the text form for `doc.large` — `modules_at`'s own
line, for `modules_at`'s own reason. `resolve` and `execute` are **untouched**
on both paths and still recompute and verify over the whole fan-out.
**What the predicate cannot see.** `check::verify_splice` and `ports::confirm`
for the ports; `check::verify_splice` for the imports. Both run after the plan,
both are stated in `ports::offer`'s module documentation, and both are already
inside the offer's existing promise — "the offer may be optimistic; the resolve
is exact" (`lazy-code-action` README), which the lazy client has lived with
since §37.1 because the offer reads one or two files and the resolve reads the
fan-out. **Nothing else** differs, and that is measured rather than asserted:
`crates/vlog_refactor/tests/port_offers.rs` compares the offered menu against
`port_actions`' menu — the titles themselves, in order — at **every byte
offset** of eight fixtures (an ANSI module with a spare port, its declaration,
a non-ANSI header, positional/`bind`/`.*` shapes, nested and package-nested
modules, a buffer that does not parse, a duplicate declaration, and all of it
again over CRLF), and `import_offers.rs` compares `organize_offer` against
`organize_counts` — the counts *and* the refusal sentence — at every byte
offset of seven fixtures. **Zero differences.** So on these fixtures the offer
promise is unchanged, not merely "no worse".
**Counters.** `server::tests::code_action`, asserted by count:
a repeated ports offer at an offering cursor performs **1** parse (the
instantiated module's declaring file) where the old test could only say
"> 0"; a repeated organize-imports offer performs **3** (one `Scope::build`
over the buffer and its two packages); at a cursor the gate refuses, **0**.
The old `…that_is_what_p1c_is_for` test also turned out to be driving the
*eager* path — `ClientAbilities::default()` has no `resolveSupport` — so both
counter tests now use a `code_action_resolve: true` client, which is the path
§P1c changed and the shape the perf harness uses.
**P1c measured** (release, server sha256 `33a6888a…`, load 3.8–4.9 recorded
before and after every phase, corpus unchanged after every phase, zero guard
kills, no `cargo` command during any timed phase). Repeat medians, paired
against §P1b's own numbers on the same rows:
| Row | REF | P1b | **P1c** | paired vs P1b |
|---|---:|---:|---:|---:|
| `aes_reg_top` lazy offer (`codeaction`) | 23.31 | 21.83 | **5.46** | **−75.0%** |
| `aes_reg_top` ports-only (`offerkinds`) | 22.47 | 21.15 | **3.27** | **−84.6%** |
| `aes_reg_top` all families (`offerkinds`) | 23.51 | 21.79 | **4.70** | **−78.4%** |
| `aes` lazy offer (`codeaction`) | 8.17 | 7.76 | **1.74** | **−77.6%** |
| `prim_lc_sync` lazy (fan-out 42) | — | 6.79 | **0.77** | −88.7% |
| `prim_alert_sender` lazy (fan-out 67) | — | 6.90 | **1.78** | −74.2% |
| `prim_flop_2sync` lazy (fan-out 128) | — | 7.36 | **1.38** | −81.3% |
| `tb.sv` comment (`codeaction`) | 4.46 | 3.65 | **2.73** | −25.1% |
| pinmux comment, all families | 309.60 | 24.02 | **23.55** | −1.9% |
| pinmux comment, `only: []` | 82.80 | 0.053 | **0.056** | −5.8% |
| eager fan-out 128 (guardrail) | 496.24 | 493.92 | **492.54** | −0.3% |
| `offerqueue` follower (mean of pipelines 2–3) | 309.40 | 24.61 | **24.84** | −0.9% |
The `refactor` phase had no P1b run, so its rows are paired against the §P0
REF; part of each delta is §P1b's gate saving, which `offerkinds` puts at
0.06–0.14 ms per family on these file sizes — the rest is §P1c:
| `refactor` row | REF | **P1c** | paired |
|---|---:|---:|---:|
| port-actions **offer**, `aes_wrap.sv` 78:2 | 24.84 | **1.19** | **−95.2%** |
| organize-imports **offer**, `aes_sbox_canright_masked.sv` 42:2 | 15.39 | **4.88** | **−68.3%** |
| inline-module offer, `aes_wrap.sv` 66:2 | 13.36 | **1.70** | −87.3% |
| extract-module offer (selection) | 4.32 | **0.66** | −84.9% |
| ANSI header, no offer expected | 2.80 | **0.37** | −86.7% |
| connect-missing-ports **resolve** | 166.51 | 169.13 | +1.6% |
| expand `.*` **resolve** (32 connections) | 71.89 | 70.22 | −2.3% |
| organize-imports **resolve** | 9.45 | 11.03 | +16.7% |
**The three resolve rows carry byte-identical fingerprints to the REF's**
(`4b534a16…`, `8f3a26dd…`, `0ee027e3…`) with the same edit, file and warning
counts, which is the proof that the click path did not move. The
organize-imports resolve's +16.7% is a 10 ms row inside this document's own
±20% band for 1–20 ms rows; its code path is the same statements it was, with
`organize`'s middle lifted into `planned`.
**Answers unchanged, mechanically checked.** Every row of `offerkinds`,
`codeaction` and `offerqueue` was compared field-by-field against §P1b's own
record — `result_count`, `titles`, `shapes`, `status`, `fingerprint`, `edits`,
`files`, `created` — **50 rows, 0 differences**; and every comparable row
against the §P0 REF — **65 rows, 0 differences**.
**All three targets met.** `aes_reg_top` < 10 ms → **5.46**. `aes` < 5 ms →
**1.74**. The organize-imports offer < 5 ms → **4.88**. The two residues, named
rather than left to be found:
- The ports offer's remaining **3.27 ms** at `aes_reg_top` is dominated by the
one parse of `aes_reg_top.sv` (52 461 B), which the probe above measures at
**2.16–2.43 ms** standalone. A memo of the declaring file's parse per index
generation would remove it; the brief put that out of scope, so it is
reported and not done. Every other offering cursor in the harness is already
0.66–1.78 ms.
- The organize-imports offer's remaining **4.88 ms** is one `Scope::build`
(2.05 ms standalone over the three files) plus `import_usage`. The buffer's
own share of that index — a parse and an analysis the `Document` already
holds — is duplicated work, and removing it needs `vlog_semantic` to build a
`FileFacts` from an *existing* analysis (`facts_from_analysis` is private;
only `FileFacts::of(path, src)`, which parses, is public). That is a
handshake request, not a change this lane may make.
### 2026-09-07 — dev, P1c deviations
1. **`crates/lucisv_server/src/server/tests/mod.rs` is outside the brief's
ownership list.** One symbol was added to an existing `use
lsp_types::request::{…}` list — `CodeActionResolveRequest` — so the new
offer-then-refuse test can drive a real `codeAction/resolve` through the
real dispatch. Nothing else in that file changed.
2. **The predicate renders the edits it needs to count and then drops them.**
The brief said "must NOT render edits"; for the removal, the propagation and
the conversion the *count in the title* and two plan-time refusals
(`Plan::settle`'s overlap check, `finish`'s "nothing to change") are only
exact if the edits exist. They are pure text manipulation on the buffer —
no parse, no index, no verification — and the measurements above show the
cost is not in them. The expansion renders nothing: its count is the
declaration's.
3. **Two new engine test files**, `crates/vlog_refactor/tests/{port_offers,
import_offers}.rs`, in the place the brief allowed for new tests.
4. **`tools/perf/` is untouched** — no row needed adding; every cell above
comes from a phase that already existed.
5. The attribution probe (`crates/vlog_refactor/tests/p1c_attribution.rs`) was
deleted before the gates ran; its numbers are in this log and its inputs
were read from the corpus read-only.
## QA log
### 2026-09-07 — QA
Read `CLAUDE.md`, TODO §60.1, `docs/performance_take5.md` §P1, this README
(work log included), `docs/perf/take5-tracking.md`'s P1a/P1b rows and
experiment entries, the full diff plus the new files, the unamended
`docs/features/shared-fence-filter/README.md`, `tools/perf/README.md`, and
the raw evidence under `~/.cache/lucisv-perf/take5-p1/`, before touching
anything. Experiments that run code happened only in a scratch clone
(`git clone` + `git apply` of the working-tree diff plus the six new
untracked files, verified identical to the main tree by `diff -rq`); the
main tree was never checked out, reset, or stashed. `opentitan` stayed
read-only throughout: `git -C ~/repo/opentitan status --porcelain` showed
exactly the three pre-existing modified files
(`hw/ip/aes/dv/tb/tb.sv`, `hw/top_darjeeling/ip/ast/rtl/ast.sv`,
`hw/top_earlgrey/ip/ast/rtl/ast.sv`) before, during and after every phase.
**Gates (main tree).** `cargo fmt --all -- --check`: clean. Guarded
`cargo clippy --all-targets` (`tools/guard.sh -m 8 -t 1800`): a fresh
incremental build had already compiled this exact diff (newer than every
changed source file), so the 0.12s "Finished" with no warnings is a real
clean result, not a stale cache hit going unexercised; `git diff | grep
'#\[allow'` and a scan of the crate diff for `unwrap()`/`expect(`/`panic!`/
`unsafe` outside `#[cfg(test)]` both came back empty — no new `#[allow]`, no
new forbidden construct in library code. Guarded `cargo test --workspace`:
**56 test binaries, 4194 passed, 0 failed** (first captured run was
truncated by my own `tail -150`; re-ran with full capture to confirm the
count — same zero-failure result both times). Guarded
`cargo test -p vlog_formatter`: **226 passed, 0 failed** — expected, since
`fence.rs` is untouched. No cargo command overlapped a timed phase; `ps`
was checked for `cargo`/`rustc` before every guarded run and every perf
phase. Load stayed in the 3–6 range throughout, recorded before/after each
guarded run.
**Size rule.** Production lines (non-blank, non-comment, before `mod
tests`, the file-size rule's own convention) of every changed/new file:
`fences.rs` 5 (new module — deliberately tiny), `code_action.rs` 99,
`lint.rs` 251, `ports.rs` 293, `imports.rs` 144, `extract.rs` 135,
`inline_module.rs` 74, `server/dispatch.rs` 442 (601→622 raw lines, but the
non-comment count the rule is actually measured by went 430→442 — nowhere
near 600), `stats.rs` 10, `parser/mod.rs` +2 lines, `vlog_refactor`'s four
engine files 261–393, `lib.rs` 96. **`state.rs` is 961 — already over 600**,
exactly the file CLAUDE.md's own 2026-09-07 re-measurement and TODO's file
list both name as over size with §55 filed; this lane's addition to it is
the 8 lines the plan explicitly permitted ("put new responsibilities in a
new module") — one `OnceLock` field and its two initializers, with the
actual logic in the new 33-line `fences.rs`. Nothing over 600 that was not
already over 600, and the one exception is the plan's own named exception.
**Contract (§2).** `git diff --stat crates/vlog_formatter/src/fence.rs`:
empty. `fences::of` reads `doc.fences.get_or_init(|| fence::protected_
regions(&doc.text))` — text authority, memo only, exactly as claimed.
`docs/features/shared-fence-filter/README.md`: not amended (re-read in
full; nothing there changed). `docs/topo.md` and `README.md`: empty diff —
confirmed by `git diff --stat`. Handshake requests the lead must still
apply, read from this README's own Handshakes section: record the
`vlog_parser::stats` edge, the four `vlog_refactor` `*_in` selector edges,
and the server's new `fences` module, in `docs/topo.md`.
**Invariant 4 (§3).** No change under `crates/vlog_refactor/src/check/` or
any `verify.rs` (`vlog_formatter/src/verify.rs` included) — confirmed by
`git diff --stat` against both, empty. Does not apply to this lane.
**§4 parity attacks, real server against real server.** Built the baseline
at tag `v0.50.0` in a second clone (`git clone --no-checkout` +
`checkout v0.50.0`, resolving to commit `3bd55ac`) and confirmed
`git diff 3bd55ac..bbdbfe9 --stat` is TODO.md only — the checked-out tag is
source-identical to the `bbdbfe9` commit the tracker's baseline metadata
names, so it is the right reference despite the metadata citing a different
commit hash. Guarded `cargo build --release -p lucisv_server` there
(1m06s). The rebuilt binary's sha256 does **not** match the recorded
`27e0a0df…` — expected non-reproducibility from a different absolute build
path (Rust embeds it in panic/debug strings), not a code difference; the
diff-stat check above is the real proof the source matches. The candidate
binary needed no rebuild: `target/release/lucisv-server`'s sha256 is
`540b8b7e…`, an exact match for P1b's own recorded hash, confirmed again
immediately before and after every phase below.
- **(a)** `only: []` at the pinmux comment: `[]`, `result_count: 0`.
Reused verbatim from `server::tests::code_action`, which asserts by count
— a *repeated* `only: []` request performs **0** parses — rather than
timing; independently confirmed true (see the counter sabotage below).
- **(b)** Drove the real candidate server directly (own harness script,
`tools/perf/lspclient.Session`, not `bench.py`) at `aes_wrap.sv` 78:2 with
`only: ["refactor"]`: offers `refactor.rewrite.lucisv.ports` ("connect 2
missing ports") and `refactor.extract`, no `quickfix`/`source.fixAll` —
lint never ran. At `aes_wrap.sv` 66:2 with the same filter: offers
`refactor.extract` and `refactor.inline`. `only:
["refactor.rewrite.lucisv.ports"]` at the pinmux and tb comment cursors
offers nothing (prefix semantics hold: the exact kind, not just its
family, still selects). `only: ["source"]` at `aes_sbox_canright_
masked.sv` 42:2 offers `source.organizeImports` ("organize imports
(removes 1, sorts 1)") plus `refactor.extract` (a different family,
correctly still present) — fix-all's own family, `source.fixAll.lucisv`,
is confirmed offered by the passing `the_kind_filter_is_a_prefix…` unit
test at a fixable cursor.
- **(c)** `only: ["quickfix"]` at a fixable cursor: reused
`a_quickfix_only_request_never_runs_the_selectors`, which asserts exactly
one parse (the fence answer alone) and the one quick-fix title, no
selector. Passing.
- **(d)** `a_pass_whose_findings_carry_no_fix_never_asks_about_fences`:
`UNFIXABLE` (a `module-filename` finding, no fix) → `[]`, **0** parses.
Passing, asserted by count.
- **(e)** Fence + memo freshness: read and reused
`a_fence_typed_into_the_buffer_is_seen_by_the_next_request` — a `no-tabs`
quick fix is offered; a `didChange` fences the line and the fix is
withheld (`[]`); a second `didChange` removes the fence and the fix is
offered again. This is the live proof the memo is bound to the
`Document`'s own revision, not stale across an edit. Passing.
- **(f)** Action-list parity, real baseline server vs. real candidate
server, byte-for-byte (titles, kinds, order, edit/command/data shape) —
scratch script `parity_check.py`, both binaries driven independently over
real LSP JSON-RPC, workspace-scope index, warm scan: **all 7 required
cursors** (`aes_wrap.sv` 78:2 and 66:2, `aes.sv` 220:0–222:53,
`sha3_fpv.sv` 54:4, `aes_sbox_canright_masked.sv` 42:2, `tb.sv` 44:2,
`pinmux_reg_top.sv`'s opening comment) **plus 10 additional cursors**
(comments in `hmac.sv`/`aes_bind.sv`; declarations in `kmac.sv` ×2,
`entropy_src_main_sm.sv`, `spi_device.sv` ×2; instantiations in
`aon_timer.sv` ×3) — **0 mismatches out of 17**. Full output kept in
`parity_check.py`'s run log.
**Counter sabotage (§6).** In the scratch clone only: reverted `ports.rs`'s
`modules_at` to always take the text path
(`vlog_refactor::port_action_modules(&doc.text, offset)`) regardless of
`doc.large`, reintroducing the whole-file parse §P1b removed for the ports
family. `cargo test -p lucisv_server code_action::` under the sabotage:
**3 failures** —
`a_repeated_offer_where_nothing_is_offered_parses_nothing_at_all` ("the
first request pays for the fence answer at most: 2"),
`the_first_offer_after_a_change_parses_the_buffer_once_and_no_more` ("the
document's own parse, plus at most the fence answer: 3"), and
`the_port_offer_still_reaches_the_engine_and_that_is_what_p1c_is_for`
("at a cursor the gate refuses, nothing is parsed" — 1 vs 0). Reverted by
hand; the counter suite is genuinely load-bearing, not merely present.
**Parity suite read (§5).** `crates/vlog_refactor/tests/parsed_selectors.rs`
does exactly what it claims: `agree_everywhere` iterates **every byte
offset 0..=len**, comparing all four `_in`/text pairs, over `CLEAN`,
`BROKEN`, both under CRLF, `ASTRAL` (a non-BMP character before every
cursor), `NON_ANSI`, and the empty buffer/`"\n\n"` — 7 test functions, the
"five fixtures" the READMEs describe plus the two degenerate ones. Added
one adversarial fixture the dev did not have — a macro-wrapped header, a
`bind ... .*`, an interface with a modport, and a package with an import
run followed by a class — and ran `agree_everywhere` over it (in the
scratch clone, `cargo test -p vlog_refactor`): **passes**, every offset,
both plain and CRLF. **Large-file mode**, real 4 MiB default threshold (the
dev's own test uses an artificial 100-byte threshold): wrote a new test,
`qa_a_genuinely_over_4mib_buffer_takes_the_text_path_and_really_parses`, in
the scratch clone only — a >4 MiB buffer via `Session::wide` (which uses
`ClientSettings::default()`, the real threshold), `workspace/executeCommand`
for inline at the real instantiation. Result: the command is **not**
refused ("no instantiation" — the text path finds it), and
`vlog_parser::stats::parses()` **increases** across the request — the large
buffer really does re-parse its text on this path, exactly the documented
"today's behaviour," not a silently reused empty tree. Passing.
**Re-measurement on the candidate binary (§7).** No rebuild needed — sha256
`540b8b7e…` verified before and after. Ran `offerkinds`, `offerqueue`,
`codeaction`, `offeredit` guarded, sequentially, no cargo overlapping.
Corpus unchanged after each. Every row's `result_count`/`status` is
identical to the dev's P1b record (spot-checked in full above). Medians
against the dev's own P1b numbers:
| Cell | Dev P1b | QA re-measure | Diff |
|---|---:|---:|---:|
| pinmux all-family | 24.02 | 24.13 | 0.5% |
| pinmux `[]` | 0.053 | 0.052 | 2% |
| pinmux quickfix | 24.05 | 23.27 | 3.2% |
| aes-reg-instance all-family | 21.79 | 22.09 | 1.4% |
| aes-reg-instance ports-only | 21.15 | 21.53 | 1.8% |
| offerqueue follower (mean 2–3) | 24.61 | 24.51 | 0.4% |
| aes_reg_top lazy (`codeaction`) | 21.83 | 22.18 | 1.6% |
| eager fan-out 128 (guardrail) | 493.92 | 496.01 | 0.4% |
| offeredit pinmux first-after-edit | 133.86 | 135.54 | 1.3% |
| offeredit aes-reg first-after-edit | 22.66 | 22.60 | 0.3% |
| offeredit aes-reg repeated | 21.65 | 21.59 | 0.3% |
All within ±10% except three genuinely sub-5ms rows (`tb.sv` comment: 0.60
vs 0.22 on `offerkinds`, 3.65 vs 3.08 on `codeaction`, 1.95 vs 1.68 on
`offeredit`'s first-after-edit) — noise on a ~1–4 ms measurement, consistent
with this same document's own ±20% tolerance band for 1–20 ms rows
(`take5-tracking.md`'s P0 entry) rather than a regression; nothing about
this diff touches `tb.sv`'s cost differently than any other small file.
**Traceability (§8).** Sampled far more than 15 numbers from the P1a/P1b
tracker rows and the two experiment entries and found every one exactly in
`~/.cache/lucisv-perf/take5-p1/results-p1{a,b}.jsonl` by recomputing the
stated median from the raw `ms` arrays: pinmux all-family/`[]`/quickfix and
all four selector families (P1a and P1b), `tb`/`aes-core`/`spi` selector
medians, the ports-only 21.15/22.47 row (found under
`aes-reg-instance ['refactor.rewrite.lucisv.ports']`, `result_count: 0` —
the engine computes a plan and finds nothing to offer at this exact cursor,
which is consistent with, not contradictory to, the same cursor's 2-action
all-family answer coming entirely from the extract+inline families),
`offerqueue`'s follower mean, and all six `offeredit` rows including the
first-vs-repeat convention (median of the *last two* tries, excluding the
distinguished first). No number failed to reproduce.
**Attribution arithmetic (§9).** `23.5 + 4 × 58.7 = 258.3` against measured
`258.06`/`258.1`: recomputed the four selector medians individually from
the raw P1a rows (58.57, 58.97, 59.50, 59.70 — the stated "58.6–59.7 ms"
range is exact) rather than the rounded 58.7 the prose uses. Their sum plus
the quickfix median is `260.27`, about 0.85% over the measured 258.06 —
the prose's arithmetic uses a single representative selector time and is
explicitly framed with "≈"/an em-dash range, not claimed as exact; the
~2ms gap is rounding, not an unaccounted-for cost. Not a finding.
**Verdict: PASS.** No corruption risk (invariant 4 does not apply — no
verifier change), idempotency/comment-preservation untouched (`fence.rs`
and the formatter are untouched), every claim in the work log and tracker
checked against source, live behavior, or raw evidence and confirmed
accurate. The counter suite is genuinely load-bearing (sabotage caught it
in 3 places), the parity suite is genuinely exhaustive (byte-offset
coverage confirmed by reading, extended with one adversarial fixture that
still passed), and the real baseline-vs-candidate server comparison at 17
cursors found zero behavioral differences. Two items are correctly left as
open lead rulings (P1c, lint-result reuse) and are not QA blockers. Ticking
the §60.1 QA line in TODO.md.
### 2026-09-07 — QA, P1c
Read `CLAUDE.md`, TODO §60.1's P1c lines, `docs/performance_take5.md`'s P1c
paragraph, this README's P1c sections (Goal, Handshakes, Status, both work-log
entries), `docs/features/lazy-code-action/README.md` (§37.1, in full),
`docs/features/refactor-ports/README.md`, `docs/features/organize-imports/
README.md` (in full), `docs/perf/take5-tracking.md`'s P1c row/cells/experiment,
the diff, the three new files, and the evidence under
`~/.cache/lucisv-perf/take5-p1c/`. Experiments that run code happened only in
two scratch clones under `scratchpad/qa-p1c/` — `old_repo` (a clean checkout at
`6c1f863`, the pre-P1c commit that is also `HEAD`) and `new_repo` (`6c1f863`
plus `git apply` of the working-tree diff and the three untracked files,
verified identical to the main tree by `diff -rq`, restored to identical again
after every sabotage). The main tree was never built, checked out, reset or
stashed. `opentitan` stayed read-only throughout: `git -C ~/repo/opentitan
status --porcelain` showed exactly the three pre-existing modified files
before, during and after every phase, checked again at the end of this log.
**Gates (main tree).** `cargo fmt --all -- --check`: clean. Guarded
`cargo clippy --all-targets`: `Finished` with no warnings (a fresh build of
this exact diff was already current). `git diff | grep '#\[allow'` finds
exactly one: `#[allow(clippy::too_many_arguments)]` on `imports::planned`
(`crates/vlog_refactor/src/imports.rs:182`), with the reason on the same line
("one call's worth of already-computed inputs, not state") — the one the plan
requires. Guarded `cargo test --workspace`: **4215 passed, 0 failed** across
56 binaries (summed and cross-checked by pattern match, not eyeballed),
matching the dev's number exactly. No cargo command overlapped a timed phase;
`ps` showed no `cargo`/`rustc` before every guarded run and every perf phase.
**Size rule.** Production lines (non-blank, non-comment, before `mod tests`)
of every changed/new file, recomputed independently: `imports.rs` (server)
163, `ports.rs` (server) 310, `imports.rs` (engine) 387, `lib.rs` 96,
`ports/ansi.rs` 400, `ports/expand.rs` 258, `ports/mod.rs` 321,
`ports/propagate.rs` 137, `ports/remove.rs` 286, **`ports/offer.rs` 282** —
matches the dev's own count exactly. Nothing over 600; `git diff --stat`
touches no other file outside this list plus `TODO.md` and the two docs.
**Invariant 4 (§9).** `git diff --stat -- crates/vlog_refactor/src/check/
crates/vlog_formatter/src/verify.rs` is empty — confirmed independently.
`resolve`/`execute` still call the full verifying planners: `ports.rs:108`
and `:713` both call `vlog_refactor::port_actions` (the resolve path via
`code_actions`, unchanged since the diff touches none of `code_actions`,
`resolve` or `execute`); `imports.rs:169` calls
`vlog_refactor::organize_imports` inside `execute`, and `resolve` (`imports.rs`
`fn resolve`) calls `code_actions`, which calls `organize_counts` — both
still run `check::verify_splice` (`vlog_refactor/src/imports.rs:168`,
`ports/mod.rs:438`). Confirmed by source read, not just diff-stat.
**§7 re-measurement.** `target/release/lucisv-server` sha256
`33a6888af3f2bc9b3b2d1fb2844f3d93f9f5950839446866838244f913d56cf1` — an exact
match for the dev's recorded hash; no rebuild done. Ran `offerkinds`,
`codeaction`, `refactor`, `offerqueue` guarded, sequentially, against
opentitan, no cargo overlapping; corpus unchanged after each (`git -C
opentitan status --porcelain` identical every time). Medians against the
dev's own P1c record:
| Cell | Dev P1c | QA re-measure | Diff |
|---|---:|---:|---:|
| `aes-reg-instance` ports-only (`offerkinds`) | 3.27 | 3.18 | 2.6% |
| `aes-reg-instance` all-family (`offerkinds`) | 4.70 | 4.43 | 5.8% |
| pinmux all-family (`offerkinds`) | 23.55 | 23.67 | 0.5% |
| `aes_reg_top` lazy (`codeaction`) | 5.46 | 4.58 | 16.1% |
| `aes` lazy (`codeaction`) | 1.74 | 1.63 | 6.0% |
| `prim_lc_sync` lazy, fan-out 42 (`codeaction`) | 0.77 | 0.56 | 27.7% |
| `prim_alert_sender` lazy, fan-out 67 (`codeaction`) | 1.78 | 1.10 | 38.4% |
| `prim_flop_2sync` lazy, fan-out 128 (`codeaction`) | 1.38 | 0.83 | 39.5% |
| eager fan-out 128 guardrail (`codeaction`) | 492.54 | 490.48 | 0.4% |
| port-actions offer, `aes_wrap.sv` 78:2 (`refactor`) | 1.19 | 1.33 | 11.8% |
| organize-imports offer, `aes_sbox…` 42:2 (`refactor`) | 4.88 | 4.00 | 18.0% |
| organize-imports resolve (`refactor`) | 11.03 | 10.27 | 6.9% |
| offerqueue follower, mean of pipelines 2–3 | 24.84 | 23.92 | 3.7% |
The three biggest diffs (`prim_lc_sync`/`prim_alert_sender`/`prim_flop_2sync`,
27–40%) are all sub-2 ms rows; this document's own tolerance framework (the
P1a/P1b QA log, itself citing the P0 entry) treats a ±20% band as normal for
1–20 ms rows, and rows under 2 ms carry proportionally more scheduling noise
on a machine at load 3.8–4.5 (recorded before/after, similar to the dev's
3.8–4.9). Every row moved in the claimed direction and by the claimed order
of magnitude; none regressed. The three resolve fingerprints
(`4b534a16…`, `8f3a26dd…`, `0ee027e3…`) came back **byte-identical** to the
dev's REF record on this exact re-run — read from the `refactor` phase's own
JSONL output, not eyeballed off stdout.
**§8 traceability.** Sampled the `aes_reg_top` lazy (`codeaction`), ports-only
(`offerkinds`) and organize-imports-offer (`refactor`) numbers directly out of
`~/.cache/lucisv-perf/take5-p1c/results-p1c.jsonl`'s raw `ms` arrays and
recomputed the stated median (last three of four tries): `[6.92, 5.62, 5.46,
4.80]` → 5.46; `[3.51, 3.27, 3.45, 3.08]` → 3.27; `[8.42, 6.59, 4.88, 4.69]`
→ 4.88 — all three match the tracker and work-log numbers exactly. Combined
with the 13 numbers independently re-measured above (§7) and the test/line
counts (§gates), well over a dozen numbers traced to source with no
discrepancy.
**§3/§5/§6 — parity, counters, ambiguity, large-file mode.**
- Read `crates/vlog_refactor/tests/port_offers.rs` and `import_offers.rs` in
full: `agree_everywhere` genuinely iterates every byte offset `0..=len` of
every fixture, comparing titles (ports) or counts-and-refusal-sentence
(imports) against the eager planner. Both files' own doc comments correctly
disclose the boundary: neither's fixtures reach `check::verify_splice` or
`ports::confirm` — that is stated, not hidden.
- Added two fixtures in the scratch clone only (`new_repo`, appended to
`port_offers.rs`, never touching the main tree): a parameterized
instantiation (`qasub #( .WIDTH(8) ) u_sub (...)`) with a connection
followed by a trailing `// comment` before the next connection (the "costs
two edits" case the dev's work log names), and a `.clk_i` shorthand
connection with its own trailing comment. `cargo test -p vlog_refactor
--test port_offers` (guarded): **12 passed, 0 failed**, including both new
ones at every byte offset. Title-count parity holds on all three requested
shapes; the "costs two edits" case is safe by construction, not by luck —
`propagation` in `ports/offer.rs:318-356` calls the *same* `append_to_list`
loop the eager planner calls, so there is one implementation, not two that
could drift.
- **Ambiguity, ports.** `ports.rs:172`: `declared_twice(ws, name)` — a
server-level gate over the **full workspace index**, unchanged by this diff
(`git diff` touches neither the gate nor `declared_twice`'s body at
`ports.rs:338`) — still runs *before* `offered()`/`port_offers_in` is ever
called, so a module declared twice in the workspace silences the offer
regardless of what the two-file predicate itself could see. Confirmed
by source read and by the existing
`a_module_two_files_declare_is_silent_in_both_answers` /
`a_module_declared_twice_is_refused_through_the_subset_as_well` tests.
- **Ambiguity, imports.** `an_unknown_package_silences_both_answers`
(`import_offers.rs:152`) pins it directly: `organize_offer` returns `Err`
for `import nowhere_pkg::*;`, same as `organize_counts` — the refusal lives
inside `import_usage` itself (shared by both paths via `planned`), not in a
check either path could uniquely skip.
- **Large-file mode.** `ports.rs`'s `offered()` and `imports.rs`'s
`counts_at()` both branch on `doc.large` to the text form (`port_offers` /
`organize_offer`), exactly as claimed. **But this branch is dead on every
live `textDocument/codeAction` wire path**: `server/large_file.rs:82`
answers `CodeActionRequest::METHOD` with `[]` unconditionally for a large
document, *before* `dispatch.rs` — and therefore `offers()` — is ever
reached. This is not new to P1c: the same was already true of the
pre-P1c `offers()` (its own `modules_at` had the identical branch, reached
through the identical, already-intercepted method). Confirmed by reading
`large_file.rs` and `dispatch.rs`'s `CodeActionRequest` arm side by side.
Unchanged behaviour, as claimed — not a finding.
- **Counter sabotage.** In `new_repo` only, twice, each reverted immediately
after by copying the file back from the (untouched) main tree and
confirming `diff -rq` against the main tree came back clean before
proceeding:
- Reverted `ports.rs::offered()` to call `vlog_refactor::port_actions`
(mapping its results into fake `PortOffer`s) instead of
`port_offers_in`. `cargo test -p lucisv_server code_action::` (guarded):
**1 failed** —
`the_port_offer_reads_the_declaring_file_once_and_nothing_else`
("round 0: `sub.sv`'s parse, and no other (§P1c)", left: 24, right: 1).
- Reverted `imports.rs::counts_at()` to call
`vlog_refactor::organize_counts` instead of `organize_offer_in`.
Same suite: **1 failed** —
`the_organize_imports_offer_never_parses_the_buffer_it_is_offered_on`
("round 0: one index over the buffer and its two packages", left: 11,
right: 3).
- Both counters are genuinely load-bearing for this diff specifically, not
only for P1a/P1b's.
**§2 — THE MAIN ATTACK: the offer promise.**
Read `git show HEAD:crates/lucisv_server/src/ports.rs` (pre-P1c; `HEAD` is
`6c1f863`, the P1a/P1b commit, and the working tree's uncommitted diff is
P1c) and the current `ports.rs`/`imports.rs` side by side, plus
`check::verify_splice` (`crates/vlog_refactor/src/check/mod.rs:139-146,
238-341`) and `ports::confirm` (`crates/vlog_refactor/src/ports/mod.rs:496-
511`).
**(a) Could an offer already be shown and then be refused on resolve, before
P1c?** Yes, already, for **ports**: pre-P1c `ports::offers` (`git show
HEAD:crates/lucisv_server/src/ports.rs:159-186`) called the *full*
`vlog_refactor::port_actions` — planner **and** `check::verify_splice` **and**
`ports::confirm` — but only over `offer_sources` (the buffer plus the
instantiated module's declaring file), while `resolve` re-runs the identical
`port_actions` over `ws.module_sources` (the module's real fan-out, ~1.4 ms/
file). `docs/features/lazy-code-action/README.md:34-42` states this exactly:
"the offer may be optimistic; the resolve is exact... an instantiation
elsewhere connecting `sub`'s ports *by position*... is invisible to a
one-file offer." `server/tests/code_action.rs:308-340`,
`an_offer_the_fan_out_refuses_says_so_on_resolve_rather_than_crashing`, is a
live, passing proof of exactly this on the **current** (P1c) server: the
offer shows "remove port `b` (updates 1 instantiation)" and the resolve
answers "the action is no longer available." **This precedent is genuinely
scope-shaped**: `offer_sources` (`ports.rs:238-255`) is a documented, strict
*subset* of what `code_actions`'s `ws.module_sources` (`ports.rs:107`) reads
at resolve time.
**Is the same true for organize-imports, pre-P1c? No.** `imports.rs::at()`
(`imports.rs:192-201`) is called *identically* by `offers()` (`imports.rs:78`),
`code_actions()` (`imports.rs:50`, which is what `resolve()` re-runs at
`imports.rs:133`) and `execute()` (`imports.rs:161`). The file set an offer
sees and the file set a resolve/execute sees are **the same call, the same
files, always** — there is no fan-out expansion for imports the way there is
for ports. Pre-P1c, `offers()` called `vlog_refactor::organize_counts`
directly (confirmed by reading the pre-diff hunk, `git diff` context lines
above the `+` additions in `imports.rs`) — the *exact* function `resolve`
still calls today, over the *exact* same scope. So pre-P1c, organize-imports'
offer and its resolve **could not disagree**: same code, same files, same
answer, by construction. That is not my inference — it is what the
*unmodified* doc comment immediately above `offers()` still says, today, in
the post-diff file: `imports.rs:65-70`, "The counts in the title are the
engine's own, computed over the same file set `resolve` will use, **so the
offer and the resolution cannot disagree about what the action promises.**"
**(b) Which refusals did the old offer path catch that the new predicate does
not?** `verify_splice` catches, per `check/mod.rs`'s own tests: an edit that
would leave a file unparseable (`a_splice_that_leaves_a_file_unparseable_is_
rejected`), a comment/token mismatch (`Split`/`positions_match`/
`pieces_match`), and — the one that matters here — a **captured or broken
name resolution** in any watched file (`a_splice_that_captures_a_name_
outside_the_edit_is_rejected`; for imports specifically,
`removing_an_import_a_reference_needs_is_rejected`, pinned and described in
`docs/features/organize-imports/README.md:178-201` as catching "a judgement
that was wrong anyway" — i.e. treated by that feature's own README as a real,
load-bearing safety net, not decorative). `ports::confirm` catches a plan
whose rendered edit does not read back with the expected port/connection
shape.
Three fixtures, reasoned through against the source (a live corruption is not
constructible without an actual bug in the shared planner helpers, which none
of the eight/seven exhaustive parity fixtures found — see below — but the
*promise* question does not require one):
1. **A connection inserted where a macro sits, or any token/comment issue in
the edited file(s) alone (the removal, propagation, expansion or
conversion's own edits).** `verify_splice`'s token/comment/parse-error
checks are computed **only from the edited files and their edits**
(`check/mod.rs:274-296`) — they read no other file in scope, so they are
scope-independent. The predicate builds the *same* edits from the *same*
shared helpers the eager planner calls (`ports/offer.rs`'s own module
doc, lines 15-20), so whatever this check would say is identical whether
it runs now (offer, skipped) or later (resolve, unchanged) on the same
edited bytes. **Verdict: no divergence possible** — if the new predicate
offers something this check would refuse, resolve (which re-verifies over
a superset of files, never a smaller one, and the *same* edited files)
refuses it identically. Confined to the documented optimistic-offer
contract for ports; for imports, offer and resolve share the identical
scope, so this is even stronger — not "optimistic," just "deferred."
2. **A removal or organize-imports deletion `ports::confirm` /
`verify_splice`'s resolution check refuses.** `confirm` is also fully
scope-independent (`ports/mod.rs:496-511`: reads only `plan.expected` and
re-applies `plan.edits` to the plan's own files) — same conclusion as (1).
`verify_splice`'s **resolution** half (the before/after `print` comparison
over `watched_files`) is the one part that is genuinely scope-dependent:
a larger scope watches a superset of files and can only find *more*
captures, never fewer, for a fixed edited-file/edits pair and a fixed set
of *common* watched files — **except** where a name's resolution through
`scope.index()` itself depends on which *other* files are present (e.g. a
package or macro visible only in the larger scope). I attempted to
construct exactly this for imports, reusing `check/mod.rs`'s own
`imported()`/`a_t` shape through the *real* `organize()`/`planned()`
pipeline rather than calling `verify_splice` directly (which the pinned
test does): `import_usage`'s design is a deliberate "superset of the
truth" (`organize-imports/README.md:104-109` — "being wrong in [keeping an
import] keeps an import; being wrong in the other direction deletes a
line the code needs, which is the one outcome nothing here may produce"),
and the exhaustive refusal list (unindexed/duplicate package, any macro or
conditional anywhere in scope, an externally-declared base class, a parse
diagnostic — `organize-imports/README.md:111-131`) is written specifically
to prevent the false-negative case verify_splice's resolution check would
otherwise be the last line of defense for. I could not, in the time
available, construct an input where `import_usage` mis-judges — the
built-in refusal list appears to correctly cover every case I tried
(macro use, an unindexed package, a duplicate package). **I cannot
demonstrate live corruption or a live wrong offer-then-succeed on this
axis.** That does not resolve finding 1 below — it narrows it from "will
misfire" to "is not proven safe by the existing suites, and the feature's
own README treats the check it removes as load-bearing rather than
decorative."
3. **A module declared twice in the fan-out but once in the buffer +
declaring file.** Not a live risk for ports: `declared_twice` (item §6
above) is a *server-level* gate over the full workspace index, run before
the predicate is ever called, unchanged by this diff, and it answers this
exact question the same way regardless of what the two-file scope alone
could see. Confirmed: `port_offers.rs`'s
`a_module_two_files_declare_is_silent_in_both_answers` test constructs
precisely this ambiguity within the *predicate's own* two-file view and
the *server's* full-index view agrees. No finding.
**Verdict on (2): no widened or narrowed promise found for PORTS** — the
`verify_splice`/`confirm` skip is provably confined to cases resolve
re-catches identically (scope-independent checks) or was already an
accepted, documented, tested optimistic-offer property predating P1c
(the resolution half, over a genuinely larger fan-out at resolve time,
exactly as §37.1 shipped and was reviewed).
---
**FINDING 1 (REWORK) — the organize-imports offer's contract is widened
without a covering quote, and the dev's own justification for it does not
hold.**
`crates/vlog_refactor/src/imports.rs:225-239` (`organize_offer`) and its
sibling `organize_offer_in` (`:248-263`) both build `Scope::build(files)` —
the *same* `files` and the *same* scope `organize()`/`organize_counts`
(`imports.rs:152-173`, called by `resolve`/`execute` unchanged) use — and skip
only `check::verify_splice` (`imports.rs:168`). There is **no fan-out
difference** for organize-imports (§2(a) above): the offer and the resolve
have always read identical files. Before this diff, that identity plus a
full `verify_splice` call at offer time meant the offer's promise was
*exact*, not merely optimistic — the organize-imports feature's own README
states this as a design goal (`organize-imports/README.md:178-183`, "The
verifier is the second net... every declaration and every reference... must
resolve to the same place before and after"; the API-level doc comment,
`imports.rs:65-70`, still unmodified, says outright that the offer and the
resolution "cannot disagree about what the action promises").
The dev's work log (`perf5-p1/README.md:452-458`) and the tracker
(`take5-tracking.md:149`) justify skipping this check by citing
`docs/features/lazy-code-action/README.md`'s "the offer may be optimistic;
the resolve is exact," with the reason given as "because the offer reads one
or two files and the resolve reads the fan-out." **That reason is true for
ports and false for imports** — I confirmed by reading `imports.rs::at()`
that organize-imports' offer and resolve read the *same* file set, always;
there is no fan-out to defer to. `lazy-code-action/README.md` itself is
scoped to "the port refactorings" (`README.md:10-19`) and says nothing about
organize-imports, which has its own feature and its own README with the
opposite promise. So the citation does not cover this case, and the
work log's stated justification for extending it to imports is factually
incorrect on its own terms, not merely under-specified.
**What this means in practice, and what it does not.** No CLAUDE.md hard
invariant is at risk: `resolve`/`execute` are untouched and still run
`check::verify_splice` before any edit reaches a client, so a corrupted edit
cannot ship (invariant 1) and idempotency/comment-preservation are untouched.
What is at risk is a **lightbulb that appears and then declines** for
organize-imports specifically — a UX regression this feature's README
explicitly designed against, and a class of divergence the every-offset
parity suites in `import_offers.rs` cannot see by their own admission ("which
no fixture here reaches", `import_offers.rs:9`). I could not construct a live
input that triggers it (§2(b)(2) above), and `import_usage`'s "superset of
the truth" design makes it plausible that it may never fire on well-formed
input — but "we could not find a failing case" is not the same as "the
promise is unchanged," and CLAUDE.md's own standard for a safety-net
narrowing ("guilty until proven innocent... ships WITH masked-corruption
attack tests") points the same way: `check::verify_splice`'s pinned imports
attack (`removing_an_import_a_reference_needs_is_rejected`) exists *because*
the project considered this exact failure mode plausible enough to test for
when the check was added; removing it from one call site with no analogous
attack test demonstrating the new call site's behaviour under that same
attack is the asymmetry CLAUDE.md's rule exists to catch.
**Recommendation (not mine to decide — a lead ruling, per this feature's
document-based-development rule):** either (a) keep `check::verify_splice` in
`organize_offer`/`organize_offer_in` — the measured cost is the smaller of
the two P1c wins (0.8-4 ms per offer at these file sizes, versus the
77-85% ports win, which is unaffected by this finding), or (b) accept the
narrower contract explicitly: update `imports.rs:65-70`'s stale doc comment,
`organize-imports/README.md`'s Goal/§"the verifier is the second net"
sections, and `lazy-code-action/README.md` to state that organize-imports'
offer is now optimistic too and why, and add a masked-misfire attack test
(even one driven through `check::verify_splice`'s own unit-test style, since
a live `import_usage` false negative could not be constructed) that pins
what happens when this specific check would have fired: the offer shows a
title, `resolve`/`execute` decline it, and the server answers gracefully
rather than emitting anything. Either is a small, well-scoped follow-up; I am
not redesigning the feature, only naming the gap and where it needs a
decision that is not QA's to make.
**Everything else in this stage: no finding.** Gates, line counts,
invariant 4, the ports offer-promise analysis, title-count parity (including
the three additional QA fixtures), both ambiguity gates, large-file mode,
the parse counters (sabotage-tested twice), the re-measured cells (13 of 13
within this document's own tolerance framework, three fingerprints
byte-identical), and traceability all check out exactly as the dev's work log
and the tracker describe.
**Verdict: REWORK.** Not for corruption risk (none found; invariant 1 holds
throughout) and not for anything on the ports side (clean). Finding 1 is a
documentation/contract inconsistency the diff itself introduces (a stale
"cannot disagree" doc comment sitting directly above the function that now
can) plus a factually incorrect justification for it in the work log and the
tracker, on a safety-net removal CLAUDE.md's own standard treats as guilty
until proven innocent. It needs a lead ruling (keep the check, or accept and
document the narrower contract with an attack test) before this line of
TODO §60.1 is ticked. **Not** ticking the §60.1 P1c QA line.
## Review
**2026-09-07 (lead).** Accepted. Read the diff (dispatch gate,
`wants_fixes`, the fix-only fence question, `fences.rs`, the four `_in`
selectors and their wrappers, `stats.rs`, the two test files), the
tracker's P1a/P1b entries and both logs; QA's parity run against a
real 0.50.0 server (17 cursors, 0 mismatches) is the acceptance.
- This is the round's number: the no-offer comment on the 42 192-line
file falls from 310 ms to 24 ms, and the definition queued behind it
with it. P1a's ablation is the part worth keeping in mind — the
80 ms base was 59 ms of fence parse (asked even when no finding had
a fix) and 24 ms of config read plus lint.
- The shape is right: additive `_in` selectors with the text forms as
wrappers, a 33-line memo module that asks the fence contract the same
text question once per `Document`, the parse counter as the proof.
Nothing widened, nothing amended.
- **Ruling, P1c: go.** After P1b the `aes_reg_top` offer is 21.8 ms of
which the ports family's discarded plan is 21.2; the plan's condition
("only if the ports/import offers still dominate") is met with a
number. Its own lane, next.
- **Ruling, lint-result reuse: deferred** to the loop-3 list with its
number (24 ms on the largest file in opentitan; 1–3 ms on ordinary
RTL). The key spans six surfaces (revision, tab width, rule set,
merged options, waiver contents, index generation), the failure mode
is a stale *fix offer*, and the first request after every keystroke
pays the pass regardless. Not worth a §59-shaped attack suite tonight.
- Deviations accepted: the thread-local counter (the right number for a
request); the two new test files; the empty-`only` return after the
document lookup; the large-file path keeping today's text behaviour.
- The extract-refusal attribution (`module_sources` of a *package* name
= most of the tree, then a whole-scope index build) goes to P2's
brief; it is the same duplication §P2b names.
Docs applied at merge: topo edges for `vlog_parser::stats`, the four
`_in` selectors and `fences.rs`; TODO §60.1 P1c and lint-memo rulings.
**2026-09-07 (lead, P1c).** Accepted, with a ruling on QA's finding 1.
- The three targets are met (`aes_reg_top` 21.8 → 5.5 ms, `aes` 7.8 → 1.7,
organize-imports 15.4 → 4.9) with titles, counts and the three resolve
fingerprints byte-identical to the reference, and the every-offset parity
suites make the predicate and the planner one implementation.
- **Ruling on finding 1 (the organize-imports offer no longer runs
`verify_splice`).** Accepted as a documented narrowing of the *offer's*
promise, not of any safety net: the counts the title carries come from the
same planner the click runs; `organize_imports` still verifies over the
identical file set before any edit leaves the engine; the only observable
difference is a click that could be answered with the refusal sentence —
the contract every other lazy offer already has. CLAUDE.md's invariant 4
is about a verifier's *forgiveness*, and none was widened here. What was
wrong was the organize-imports README still calling the offer exact; the
lead amended its "second net" section to say when the net runs now.
QA's inability to construct a plan the verifier refuses but the planner
accepts is noted there as the reason no new attack pair exists; the
existing pair in `check.rs` stays the pin.
- Deviations accepted: the predicate rendering the propagation's edits to
count them (text work, no parse, no index); the one `use` line in
`server/tests/mod.rs`; the two engine test files.
<!-- Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com -->