516 lines
31 KiB
Markdown
516 lines
31 KiB
Markdown
# walk cycles
|
|
|
|
## Goal
|
|
|
|
Two unrelated residues of the repository analysis (finding 3), landed
|
|
together as TODO §43 because each is small and neither collides with the
|
|
other.
|
|
|
|
**43.1 — a cycle policy for the shared walk.** `lucisv_core::walk` recursed
|
|
on `Path::is_dir()` with no memory of where it had been. A symlink that
|
|
points back into the tree it sits in — `a/loop -> ../a`, `a/sub/up -> ..`,
|
|
the `rtl -> ../shared/rtl` pair a vendored checkout writes twice — made the
|
|
walk descend forever, one directory deeper each time, until the operating
|
|
system refused the path. Both front ends share that walk: `lucisv` (and so
|
|
`format`, `check`, `--check`, `--diff`) and the language server's index scan,
|
|
where the symptom is not an error message but an index that never comes up.
|
|
The policy is now **each directory is entered once, by identity**: a symlink
|
|
naming a directory the walk has already entered is skipped silently, and a
|
|
symlink naming one it has not is still followed, once. No traversal budget —
|
|
identity *is* the policy, and a budget would be a second, weaker rule
|
|
answering the same question differently.
|
|
|
|
**43.2 — the net delay's comment slots.** `wire /* c */ #5 w;` and
|
|
`wire [7:0] /* c */ #1 w;` were refused outright: `NetDelay` had no field for
|
|
a comment written in front of its `#`, so the comment was printed one node
|
|
later and `verify.rs` — correctly — refused the whole file (exit 2, no
|
|
output). `NetDelay` now owns both of its gaps, `before_hash` and
|
|
`after_hash`, and the `#SKIP` `parser-skips` left in
|
|
`net_delay_position.cases` is retired.
|
|
|
|
## Assumptions
|
|
|
|
- **Directory identity on unix is `(dev, ino)`.** `fs::metadata` follows
|
|
symlinks, so the link and its target return the same pair, which is exactly
|
|
the question being asked. Elsewhere (there is no non-unix CI today, but the
|
|
crate compiles there) it is `fs::canonicalize`, which resolves the same way
|
|
at the cost of a path lookup. Both are `Option`: a name whose metadata
|
|
cannot be read is not a directory the walk can enter.
|
|
- **A hard link is not a cycle, and is not treated as one.** Two hard-linked
|
|
*files* have one inode and the visited set never sees them: only
|
|
directories are recorded. (Hard-linked directories are not creatable on any
|
|
filesystem lucisv runs on.)
|
|
- **The visited set lives for one `collect_files` call.** Two inputs named on
|
|
one command line each get their own walk, so a directory reachable from
|
|
both is still walked twice — unchanged, and the CLI's own path dedup is
|
|
what answers that (`§41`). Inside one walk the same file reached under two
|
|
spellings is reported once, under the first spelling that reaches it: entry
|
|
order is `read_dir` sorted by path, so `link_a/x.sv` wins over `shared/x.sv`
|
|
and `shared/x.sv` wins over `zlink/x.sv`. This is the same rule §41 already
|
|
applies to a symlinked *file*.
|
|
- **A dangling symlink is not an input.** `metadata` fails on it, so it is
|
|
neither walked nor collected. Before this round a dangling `x.sv` link was
|
|
collected and failed later, at read time, with a "no such file" error the
|
|
user did not write.
|
|
- **The `.gitignore`/`--exclude` decision still comes first.** A cycle inside
|
|
an ignored or excluded directory is never entered at all, so the visited
|
|
set never sees it; the ignore rules were not touched.
|
|
- **A comment in front of a `#` belongs to the delay** (43.2), the way
|
|
`Typedef::before_name` owns the gap in front of its name: the gap is taken
|
|
only on the branch that actually consumes the `#`, so a `#` that is not a
|
|
net delay leaves the comment for whoever comes next.
|
|
|
|
## Handshakes
|
|
|
|
- **`lucisv_core::walk` → `lucisv` and `lucisv_server`** (topo §2.9-8, struck
|
|
by this round). `collect_files`'s signature is unchanged. What changed is
|
|
what it returns for a tree containing symlinked directories: it terminates,
|
|
and a directory reachable under several names contributes its files once.
|
|
`lucisv_server::state::Workspace::walked_files` is the server's only caller
|
|
and needed no change — its `sort`/`dedup` still runs, and now has less to
|
|
do. `vlog_linter` uses `walk::is_excluded` only, which is untouched.
|
|
**Amended 2026-09-09 (review finding F1):** the visited set is now a value a
|
|
caller may own and share between two walks (`DirectoryTracker`,
|
|
`collect_files_tracked`, `collect_files_below_tracked`), because the server's
|
|
startup scan discovers its scope in two walks and the enter-once rule has to
|
|
hold *between* them. The policy is unchanged and the old entries are
|
|
wrappers; see the work log below.
|
|
- **`vlog_parser::ast::NetDelay` → `vlog_formatter`** (topo §2.9-27, struck).
|
|
Two new public fields, `before_hash` and `after_hash`, both
|
|
`Vec<Comment>`. The only constructor is `Parser::parse_net_delay`; the only
|
|
reader is `Fmt::net_delay`. `vlog_semantic`, `vlog_linter` and
|
|
`vlog_refactor` do not name the type.
|
|
- **Not taken:** the gaps *inside* a delay's `#( … )` — `#( /*c*/ 1:2:3 )`
|
|
and each side of its two `:` — are still refused. They are
|
|
`parse_delay_values`, shared with a gate instantiation's delay list, and
|
|
they fail identically outside a net declaration; they belong with the rest
|
|
of the shared expression machinery in topo §2.9-22, not here. Recorded
|
|
below and left for a future round.
|
|
|
|
## Status / TODO
|
|
|
|
- [x] 43.1 `Walk::visited`, `Walk::enter`, `dir_id` per platform; `dir()`
|
|
checks-and-inserts before `read_dir`
|
|
- [x] 43.1 a dangling symlink is skipped rather than collected
|
|
- [x] 43.1 unit tests: self-loop, ancestor link from a nested start, two
|
|
links to one target, a link to a directory not yet walked, a dangling
|
|
link, a cycle inside an ignored directory
|
|
- [x] 43.1 CLI test (`--check` over a cyclic tree names each file once)
|
|
- [x] 43.1 server test (a cyclic workspace scans once and finishes)
|
|
- [x] 43.2 `NetDelay::before_hash` + `after_hash`, parser and formatter
|
|
- [x] 43.2 the `#SKIP` in `net_delay_position.cases` retired, three live
|
|
cases in its place
|
|
- [x] 43.2 the RTL gap fuzzer covers a net delay (352 → 374 gaps, still zero
|
|
failures)
|
|
- [x] Gates: fmt, clippy, workspace tests, corpus, both binaries over a
|
|
cyclic tree
|
|
|
|
## Docs to apply at merge (lead)
|
|
|
|
- `docs/topo.md` §2.9-8 — strike: **delivered 2026-09-05 by walk-cycles
|
|
(TODO §43.1)**: `lucisv_core::walk::Walk` keeps a `visited` set keyed on
|
|
`(dev, ino)` on unix and the canonical path elsewhere; each directory is
|
|
entered once, a symlink to a directory already entered is skipped
|
|
silently, a symlink to one not yet entered is still followed, a dangling
|
|
symlink is skipped. Both front ends: CLI `--check` over a cyclic tree names
|
|
each file once; the server's `walked_files` scan finishes.
|
|
- `docs/topo.md` §2.9-27 — strike: **delivered 2026-09-05 by walk-cycles
|
|
(TODO §43.2)**: `NetDelay::before_hash` and `after_hash` own the two gaps
|
|
around the `#`; the formatter prints them inline; the
|
|
`net_delay_position.cases` `#SKIP` is retired and the RTL gap fuzzer covers
|
|
the construct. The gaps *inside* `#( 1:2:3 )` remain refused and belong to
|
|
§2.9-22 (`parse_delay_values`, shared with gate delays).
|
|
- `docs/repository-analysis.md` finding 3 — annotate as closed by TODO §43.1
|
|
with the identity policy above, and note that the "no traversal budget"
|
|
ruling was the lead's.
|
|
- `docs/features/parser-skips/README.md` — its Assumptions (line ~103),
|
|
Handshakes (line ~151) and QA log (lines ~343, ~409) describe the net-delay
|
|
comment as a live `#SKIP` and as a handshake request to `comment-slots`.
|
|
That request is now answered; a one-line "closed by walk-cycles (TODO
|
|
§43.2), 2026-09-05" under each is the honest amendment. Not edited here —
|
|
it is another feature's README, and this lane owns none of it.
|
|
- `README.md` — no change needed: the walk's user-visible contract
|
|
(extensions, `--exclude`, `.gitignore`) is unchanged. If a line is wanted,
|
|
it is in the CLI section: "a symlinked directory is walked once; a cycle
|
|
terminates".
|
|
|
|
## Work log
|
|
|
|
### 2026-09-08 — §61.3: two additive entries beside `collect_files`
|
|
|
|
`lucisv_core::walk` gained two functions and lost nothing. `collect_files`
|
|
keeps its signature, its order, its `.gitignore` handling, its `--exclude`
|
|
matching, its cycle guard and its warnings, and is now a two-line wrapper over
|
|
the first of them. The 102 tests this feature and `parallel-files` left behind
|
|
all pass unchanged; seven were added.
|
|
|
|
- **`collect_files_with(input, exclude, gitignore, found, warn)`** hands each
|
|
file to `found(path, Option<u64>)` instead of pushing it onto a `Vec`. The
|
|
length is `meta.len()` off the **`metadata` call the walk already makes on
|
|
every directory entry** to answer "directory?" — so the walk costs nothing
|
|
more and a caller that needs sizes (`lucisv_server`'s
|
|
`lucisv.index.maxFileSize` cap) stops making 3 976 of its own. `None` means
|
|
the walk did not stat: `input` naming a file rather than a directory is
|
|
handed straight over, with no `metadata` call added to a path that never
|
|
needed one.
|
|
- **`collect_files_below(root, input, …)`** walks `input`, which lies under
|
|
`root`, finding exactly what a walk of `root` would have found there. It
|
|
pushes each ancestor's `.gitignore` onto the rule stack at the depth that
|
|
ancestor sits at, and it yields **nothing** when one of those ancestors is
|
|
itself ignored or excluded — because a walk of `root` would never have
|
|
descended into it. `input` not under `root` finds nothing and is not an
|
|
error.
|
|
|
|
The second exists because `lucisv_server` walks one folder of a scope whose
|
|
rung is the *root*, and a walk that starts below a root would otherwise index
|
|
what that root's rules exclude. Its three tests assert equality with the
|
|
whole-root walk restricted to the same subtree — including the case where a
|
|
deeper `.gitignore`'s `!` line re-includes what the root's rule dropped, which
|
|
is where the `base` depth of a pre-loaded ignore file has to be exactly right.
|
|
|
|
**2026-09-05 — dev (Opus 5).**
|
|
|
|
*43.1, `crates/lucisv_core/src/walk.rs`.* `Walk` gained
|
|
`visited: HashSet<DirId>` and one method, `enter`, which is the whole policy:
|
|
`dir_id(dir).is_some_and(|id| self.visited.insert(id))`. `dir()` calls it
|
|
first and returns `Ok(())` when it answers false, so a directory already
|
|
entered costs one `metadata` call and nothing else — no `read_dir`, no
|
|
ignore-stack push, no recursion. `DirId` is `(u64, u64)` under `#[cfg(unix)]`
|
|
from `MetadataExt::dev`/`ino`, and `PathBuf` from `fs::canonicalize`
|
|
otherwise; `dir_id` returns `Option`, and `None` (a dangling link, a
|
|
directory that vanished mid-walk) means "not entered".
|
|
|
|
The entry loop's `path.is_dir()` became one `fs::metadata(&path)` — the same
|
|
single stat, and it follows symlinks exactly as `is_dir()` did, so a
|
|
symlinked directory is still recognized as a directory. Three things fall out
|
|
of having the metadata rather than a bool: `meta.is_dir()` for the walk arm,
|
|
`meta.is_file()` for the collect arm, and a dangling link (no metadata at
|
|
all) skipped by the `let … else { continue }` in front of both. The extension
|
|
test moved into a small `is_source` helper so the collect arm stays one line.
|
|
|
|
The one behaviour change beyond termination that a user could notice: a
|
|
dangling symlink named `x.sv` used to be *collected* and then failed at read
|
|
time. It is now skipped. That is in the plan's test list ("a dangling symlink
|
|
is skipped") and is the same judgment as the directory case.
|
|
|
|
Six unit tests in `walk.rs`, all `#[cfg(unix)]` because they need real
|
|
symlinks, over a `TempTree` helper in the test module (the third such helper
|
|
in the crate — `config.rs` and `cache.rs` have their own; a fourth copy is
|
|
cheaper than a shared test-support module for two dozen lines). Each of them
|
|
would have run until the OS refused a path before this change.
|
|
|
|
*43.2, three crates.* `NetDelay` gained `before_hash` and `after_hash`.
|
|
`parse_net_delay` takes the first with `take_gap()` **after** the
|
|
`cur().is_sym("#")` check — the `gap_before("#")` contract, spelled out
|
|
rather than called, because the check is already there for the `is_net` gate
|
|
— and the second with `take_gap()` after the `bump()`.
|
|
|
|
`Fmt::net_delay` now owns the separator in front of the delay as well as the
|
|
delay: it emits the `before_hash` comments *instead of* the plain space when
|
|
there are any, and the plain space when there are not, so a declaration with
|
|
no comment there is laid out byte-identically to before. That moved the
|
|
trailing space off `net` (`text(format!("{net} "))` → `text(net.clone())`)
|
|
and off the data type, which is why `data_decl` changed shape slightly; the
|
|
two call sites are now inside the `if let Some(net)` and
|
|
`if let Some(t) = self.data_type(…)` arms, which is also correct, since a
|
|
delay is only ever read after a net keyword, and an after-type delay only
|
|
after a data type that was actually written.
|
|
|
|
*Deviation from the plan: `after_hash`.* The plan asks for `before_hash`
|
|
only, and also asks that the gap fuzzer cover the new slot. Those two are in
|
|
tension: `assert_no_failing_gaps` demands **zero** failures across a fixture
|
|
set, and the smallest fixture that exercises `before_hash` (`wire #5 a;`)
|
|
also contains the gap between `#` and `5`, which had no owner either. So the
|
|
fixture could not be added without it. `after_hash` is four lines (one field,
|
|
one `take_gap`, one `slot_comments`) on the same construct, and closes the
|
|
delay's own gaps completely; the alternative was to leave the fuzzer without
|
|
a net-delay fixture, which is the thing the plan explicitly asked for. Flagged
|
|
here for the lead.
|
|
|
|
The gaps inside `#( 1:2:3 )` are *not* closed — eight of them, measured with
|
|
the fixture `wire [7:0] #(1:2:3) b = c;` before it was narrowed to `#1`. They
|
|
live in `parser/instance.rs::parse_delay_values`, shared with gate
|
|
instantiation delay lists, fail identically there, and are §2.9-22 shared
|
|
machinery. The RTL fuzzer fixture is `wire #5 a;` / `wire [7:0] #1 b = c;`,
|
|
which covers both sides of the type and both new slots; `EXPECTED_RTL_GAPS`
|
|
352 → 374, zero failures.
|
|
|
|
*Files touched outside the plan's expected set.* None beyond what the plan
|
|
names, with one addition: `crates/vlog_formatter/tests/verification.rs` (the
|
|
gap fuzzer's fixture and count — the plan says "find how the fuzzer
|
|
enumerates slots and add this one", which is this file). Full list:
|
|
`crates/lucisv_core/src/walk.rs`, `crates/lucisv/tests/cli.rs`,
|
|
`crates/lucisv_server/src/state.rs` (test only),
|
|
`crates/vlog_parser/src/ast/decl.rs`,
|
|
`crates/vlog_parser/src/parser/decl.rs`,
|
|
`crates/vlog_formatter/src/format/decl.rs`,
|
|
`crates/vlog_formatter/tests/cases/net_delay_position.cases`,
|
|
`crates/vlog_formatter/tests/verification.rs`, `TODO.md`, this README.
|
|
|
|
*Do the tests have teeth?* Asked directly rather than assumed: the `enter`
|
|
call was short-circuited (`if false && !self.enter(dir)`) and the walk tests
|
|
re-run. Three of the six failed — the self-loop, the ancestor link and the two
|
|
links — with paths 31 levels of `a/up/` deep, which is what the OS refuses at
|
|
rather than a hang. The other three (the sibling link, the dangling link, the
|
|
ignored cycle) pass either way by construction: they are about the *other*
|
|
half of the policy. The short-circuit was reverted immediately and the file
|
|
compared against a copy taken before it; `walk::` is green again.
|
|
|
|
*Gates, all guarded.* `cargo fmt --check` on the five touched crates: clean.
|
|
`cargo clippy --all-targets`: clean, no new `#[allow]`. `cargo test
|
|
--workspace`: **3 788 passed, 0 failed** (baseline 3 780 + the 8 tests this
|
|
round adds: 6 in `walk.rs`, 1 CLI, 1 server). `tools/corpus_check.sh`:
|
|
**814/820 (99.3%)**, the same six failures (five parse, one lex) and the same
|
|
10 already-clean files. Byte-identity: no corpus file writes a comment before
|
|
a net delay's `#` — checked with a direct grep over `corpus/`, 0 hits — and
|
|
the empty-slot path emits exactly the `text(" ")` it did before, so the
|
|
formatter's output over the corpus cannot have moved; the corpus counts
|
|
confirm it. `node editors/vscode/smoke.js target/release/lucisv-server`: OK,
|
|
20 messages. The cyclic scratch tree (a self-link, a `..` link one level down,
|
|
a `../../..` link three levels down, a second name for one directory, and a
|
|
dangling `x.sv` link) through both release binaries under
|
|
`tools/guard.sh -t 120`: `lucisv --check` finishes in ~1s and names its three
|
|
files once each; an LSP session (initialize with that `rootUri`, `initialized`,
|
|
one `didOpen`, `workspace/symbol`) finishes in ~1s with each package indexed
|
|
exactly once. No guard kill anywhere in the round.
|
|
|
|
### 2026-09-05 — lead, at review
|
|
|
|
QA's MEDIUM (the dangling-symlink change made a "no such file" error
|
|
silent) is ruled and fixed: a dangling link that *names a source file* is
|
|
handed on again, so the front end reports it exactly as 0.42.0 did (exit 2);
|
|
a dangling link to anything else is skipped as the dev wrote. The test is
|
|
renamed to say both halves. QA's LOW (a link to `/` is followed and the
|
|
first permission-denied directory aborts the whole walk, dropping the files
|
|
already found) is pre-existing `?` propagation and is filed as topo §2.9-30
|
|
together with the warning channel the walk lacks. The opentitan
|
|
`tlul_adapter_vh.sv` divergence QA root-caused is §41's canonical dedup
|
|
reporting a same-directory symlink alias once — the intended change, noted
|
|
in 0.43.0's release notes.
|
|
|
|
**2026-09-09 — the identity is now shared across walks (review finding F1).**
|
|
43.1's contract — *each directory is entered once, by identity, and its files
|
|
are reported under the first path that reached it* — was a contract about one
|
|
`Walk`. The 0.52.0 startup scan discovers its scope in two walks (the user's
|
|
own folder, then the rest of the workspace: `docs/features/perf5r-first-answer/README.md`),
|
|
and two `Walk`s meant two `visited` sets, so a symlinked directory reached by
|
|
both was reported twice under two spellings and the index held every module in
|
|
it twice — a valid rename refused as ambiguous
|
|
([the review](../../performance_052_review.md#f1--p2--split-startup-discovery-duplicates-modules-behind-directory-aliases)).
|
|
|
|
The set is now a value a caller may own: `Walk::visited` became
|
|
`Walk.tracker: &mut DirectoryTracker`, and `collect_files_tracked` /
|
|
`collect_files_below_tracked` take one. The **policy is unchanged** — the same
|
|
`(dev, ino)` identity, the same enter-once rule, the same silent skip, the
|
|
same dangling-link handling, and `collect_files_with`/`collect_files_below`
|
|
still make a tracker of their own so a single walk behaves byte for byte as it
|
|
did. What is new is a second answer for the caller that shares one:
|
|
`DirStatus::PrecedenceConflict` says "already entered, under a path this one
|
|
sorts *before*" — which is the case where the enter-once rule and a walk of
|
|
the root would pick different spellings. A single walk never sees it (it meets
|
|
the first spelling first, by construction); only a split does, and the server
|
|
answers it with one ordinary rescan rather than by guessing.
|
|
|
|
Two `lucisv_core` unit tests pin the tracker itself
|
|
(`tracker_detects_precedence_conflict_when_alias_sorts_before`,
|
|
`tracker_allows_alias_sorting_after_without_conflict`); nine server fixtures
|
|
in `server/tests/startup.rs` pin what the server does about it, cycles
|
|
included — `sub/up -> ..` still terminates, still names each file once, and
|
|
now agrees with a plain walk about how it spells them.
|
|
|
|
## QA log
|
|
|
|
**2026-09-05 — QA (Sonnet).** Built `target/release/{lucisv,lucisv_server}` once
|
|
and attacked both halves of the round on scratch trees under
|
|
`tools/guard.sh -t 120`; nothing was ever killed (no memory or wall-clock hit)
|
|
in this pass.
|
|
|
|
*Diff review.* Read `crates/lucisv_core/src/walk.rs`,
|
|
`crates/vlog_parser/src/{ast,parser}/decl.rs`,
|
|
`crates/vlog_formatter/src/format/decl.rs`, the two test files, and
|
|
`crates/lucisv/tests/cli.rs` / `crates/lucisv_server/src/state.rs` line by
|
|
line against the plan. Traced the `data_decl` reshuffle by hand for the
|
|
empty-slot case on both sides of the type: `net_delay`'s separator branch
|
|
degrades to the same `text(" ")` the old unconditional call emitted, so a
|
|
declaration with neither a delay nor a comment is unaffected — confirmed
|
|
this holds for the "after_type but no data_type" case too, which cannot
|
|
arise (`parse_net_delay(is_net, true)` only ever succeeds after
|
|
`parse_opt_data_type` actually consumed tokens, since an omitted type
|
|
leaves the `#` for the `before` call to claim first).
|
|
|
|
*43.1 — cycle attacks (all via `tools/guard.sh -t 120`, actual wall times
|
|
well under that in every case).*
|
|
- Depth 1/2/3 cycles (`a/loop -> a`, `a/b/up -> ..`, `a/b/c/top -> ../../..`):
|
|
terminate, each file named once. Two-link cycle (`a/x -> ../b`,
|
|
`b/y -> ../a`): terminates, `ma.sv` and `mb.sv` each reported once, `mb.sv`
|
|
under the alias spelling `a/x/mb.sv` (first spelling reached, as documented).
|
|
Chain of 50 symlinked directories collapsing to one target: resolved
|
|
correctly and fast (single `metadata` call per hop, no manual recursion) —
|
|
no `ELOOP`, no slowdown.
|
|
- **Ancestor-of-start escape.** Built `start/out -> ../..` where the target is
|
|
*outside* `start` entirely (not just the walk's own root) and ran
|
|
`--check` with `start` as the CLI argument (not its parent). The link is
|
|
followed once — per the ruling, identity is the policy, not location — and
|
|
pulls in a sibling file and a grandparent-level file that are not inside
|
|
`start` at all. It terminates (~1s) because the walk eventually re-enters
|
|
`start` itself from the other direction and that's already visited. Not a
|
|
bug — this is the plan's own explicit choice (no budget, `rtl ->
|
|
../shared/rtl` must keep working) — but it is a real, user-visible
|
|
consequence: pointing lucisv at a subdirectory can pull in files from
|
|
outside it if that subdirectory contains an upward-and-back symlink.
|
|
Flagged as **LOW / informational** for the lead's record, not a defect.
|
|
- **Link to `/`.** Followed once, as the ruling implies it must be; spent
|
|
~14.6s doing real `readdir`/`stat` work under `/System`, `/Library`,
|
|
`/private` etc. before hitting a permission-denied directory, at which
|
|
point the *entire* run aborted with `error: <original start path>:
|
|
Permission denied` — none of the user's own files were reported, not even
|
|
the ones already found. Reproduced this abort-on-any-`read_dir`-error
|
|
behaviour with a controlled example (`crates/lucisv_core/src/walk.rs`'s
|
|
`dir()` uses `?` on `read_dir(dir)?.collect::<Result<_,_>>()?`, unchanged
|
|
by this diff) — it is pre-existing, not introduced by 43.1: the old,
|
|
cycle-blind walker would have followed `/` identically and hit the same
|
|
wall. Filed as **LOW / informational**, since it predates this round, but
|
|
worth the lead's attention because 43.1 is what makes "follow a link
|
|
outside the tree" a documented, intentional feature rather than an
|
|
accident — a link to `/` (or to any tree with a permission-restricted
|
|
subdirectory anywhere under it) now silently costs the *entire* check, not
|
|
just the linked file. Link to a real bounded tree (`/usr/share`, 250 MB):
|
|
walked completely in ~1s, correctly found and lex-errored on a
|
|
coincidentally `.sv`-named file (`vim/vim91/tutor/tutor1.sv`, Swedish
|
|
locale code) — confirms outside-of-start links are followed and that nothing
|
|
hangs on a moderately large real directory.
|
|
- Hard-linked **files**: reported twice, once per directory, confirming
|
|
identity is directory-only as documented. Two directories with identical
|
|
content but different inodes: both walked (not deduped) — confirmed
|
|
content-blind, inode-based identity.
|
|
- Gitignore interplay: a cycle inside an ignored directory never runs
|
|
(confirmed — the `loop` symlink inside `build/` was never touched); an
|
|
ignored symlinked directory name is skipped by that spelling but the real
|
|
target directory (different name, not itself ignored) is still walked
|
|
directly — this is unchanged, pre-existing per-spelling ignore matching,
|
|
not a 43.1 regression; a `.gitignore` inside a followed link's target
|
|
applies to the walk (its `sub/` pattern correctly hid the target's own
|
|
subdirectory when reached through the link).
|
|
- **The dangling `x.sv` behaviour change**, `lucisv format --check dir`
|
|
with a dangling `x.sv` link, new binary vs.
|
|
`~/.cache/lucisv-baselines/lucisv-0.42.0`: confirmed exactly as the
|
|
work log describes — 0.42.0 collects it, fails at read time
|
|
(`error: .../x.sv: No such file or directory`, exit 2, "1 file would be
|
|
reformatted, 1 file failed to format"); the new binary skips it silently
|
|
(exit 1, "1 file would be reformatted", no mention of `x.sv` anywhere).
|
|
**Finding, MEDIUM, for the lead's ruling** (this is what the plan and
|
|
TODO explicitly asked for, so not a defect against the dev — but the
|
|
silence itself is worth a second look): a dangling symlink named like a
|
|
source file usually means something real broke (a missing vendor drop, a
|
|
bad checkout), and the user now gets no signal at all instead of a
|
|
specific, actionable error. The CLI already has a precedent for this exact
|
|
tension — a missing file named in a `-f` filelist is a **warning on
|
|
stderr**, changing no exit code — and the same shape (warn, don't fail,
|
|
don't stay silent) seems like it would keep 43.1's win (no more hard
|
|
crash on a broken symlink) without losing the signal. Recommend the lead
|
|
decide whether `walk.rs` should carry a callback/return channel for this
|
|
one case, or whether silence is accepted as-is.
|
|
- **Both front ends.** CLI `--check` over a two-directory cyclic tree
|
|
(`rtl/self -> ../rtl`, `rtl/sub/up -> ..`): 2 files, once each. The same
|
|
tree over `lucisv_server` (drove the real binary over stdio, same framing
|
|
`talk_with` uses: `initialize` with that `rootUri` +
|
|
`workspace/didChangeConfiguration` for the wide index scope +
|
|
`workspace/symbol` queries): both declared modules found exactly once,
|
|
finished in-process with no hang. **File counts agree between CLI and
|
|
server for the same tree (2 and 2).**
|
|
Explicit file argument that is a symlink to a directory, and a start
|
|
directory that is itself a symlink: both work, both find the expected
|
|
file under the given spelling.
|
|
|
|
*43.2 — comment-slot attacks, all via `format --stdout`, then idempotency
|
|
(format twice) and a before/after comment-count check on every shape:*
|
|
`wire /* c */ #5 w;`, `wire // c` + `#5 w;` on the next line, `wire [7:0]
|
|
/* c */ #1 b = c;`, `wire # /* c */ 5 w;` (`after_hash`), both slots at once
|
|
(`wire /* c1 */ # /* c2 */ 5 w;`), two comments in one slot
|
|
(`wire /* one */ /* two */ #5 w;`), a comment on the after-type side
|
|
(`wire [7:0] /* c */ #1 b = c;`), `tri`/`wand` with a delay comment,
|
|
an attribute ahead of the module. All ten: format cleanly, round-trip
|
|
idempotent, comment count preserved exactly. The refused shapes stayed
|
|
refused and did **not** corrupt: all four gaps inside `#(1:2:3)` — before
|
|
`1`, around each `:`, after `3` — still fail with a `verification failed:
|
|
token stream diverges` error and no output, matching the "not taken" scope
|
|
in Handshakes (topo §2.9-22). Ran the gap fuzzer directly
|
|
(`cargo test -p vlog_formatter a_comment_in_every_rtl_gap_still_formats`
|
|
under guard): passes; confirmed `EXPECTED_RTL_GAPS` is 374 in the tree and
|
|
that the added fixture (`wire #5 a;\n wire [7:0] #1 b = c;`) genuinely
|
|
exercises both new slots (both are comment-free in the fixture itself, but
|
|
the fuzzer inserts a comment into every inter-token gap in turn, which is
|
|
what raised the count from 352).
|
|
|
|
*Gates, all guarded.* `cargo fmt --check` (five touched crates): clean.
|
|
`cargo clippy --all-targets`: clean, 0 warnings. `cargo test --workspace`:
|
|
**3 788 passed, 0 failed** — matches the work log exactly. Re-ran just
|
|
`lucisv_core`'s `walk::tests` in isolation: 17 passed (11 pre-existing + the
|
|
6 new ones), including the 6 cycle tests as their own filtered run.
|
|
`tools/corpus_check.sh`: **814/820 (99.3%)**, same 6 failures
|
|
(`ibex/dv/formal/check/peek/compare_helper.sv`,
|
|
`ibex/dv/uvm/core_ibex/riscv_dv_extension/riscv_core_setting.tpl.sv`,
|
|
`ibex/syn/rtl/latch_map.v`,
|
|
`ibex/vendor/google_riscv-dv/src/riscv_instr_cover_group.sv`,
|
|
`picorv32/scripts/romload/testbench.v`,
|
|
`picorv32/scripts/smtbmc/mulcmp.v`), same 10 already-clean files.
|
|
`node editors/vscode/smoke.js target/release/lucisv-server`: OK, 20
|
|
messages.
|
|
|
|
*Byte-identity vs 0.42.0.* Over the 820-file corpus, each file individually
|
|
through `format --stdout` (bypasses directory-walk dedup, isolates the
|
|
formatter itself): **0 differing**, exit codes included. Opentitan
|
|
`format --check` (using `--no-cache` on both sides after the first pass
|
|
showed cache-hit-count noise from a shared `.lucisv_cache`; see below) over
|
|
`hw/ip`, `hw/top_earlgrey/ip`, `hw/top_darjeeling/ip`, `hw/dv`, `hw/vendor`:
|
|
`hw/top_earlgrey/ip`, `hw/top_darjeeling/ip`, `hw/dv`, `hw/vendor` are
|
|
byte-identical between the two binaries (including exit codes: 1, 2, 1, 2
|
|
respectively). **`hw/ip` differs by exactly one file**:
|
|
`hw/ip/tlul/rtl/tlul_adapter_vh.sv` is reported "would reformat" by 0.42.0
|
|
and silently absorbed (not reported at all) by the new binary — 1773 vs.
|
|
1772 files. Root-caused, not a §43 regression: `hw/ip/tlul/rtl` contains
|
|
`tlul_adapter_shim.sv -> tlul_adapter_vh.sv`, a **symlinked file next to its
|
|
own target in the same directory**, and `crates/lucisv/src/main.rs`'s
|
|
`dedup()` (canonical-path fold, keeps the first spelling — this is §41,
|
|
already in trunk, *not* touched by this diff, and shipped in a release
|
|
*after* 0.42.0 per the loop order in `TODO.md`) now folds
|
|
`tlul_adapter_shim.sv`/`tlul_adapter_vh.sv` onto one entry, keeping
|
|
`tlul_adapter_shim.sv` (alphabetically first) and dropping the other.
|
|
Reproduced in isolation on a two-file scratch directory
|
|
(`real.sv` + `shim.sv -> real.sv`) with both binaries, `--no-cache`: 0.42.0
|
|
reports both, the new binary reports one — confirms this is `main.rs`'s
|
|
existing dedup (unmodified by 43.1/43.2) becoming visible only because the
|
|
0.42.0 baseline predates it, not anything in this round's diff. Filed as
|
|
**informational**, not a §43 finding: the "byte-identity vs 0.42.0" gate is
|
|
not a clean isolation of this round alone once §41/§42 sit between the
|
|
baseline and trunk; recommend future rounds diff against trunk-before-the-
|
|
lane (or the `wip-43` backup already under
|
|
`~/.cache/lucisv-baselines/`) for a true delta, and use 0.42.0 only for the
|
|
"nothing has moved since the last *release*" question. Confirmed
|
|
`git -C ~/repo/opentitan status --porcelain` still shows only the three
|
|
expected pre-existing modifications (`hw/ip/aes/dv/tb/tb.sv`,
|
|
`hw/top_darjeeling/ip/ast/rtl/ast.sv`, `hw/top_earlgrey/ip/ast/rtl/ast.sv`)
|
|
after all opentitan runs; `.lucisv_cache/` is gitignored and untouched by
|
|
this statement either way.
|
|
|
|
*Verdict:* **PASS.** No corruption, no idempotency break, no dropped
|
|
comment, in any attack. Both hard invariants around cycles (identity,
|
|
no budget) and the two new comment slots hold up under adversarial input,
|
|
and the refused inside-`#(...)` gaps stay refused rather than silently
|
|
accepted. Two behavioural points are flagged above for the lead's ruling
|
|
(the dangling-symlink silence, MEDIUM; the link-to-`/` full-run abort on a
|
|
permission wall, LOW/pre-existing) plus one informational note on the
|
|
baseline choice for byte-identity gates — none of them block this round.
|
|
|
|
## Review
|
|
|
|
**2026-09-05 — lead.** Accepted; ships in 0.43.0. 43.1 is the ruled policy
|
|
in one method — identity is the whole rule, and QA's cycles of every shape,
|
|
the 50-link chain and the two-link cycle all terminate with each file once.
|
|
The dev's `after_hash` slot beyond the plan is accepted: the gap fuzzer's
|
|
zero-failure bar made it necessary, and four lines on the same construct is
|
|
the right size; the `#(1:2:3)` interior stays §2.9-22's. The one behaviour
|
|
change QA flagged is corrected above so no user loses an error they had.
|
|
Both front ends share the walk unchanged in signature, and the byte-identity
|
|
gate over the corpus is 0 differing.
|