Files
lucisv/tools/perf/phases_r3.py
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

91 lines
4.3 KiB
Python

#!/usr/bin/env python3
# Author: Guoliang Chen, a Senior Digital Design Engineer
"""The take-5 **review** round's phase for R3a/R3c: `extractrefuse`.
The `execute` phase runs the two command-bearing offers as a *user* would, and
one of them — the extraction at `aes_wrap.sv` 66:2 — refuses after about
805 ms. That refusal turned out to be `extract/boundary.rs`'s, four stages past
anything a region-local preflight can reach, so §61.1's extract preflight
cannot and does not move it.
What the preflight *does* move is the other half of the refusal list: a new
name that is not an identifier, a target file that is already occupied, a
buffer that does not parse, and every refusal about the selection's own shape.
None of those had a row, so shipping the preflight would have rested on unit
tests alone. This phase gives them one, at the **same site** as the 805 ms
refusal so the two numbers are directly comparable: same file, same cursor,
same session, same fan-out — the only difference is which refusal is reached.
Rows are `executeCommand` round trips with no edit pushed, exactly as
`phases_p0.execute_row` records a refusal, so `ms` is the whole round trip.
"""
import phases_p0
import schema
import sites
from harness import ARGS, code_action_params, phase, record, session
#: The command the extract offer carries. Named here rather than read off an
#: offer, because these rows deliberately send arguments no offer would: the
#: point is the refusal, not the lightbulb.
EXTRACT = "lucisv.extractModule"
#: `(row, new_name, shift)` — refusals at the site whose *scope-dependent*
#: refusal costs 805 ms. `shift` extends the selection's end character forward
#: so the range stops inside the instantiation instead of after it, which is
#: `Region::read`'s "partial item" refusal — the one the preflight moves.
#:
#: The name row is the control, and it is expected **not** to move:
#: `plain_identifier` was already `extract_module`'s first statement, ahead of
#: `Extraction::plan` and so ahead of the scope build. Keeping it in the phase
#: is what makes the other row's improvement attributable to the preflight
#: rather than to the session.
CASES = [
("control: new name is not an identifier (already pre-scope)",
"1_not_an_ident", 0),
("refused early: selection covers no whole item", "pulled_out", 20),
]
@phase("extractrefuse")
def phase_extractrefuse():
"""The preflight-reachable extract refusals, timed at the 805 ms site."""
_, path, needle, occurrence, offset = next(
row for row in sites.REFACTOR_SITES if row[0] == "inline-module")
params = code_action_params(path, needle, occurrence, offset)
uri = params["textDocument"]["uri"]
for row, new_name, shift in CASES:
with session("workspace", resolve_support=True, apply_edit=True,
create_files=True) as s:
phases_p0.open_and_settle(s, path)
rng = selection(params["range"], shift)
call = {"command": EXTRACT, "arguments": [uri, rng, new_name]}
s.take_notifications()
total, statuses, pushed = [], [], []
for _ in range(ARGS.tries + 1):
_, _, three, message, pushes = phases_p0.execute_once(s, call)
total.append(three)
statuses.append(schema.status_of(message))
pushed = pushes or pushed
status, text = statuses[-1]
record(phase="extractrefuse", row=row, ms=total,
status=status, message=text, result_count=len(pushed),
client=s.client_shape(), command=EXTRACT,
arguments=len(call["arguments"]), file=path,
position=rng["start"], new_name=new_name,
note="no edit was pushed, so ms is the whole "
"executeCommand round trip; the same site whose "
"scope-dependent refusal costs about 805 ms")
def selection(base, shift):
"""`base`, with its end moved `shift` characters forward — 0 leaves it
alone, which is the cursor the offer itself is made at."""
if not shift:
return base
end = dict(base["end"])
end["character"] = end["character"] + shift
return {"start": base["start"], "end": end}
# Author: Guoliang Chen. Lucisv is made by Guoliang Chen with love, luciochen.com