Skip to content

refactor(cmdline): move the shell lexer to core - #4331

Open
KuSh wants to merge 1 commit into
lex/10-consolidationfrom
lex/11-lexer-to-core
Open

KuSh wants to merge 1 commit into
lex/10-consolidationfrom
lex/11-lexer-to-core

Conversation

@KuSh

@KuSh KuSh commented Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator

The quote-, escape- and operator-aware lexer lived in discover/, but it holds no rewrite rule and no classification logic, and most of its callers are not discover: the permission gate (hooks/permissions.rs), the hook entry points (hooks/decision.rs, hooks/hook_cmd.rs, hooks/mod.rs) and rtk proxy (main.rs) all read shell commands through it. After #4138 made it the one place that says where a word, a quote, a substitution or a segment ends, that knowledge belongs in core, where every component can depend on it without depending on discover.

src/discover/lexer.rs moves to src/core/cmdline/lexer.rs as a rename. Import paths follow, the doc paths inside the file are qualified with their directory, and the lexer's documentation moves from discover/README.md to core/README.md. The consumer table there is now complete: split_for_permissions is also used by discover/registry.rs, contains_unattestable_construct by hooks/decision.rs, hooks/hook_cmd.rs and discover/mod.rs, and the pub(crate) scanning helpers shared with the rewriter's token walks are listed. The folder maps in docs/contributing/TECHNICAL.md, docs/contributing/ARCHITECTURE.md and .claude/rules/search-strategy.md point to the new location.

No behaviour or visibility change.

Test plan

  • cargo fmt --all --check && cargo clippy --all-targets -- -D warnings && cargo test --all: 6007 passing, clippy clean, at this commit
  • wincheck.sh (cfg(windows) type-check) clean
  • git show -M --stat records the file as a rename; no remaining reference to discover::lexer or discover/lexer.rs outside target/

Part of stack #4139 (#4129 → #4331). Based on #4138. Each commit gates green on its own, so the stack is bisectable.

🤖 Generated with Claude Code

@KuSh
KuSh added this pull request to stack #4139 September 28, 2026 03:23
@rtk-wshm-sync-bot rtk-wshm-sync-bot Bot added core documentation Improvements or additions to documentation refactor labels Sep 28, 2026
@rtk-wshm-sync-bot

Copy link
Copy Markdown

wshm · Automated triage by AI

📊 Automated PR Analysis

♻️ Type refactor
🟡 Risk medium

Summary

This PR relocates the shell lexer (previously lexer.rs under discover) into src/core/cmdline/lexer.rs, making it a shared core infrastructure module used by both the rewriter and permission gate. It also updates documentation (ARCHITECTURE.md, TECHNICAL.md, core/README.md, search-strategy.md) to reflect the new module location and its consolidated responsibilities.

Review Checklist

  • Tests present
  • Breaking change
  • Docs updated

Analyzed automatically by wshm · This is an automated analysis, not a human review.

@KuSh
KuSh force-pushed the lex/11-lexer-to-core branch from 9a6abfc to 7ca6f6f Compare October 1, 2026 18:32
@KuSh
KuSh force-pushed the lex/11-lexer-to-core branch 3 times, most recently from baed3e5 to 0e08bde Compare October 2, 2026 15:07
@KuSh
KuSh force-pushed the lex/11-lexer-to-core branch 2 times, most recently from 2e09021 to 8a3834d Compare October 7, 2026 07:16
@KuSh
KuSh force-pushed the lex/11-lexer-to-core branch 2 times, most recently from adb3556 to 6951254 Compare October 9, 2026 16:27
@KuSh
KuSh force-pushed the lex/11-lexer-to-core branch 2 times, most recently from 38f5fd9 to 47b4b9a Compare October 15, 2026 00:24
@KuSh
KuSh force-pushed the lex/11-lexer-to-core branch from 47b4b9a to c21d8f3 Compare October 15, 2026 12:03
@KuSh
KuSh force-pushed the lex/11-lexer-to-core branch from c21d8f3 to 241adf8 Compare October 19, 2026 16:38
@KuSh
KuSh force-pushed the lex/11-lexer-to-core branch from d572a28 to 804646f Compare November 1, 2026 16:42
@TaKO8Ki
TaKO8Ki self-requested a review November 2, 2026 11:25

@TaKO8Ki TaKO8Ki left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good. This pr just moves the lexer into core without changing its behavior.

@TaKO8Ki
TaKO8Ki force-pushed the lex/11-lexer-to-core branch from 804646f to 06147a0 Compare November 2, 2026 11:31
@KuSh
KuSh force-pushed the lex/11-lexer-to-core branch from 06147a0 to c22472b Compare November 3, 2026 00:58
@KuSh
KuSh force-pushed the lex/11-lexer-to-core branch from c22472b to 0976532 Compare November 3, 2026 06:27
@KuSh
KuSh marked this pull request as draft November 4, 2026 07:41
@KuSh
KuSh force-pushed the lex/11-lexer-to-core branch from 0976532 to 49e5689 Compare November 5, 2026 11:48
@KuSh
KuSh marked this pull request as ready for review November 5, 2026 12:22
@KuSh
KuSh force-pushed the lex/11-lexer-to-core branch from 49e5689 to 6b11d47 Compare November 17, 2026 01:42
@KuSh
KuSh force-pushed the lex/11-lexer-to-core branch from 6b11d47 to 3759760 Compare November 18, 2026 01:06
@KuSh
KuSh force-pushed the lex/11-lexer-to-core branch from 3759760 to 74419da Compare November 19, 2026 01:12
@KuSh
KuSh force-pushed the lex/11-lexer-to-core branch 2 times, most recently from 7937d8a to 8d87834 Compare November 25, 2026 02:13
@KuSh
KuSh force-pushed the lex/11-lexer-to-core branch from 8d87834 to 56b5acf Compare November 28, 2026 01:23
The quote-aware lexer in discover/lexer.rs holds no rewrite rule and no
classification logic, and it is already used outside discover: by the
permission gate (hooks/permissions.rs), the hook entry points
(hooks/mod.rs, hooks/decision.rs, hooks/hook_cmd.rs) and `rtk proxy`
(main.rs). Moving it to core/cmdline/lexer.rs puts shared shell knowledge
in core, where every consumer can depend on it without depending on
discover.

No behaviour or visibility change: import paths and doc references
follow the file, and its documentation moves from discover/README.md to
core/README.md, with every consumer listed.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@KuSh
KuSh force-pushed the lex/11-lexer-to-core branch from 56b5acf to ac37343 Compare November 29, 2026 01:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core documentation Improvements or additions to documentation refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants