Skip to content

fix(lint): enable anti-slop/no-shape-in-symbol-names - #20785

Merged
nwparker merged 1 commit into
mainfrom
nwparker/anti-slop/no-shape-in-symbol-names
Sep 15, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/anti-slop/no-shape-in-symbol-names

Conversation

@nwparker

@nwparker nwparker commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 38 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​201 $\color{#cf222e}{\Huge{\mathbf{−}}}$​175 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​26
Prod 58 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​240 $\color{#cf222e}{\Huge{\mathbf{−}}}$​173 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​67

Based on #20726 (now merged) — review/merge that first. This PR's base is nwparker/2x-lint, so the diff shown here is only the rule flip plus the fixes.

What the rule rejects

anti-slop/no-shape-in-symbol-names bans the case-insensitive substring "shape" in any JS/TS identifier: variables, functions, parameters, types, type parameters, class members, private names, object-literal keys and JSX identifiers. The single exemption is a statically accessed member read owned by another value, so zodObject.shape needs no suppression.

Why it matters. "Shape" names a value's structure rather than its domain role. UserShape, validateArgShape, errorShape and FIELD_SHAPES all say "this is an object with some fields" — which is exactly what the type already says — while telling you nothing about what the value is for or who owns it. The name ends up carrying zero information, and the suffix spreads: once one type is FooShape, its validator becomes validateFooShape and its predicate isFooShaped. Forcing a domain name makes the symbol describe the concept instead of restating that it has properties.

Violations fixed

689 violations across 109 files, now zero. I verified the baseline count directly rather than trusting it: checked out the pre-change tree into a scratch worktree, flipped the rule to error, and counted — exactly 689 across 109 files, which lines up with the 110 files this PR touches (109 sources + the config flip).

Fix pattern

Rename for the domain role, not the structure:

-type FieldShape = 'list' | 'map' | 'whole'
-const FIELD_SHAPES = { ... } satisfies Record<keyof Observation, FieldShape>
+type FieldEncoding = 'list' | 'map' | 'whole'
+const FIELD_ENCODINGS = { ... } satisfies Record<keyof Observation, FieldEncoding>

-function assertGitPushTargetShape(target: unknown): void
+function assertValidGitPushTarget(target: unknown): void

-function describeReadDirPathShape(p: string): ReadDirPathKind
+function classifyReadDirPath(p: string): ReadDirPathKind

Predicates became statements about the value: isDeltaShapedProviderFrameKind → isDeltaProviderFrameKind, isDeleteShapedDiscardEntry → discardDeletesEntryFile, isSkillsCliAgentKeyShaped → isUsableSkillsCliAgentKey. Type aliases dropped the suffix where the remaining name was already unambiguous: GhGraphqlErrorShape → GhGraphqlError.

No wire-visible name was renamed — no IPC or RPC channel, stream opcode, request/response param, persisted field, or i18n key. The --shape=symlink|copy CLI flag that .github/workflows/skill-update-roundtrip.yml passes is unchanged; only the local variable holding it was renamed.

Suppressions

Four groups, all justified inline:

Where Why
browser-pane/annotate/ (12 files, file-wide) In the screenshot annotator a "shape" is the drawn geometry — pen, arrow, rect, ellipse, highlight. A genuine domain noun that pervades every symbol in the module, so file-wide is the honest granularity rather than 60 line suppressions.
repo-icon.tsx, repo-header-project-actions.tsx, mobile/MobileRepoIcon.tsx lucide-react exports the icon component as Shapes — the name is theirs. The matching REPO_LUCIDE_ICONS key is the persisted icon name shared with the desktop picker; renaming it would orphan saved repo icons.
onboarding-state-types.ts, constants.ts shapedSidebar is a persisted onboarding-checklist field and a telemetry enum member. Renaming orphans saved state.
telemetry-event-classification.ts, rpc-send-params.ts, repo-update-params.ts, ui-update-value-tolerance-params.ts zod's own shape property and its exported ZodRawShape type. In rpc-send-params.ts, matching the literal shape property is what selects the ZodObject branch of the conditional type.

No suppression was added merely to avoid a rename. Eight symbols were initially suppressed with the boilerplate excuse "renaming it is a cross-module refactor outside this change." Each was proven to have zero non-TypeScript references repo-wide and renamed instead — including all three blanket file-wide disables outside annotate/, which would have silently exempted any future violation in those files.

What a reviewer should scrutinise

  1. The boundary. This is a pure-rename PR, so the only real risk is an orphaned reference the compiler can't see — a string literal, a JSON key, a workflow input. Concretely: the --shape flag in verify-skill-update-roundtrip.mjs vs. the workflow matrix, the Shapes REPO_LUCIDE_ICONS key, and shapedSidebar.
  2. The renamed JSON output keys in six benchmark scripts (shape → topology/label/variant/inputCase/caseName/lineLayout, guestProcessShape → guestProcessChain). I found no programmatic consumer — they're reachable only via package.json bench scripts and the output is human-read — but if you know of an external dashboard parsing these, say so.
  3. discardDeletesEntryFile / deletesFile in the source-control toast path, the one rename where I also made a public option name consistent with its private helper. Positional call into entryFailureTitle was already correct, so there is no behavior change either way.
  4. Whether the 12 file-wide disables in annotate/ are the right call versus per-line. I think the domain-noun argument holds there and nowhere else.

How it was verified

  • Audit reports zero violations, via both the raw command and pnpm run audit:anti-slop (the CI script). I confirmed the rule genuinely fires by planting a probe violation — it reported 3 errors and exited 1.
  • node config/scripts/run-typecheck-projects-in-parallel.mjs exits 0, before and after the rebase, with no .js/.d.ts/.tsbuildinfo artifacts left behind.
  • 54 test files covering the changed sources and their siblings: 1010 passed, 2 skipped.
  • Boundary audit: extracted all 66 removed shape-containing identifiers from the diff and grepped the entire repo for each — every file type, not just TS. The only survivor is ZodRawShape, which is zod's own and intentionally suppressed. Zero orphans.
  • node --check on every changed .mjs (not covered by tsc); project oxlint clean on all 109 changed source files; oxfmt is a no-op.

Not verified

Stated plainly rather than papered over:

  • The 3 mobile/ files (MobileRepoIcon.tsx, golden-value-pool.ts, use-mobile-tasks-provider-view-projection.test.tsx). mobile/ is a separate pnpm workspace and its node_modules is not installed in this worktree, so its tsc and vitest could not run — I tried, and expo is unresolvable. They lint clean and I read all three diffs in full; they are pure renames, and golden-value-pool.ts renames only the type alias and const binding, not the serialized field names (sender, payloads, settlements, state, effects are untouched), so no golden file is invalidated.
  • browser-cookie-samesite.electron.test.ts (electron-gated), wsl-unc-delete.wsl.test.ts (real-WSL gated), and tests/e2e/terminal-cjk-ime-committed-text.spec.ts (Playwright) are unrunnable here by construction. All three are rename-only hunks read line by line. In the e2e spec only an array variable was renamed — test titles and screenshot slugs are unchanged.

Recreated from #20750, which GitHub auto-closed when its base branch was deleted on merge of #20726. Same branch, same commit, now targeting main directly.

@greptile-apps

greptile-apps Bot commented Sep 15, 2026

Copy link
Copy Markdown

Too many files changed for review (110 files, 100 file limit).

Bypass the limit by tagging @greptile-apps to review.

@coderabbitai

coderabbitai Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 4ca2fdeb-b811-4d79-9789-f5564bf1092d

📥 Commits

Reviewing files that changed from the base of the PR and between 1cf7759 and 14fcb25.

📒 Files selected for processing (1)
  • config/oxlint-anti-slop.json

Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.


📝 Walkthrough

Walkthrough

The change enables the anti-slop naming rule with scoped exemptions. It replaces ambiguous shape terminology across benchmarks, production code, shared contracts, renderer code, and tests. It also renames several exported helpers and types. Runtime behavior remains unchanged except for selected benchmark output field names and the explicit normalization added to the browser cookie test fixture.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 14fcb

No supported behavior or validation failure remains that should block merging.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 27.91% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 43 functions across 50 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary change: enabling the anti-slop rule.
Description check ✅ Passed The description gives a detailed change summary, rationale, suppression decisions, linked issue references, verification results, and known test limitations. It omits several exact template headings a…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 27.91% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 43 functions across 50 files. (1 skipped: 1 unsupported.)

  • Fix all pre-merge checks with AI

Warning

Some tools did not complete. Review the errors below.

🔧 Biome (2.5.10)
config/oxlint-anti-slop.json

File contains syntax errors that prevent linting: Line 59: Expected an array, an object, or a literal but instead found '// The exemptions below are file-scoped rather than inline; Line 69: End of file expected; Line 74: End of file expected; Line 75: End of file expected; Line 80: End of file expected; Line 83: End of file expected; Line 92: End of file expected; Line 95: End of file expected; Line 100: End of file expected; Line 103: End of file expected; Line 109: End of file expected


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

  • Rule flipped on — anti-slop/no-shape-in-symbol-names goes from "off" to "error" in config/oxlint-anti-slop.json, the only config where the rule is registered; 689 violations across 109 source files are cleared by renaming symbols so no identifier carries the case-insensitive substring "shape".
  • Suppression groups — four, all justified inline: the annotate/ geometry module (12 file-wide disables), lucide's Shapes icon (3 files), the persisted shapedSidebar field/telemetry member (2 files), and zod-owned ZodRawShape / literal shape key (4 files). No suppression exists merely to dodge a rename.
  • Boundary surfaces preserved — the --shape=symlink|copy workflow flag still reaches option('shape'); the persisted Shapes repo-icon key and shapedSidebar are untouched; no IPC/RPC channel, stream opcode, request/response param, persisted field, or i18n key was renamed.
  • Benchmark output keys — shape → topology/label/variant/inputCase/caseName/lineLayout and guestProcessShape → guestProcessChain; the eight changed benchmark scripts have no other reference repo-wide and no comparison harness reads those keys.

I re-ran the gates rather than trusting the description: pnpm run audit:anti-slop reports 0 warnings / 0 errors (24,798 files, 1 rule), and project oxlint on all 106 changed non-mobile files reports 0 warnings / 0 errors (176 rules, including max-lines). I also grepped the tracked tree for ~45 removed identifiers and found no stale references, and checked the load-bearing boundary strings directly. The rule implementation only visits Identifier/PrivateIdentifier/JSXIdentifier and exempts non-computed member reads, so filenames like rpc-response-shape.ts and comment prose are correctly outside its scope.

The one thing not machine-verified here is mobile/ typecheck/vitest (separate workspace, deps absent); the three mobile changes are file-local renames or comment-only, and audit:anti-slop does cover mobile and passed.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker force-pushed the nwparker/anti-slop/no-shape-in-symbol-names branch 2 times, most recently from 3a5e031 to 94ffd66 Compare September 15, 2026 06:48

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

This run covers the single new commit 94ffd66c15 since the prior Pullfrog review at ef867f19d1 (the intermediate 3a5e031212 was a patch-identical rebase).

  • Moved suppressions to file-scoped config overrides — config/oxlint-anti-slop.json now exempts annotate/**, the three lucide-Shapes files, constants.ts / onboarding-state-types.ts, and rpc-send-params.ts through overrides[].files, because an inline oxlint-disable directive naming an anti-slop rule reads as unused under the root oxlint scan that does not load the plugin.
  • Typed zod's shape out of the remaining call sites — repo-update-params.ts now constrains T extends Readonly<Record<string, z.ZodType>>, ui-update-value-tolerance-params.ts rewrote tolerateUnknownValues as an explicit loop, and telemetry-event-classification.ts returns object | null from eventSchemaFields, so no ZodRawShape suppression remains.
  • Reworked the browser cookie test fixture — browser-cookie-samesite.electron.test.ts maps raw SQLite rows into typed rows instead of asserting a cast on .all().
  • Renamed the remaining shape-named symbols and comments — including SendShape→SendFields, sendShape→sendFields, and use-site comments pointing at the config exemption.

I verified the mechanics rather than the description: pnpm run audit:anti-slop reports 0 warnings / 0 errors across 24,798 files (which also proves the JSONC comments and the **/ globs resolve), run-typecheck-projects-in-parallel.mjs exits 0, verify:rpc-params-catalog passes, check:code-quality:changed reports 0 new findings, and the UI-tolerance / repo-update / telemetry test files pass. The one thing not machine-verified here is mobile/ tsc + vitest (separate workspace, deps absent here); its three changes are local renames or comment-only and audit:anti-slop covers mobile.

ℹ️ PR description's suppression section no longer matches the code

The ## Suppressions section still says "Four groups, all justified inline" and lists telemetry-event-classification.ts, repo-update-params.ts, and ui-update-value-tolerance-params.ts as zod-owned suppressions. Those inline directives are gone, and the three blanket file-wide disables outside annotate/ that the body says were eliminated are back as config-level file globs — so a reader merging this will be misled about why the exemptions are shaped the way they are.

Technical details
# PR description no longer describes the actual suppression strategy

## Affected sites
- `config/oxlint-anti-slop.json` lines 59-98 — four `overrides[].files` entries exempt whole files from `anti-slop/no-shape-in-symbol-names`.
- PR body `## Suppressions` — table claims the exemptions are inline; `telemetry-event-classification.ts`, `repo-update-params.ts`, and `ui-update-value-tolerance-params.ts` no longer need any suppression (`ZodRawShape` was typed out of them in this commit).
- PR body `## Suppressions` closing paragraph — "including all three blanket file-wide disables outside `annotate/`, which would have silently exempted any future violation in those files" is contradicted by the new globs for `repo-icon.tsx`, `repo-header-project-actions.tsx`, and `MobileRepoIcon.tsx`.

## Required outcome
- Update the PR description so the suppression table and rationale describe the file-scoped config overrides, and state the deliberate trade-off: a whole-file exemption also hides any future `shape` identifier in those files.

## Open questions for the human
- Would registering the anti-slop plugin in the root `.oxlintrc.json` (rules off) let the inline directives be recognized there and avoid the whole-file exemptions entirely? If the config override is the intended long-term shape, a one-line note that the future-violation blind spot is accepted is enough.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker force-pushed the nwparker/anti-slop/no-shape-in-symbol-names branch from 94ffd66 to 1cf7759 Compare September 15, 2026 07:41
Flip `anti-slop/no-shape-in-symbol-names` from "off" to "error" and clear
every violation under src, config, tests and mobile.

What the rule bans
------------------
The case-insensitive substring "shape" in any JS/TS identifier: variables,
functions, parameters, types, type parameters, class members, private names,
object-literal keys and JSX identifiers. The one exemption is a statically
accessed member read owned by another value (`zodObject.shape` is fine), so
third-party APIs stay readable without a suppression.

"Shape" names a value's structure rather than its domain role. `UserShape`,
`validateArgShape` and `errorShape` all tell you the symbol is "an object
with some fields" -- which is already what a type says -- while saying
nothing about what the value is for or who owns it. The rule forces the
name to carry the domain instead.

Violations fixed
----------------
689 violations across 109 files at baseline (verified by re-running the
audit against the pre-change tree with the rule set to "error").

Fix pattern
-----------
Rename for the domain role, not the structure:

  -type FieldShape = 'list' | 'map' | 'whole'
  -const FIELD_SHAPES = { ... } satisfies Record<keyof Observation, FieldShape>
  +type FieldEncoding = 'list' | 'map' | 'whole'
  +const FIELD_ENCODINGS = { ... } satisfies Record<keyof Observation, FieldEncoding>

  -function assertGitPushTargetShape(target: unknown): void
  +function assertValidGitPushTarget(target: unknown): void

  -function describeReadDirPathShape(p: string): ReadDirPathKind
  +function classifyReadDirPath(p: string): ReadDirPathKind

Predicates became statements about the value (`isDeltaShapedProviderFrameKind`
-> `isDeltaProviderFrameKind`, `isDeleteShapedDiscardEntry` ->
`discardDeletesEntryFile`, `isSkillsCliAgentKeyShaped` ->
`isUsableSkillsCliAgentKey`). Type aliases dropped the suffix where the
remaining name was already unambiguous (`GhGraphqlErrorShape` ->
`GhGraphqlError`).

No wire-visible name was renamed: no IPC or RPC channel, stream opcode,
request/response param, persisted field, or i18n key. The `--shape=symlink|copy`
CLI flag read by .github/workflows/skill-update-roundtrip.yml is unchanged --
only the local variable holding it was renamed.

Exemptions
----------
They are file-scoped entries in config/oxlint-anti-slop.json, not inline
`oxlint-disable` comments. An inline directive naming an anti-slop rule reads
back as an UNUSED directive under the root lint scan, which does not load this
plugin -- the changed-code quality gate counts that warning, so the comment form
cannot be used for a rule that lives only in this config.

* src/renderer/src/components/browser-pane/annotate/**:
  in the screenshot annotator a "shape" is the drawn geometry -- pen, arrow,
  rect, ellipse, highlight. That is a genuine domain noun, and it pervades
  every symbol in the module.
* repo-icon.tsx, repo-header-project-actions.tsx, mobile MobileRepoIcon.tsx:
  lucide exports the icon component as `Shapes`. The name is theirs, and the
  matching REPO_LUCIDE_ICONS key is the persisted icon name shared with the
  desktop picker -- renaming it would orphan saved repo icons.
* src/shared/onboarding-state-types.ts, src/shared/constants.ts:
  `shapedSidebar` is a persisted onboarding-checklist field and a telemetry
  enum member; renaming it would orphan saved state.
* src/shared/rpc-contract/rpc-send-params.ts: matching zod's own literal `shape`
  property is what selects the ZodObject branch of the conditional type.

No exemption was added merely to avoid a rename. Eight symbols initially
suppressed as "a cross-module refactor outside this change" were proven to have
zero non-TypeScript references repo-wide and renamed instead.

Zod's `ZodRawShape` needed no exemption at all: `Readonly<Record<string,
z.ZodType>>` is its definition, so repo-update-params.ts and
ui-update-value-tolerance-params.ts spell it out instead. Likewise
telemetry-event-classification.ts now reads `.shape` through an `in` narrowing,
which also retires two pre-existing type assertions; three more assertions the
rename had dragged onto changed lines (two `JSON.parse` sites, one node:sqlite
row read) became annotations and an explicit row mapping.

Verified
--------
* Audit reports zero violations; confirmed the rule genuinely fires by
  planting a probe violation.
* node config/scripts/run-typecheck-projects-in-parallel.mjs exits 0.
* Vitest over src/shared, src/main/github/project-view, the annotate module,
  the repo-icon components and the Chromium SameSite electron spec: all green.
* All 66 removed "shape" identifiers grepped repo-wide across every file type;
  none survive.
* node config/scripts/generate-rpc-params-catalog.mjs --check exits 0.
* node --check on every changed .mjs; oxfmt clean on all changed files.
* `pnpm run check:code-quality:changed` reports 0 findings.

Not machine-verified: the 3 mobile/ files (its Vitest run cannot resolve
`expo/tsconfig.base.json` in this worktree), and the WSL- and Playwright-gated
specs. All are rename- or comment-only hunks, read in full.
@nwparker
nwparker force-pushed the nwparker/anti-slop/no-shape-in-symbol-names branch from 1cf7759 to 14fcb25 Compare September 15, 2026 08:17

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ No new issues found.

Reviewed changes

Incremental review — this run covers the net change from 1cf7759782 to 14fcb2538e, the only commit since the last reviewed head.

  • Exempted the golden recorder directory rather than renaming it — config/oxlint-anti-slop.json gains a **/test-support/rpc-recording/** file-scoped override. recorder-digest.ts hashes that directory's raw bytes into every golden's recorderSha256 header, so a rename — or even an inline directive — would invalidate all 208 recordings.
  • Reverted mobile/src/test-support/rpc-recording/golden-value-pool.ts — the FieldShape / FIELD_SHAPES / Shape renames are undone, restoring the file to its main bytes so the pinned golden digests stay valid.

I verified this rather than assuming it: pnpm run audit:anti-slop reports 0 warnings / 0 errors across 24,802 files (which also proves the new **/ glob matches), and git diff --merge-base main -- mobile/src/test-support/rpc-recording is empty, confirming the revert is byte-exact and no golden is invalidated. The exemption is load-bearing — the restored file still contains FieldShape / FIELD_SHAPES identifiers. No new actionable findings; the delta is a clean, well-documented response to the byte-pinning constraint.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker merged commit 231e805 into main Sep 15, 2026
53 checks passed
@nwparker
nwparker deleted the nwparker/anti-slop/no-shape-in-symbol-names branch September 15, 2026 09:00
nwparker added a commit that referenced this pull request Sep 15, 2026
main enabled anti-slop/no-shape-in-symbol-names (#20785) after this
branch was written. The predicate answers whether a path IS a home root,
not whether it resembles one.
nwparker added a commit that referenced this pull request Sep 17, 2026
…d take (#19865)

* fix(worktree): ask the execution host whose home a remote delete would take

`isDangerousWorktreeRemovalPath` read `os.homedir()` — the machine running
Orca — and then applied POSIX-only shape rules. SSH orphan cleanup feeds it
remote paths, so a Windows host profile (`C:\Users\bob`) was unrecognised from
a macOS/Linux desktop and the recursive delete lost its last guard, while a
coincidental client-home prefix could refuse a legitimate remote delete.

The removal route already resolves one execution host for the whole removal;
it now resolves one home authority the same way. `WorktreeRemovalHomeAuthority`
is `{ kind: 'client' }` or `{ kind: 'executionHost'; homePath }`, required at
every guard entry point, so the ambient read is unreachable from a remote
removal. The host's answer is the `$HOME` the SSH session already read on the
host during relay deploy — no new probe. Unresolved stays `null`, meaning
unknown, never "same as this client's".

Path-shape rules now cover Windows profiles (`C:\Users`, `C:\Users\<name>`,
any drive or UNC root, case-insensitively) and WSL UNC aliases, which front a
Linux filesystem and so take the POSIX shapes.

Fixes #18275

* fix(worktree): merge the duplicated removal-route import

The focused code-quality plugins deny `import/no-duplicates`.

* test(worktree): pin the IPC removal call site and the unknown-host-home refusal

Mutation testing found four survivors in the home guard:

- Swapping the IPC unregistered-removal call site to the client's home passed
  every suite while the remote delete could reach the host's own home. Only
  the runtime call site was pinned. Add the mirror test for the IPC path.
- Falling back to os.homedir() when the execution host reported nothing was
  indistinguishable from refusing; the client home never coincided with the
  probed path. Assert the fallback stays off with homedir pinned to the path.
- Comparing an execution-host home across path syntaxes survived because no
  row exercised the win32 home under POSIX ops: path.resolve manufactures
  <cwd>/C:/Users/bob, which every ancestor of the cwd contains.
- Dropping the bare /Users rule survived; add the row.

Also cover the forward-slash C:/Users/bob form normalizeRemoteHome reports
for a Windows host, which no existing row used.

* ci: re-run after an unrelated Electron probe startup timeout

* fix(lint): clear the casting and max-lines gates on the home guard

Rebasing onto main brings two gates this branch predates:
typescript/consistent-type-assertions at assertionStyle: never, and the
300-line ceiling that the added home lookup pushed
orca-runtime-remove-managed-worktree.ts past. The fixture casts carry
per-site SAFETY rationales; the route's git-options-and-listing step
moves into its own module, which also stops the local/SSH branch being
spelled twice in one expression.

* fix(lint): name the home predicate for what it matches

main enabled anti-slop/no-shape-in-symbol-names (#20785) after this
branch was written. The predicate answers whether a path IS a home root,
not whether it resembles one.

* fix(worktree): refuse a removal the execution host cannot vouch for

Review of the home guard found three ways it still let a delete proceed on
evidence about the wrong machine, or on no evidence at all.

`getPathOps` switches to win32 as soon as EITHER the worktree path or the repo
path looks Windows-absolute, and `//nas/share/repo` does. A POSIX worktree path
was then judged by Windows-only shape rules, which recognise `<root>\Users\<name>`
and nothing else, so `/home/alice` — and any client home outside `\Users` —
stopped matching and the last guard in front of a recursive delete went quiet.
The home question involves the worktree path and a home, never the repo path, so
the predicate now reads the path in its own syntax as well and refuses if either
reading names a home. A union of refusals can only ever refuse more.

An execution host that never reported its `$HOME` is `unverifiable`, and
`unverifiable` does not authorise a delete. `isRemovalHomeAuthorityResolved`
gates the two paths that recursively delete a directory —
`canSafelyRemoveOrphanedWorktreeDirectory` and
`canCleanupUnregisteredOrcaLeftoverDirectory` — because the orphan proof they
accept, a `.git` file at the top of a directory, is also what a bare-repo
dotfiles `$HOME` looks like, and there the guard is the only evidence there is.
`git worktree remove` is deliberately not gated: the host's own Git registry
already established that the path is a linked worktree of that repo, and a
missing second opinion does not retract a first one. An empty `$HOME` is
normalised to unanswered rather than read as a resolved home.

The IPC entry point spelled its host two ways. The metadata prune, the
archive-hook route and now the home authority came from
`getRepoExecutionHostId(repo)`, while the `git worktree list` and every delete
came from raw `repo.connectionId`. A row carrying only
`executionHostId: 'ssh:<target>'` therefore listed a remote checkout on this
client and deleted a same-named local path while the guards vouched for the
remote one; the mirror row did the reverse (#11163, previously fixed on the
runtime path only). Neither spelling is evidence about the other, so a row that
carries two host names is refused before anything is listed or deleted. Both
sides are spelled by `getRepoExecutionHostId`, so they can differ on content but
never on normalisation.

A `runtime:<env>` row refuses here for the same reason. It is not reachable
through this handler today — the renderer sends environment targets to
`worktree.rm`, and the host-qualified catalog refuses to list a runtime host —
so that arm closes a door rather than changing a flow.

Fixtures that register an SSH provider now report a host home, because a
connected relay session always has one: `remoteCliBridgeEnv` is assigned before
`registerSshGitProvider`, is never cleared, and providers are unregistered
before the session leaves `activeSessions`. The wiring lives in its own module
called from the harness rather than in `worktrees-test-module-mocks`, which
`vi.mock` factories import: reaching the production route module from there
pulls in `providers/ssh-git-dispatch` while it is being mocked, and the module
runner deadlocks.

* fix(worktree): compare removal host names after decoding, not as stored text

`getRepoExecutionHostId` returns a row's `executionHostId` as stored, while the
same row's `connectionId` is re-spelled through `toSshExecutionHostId`, which
percent-encodes. A byte compare of the two would refuse a perfectly consistent
row over a `%20`, so the two host ids are now compared after `parseExecutionHostId`
has decoded the target id out of each.

`runtime:<env>` and an unparseable id decode to no machine at all and match
nothing, including each other — a runtime-owned row has a null `connectionId`
and would otherwise read as local, which is a delete on this client.

* fix(lint): clear the static-analysis gates on the removal home authority

The type-aware audit rejects a `default` arm on a discriminated switch, so the
host-kind switch names `runtime` and `undefined` outright — which also makes a
host kind added later a compile error here rather than a silent fallthrough.

The two test casts the changed-code gate flagged are gone: the leftover-cleanup
meta is typed instead of asserted, and the unparseable-host-id case narrows to
`ExecutionHostId` with the SAFETY rationale the gate asks for.

* docs(worktree): say why an unroutable removal host is refused by a plain compare

The comparison refuses `runtime:<env>` because only the left operand can name
no machine — `repoRowHostId` comes from `connectionId` and is always `local` or
an `ssh:` id. That invariant was doing the work silently; an explicit null test
in its place was a branch no input can reach, so the reason is written down
instead.

* fix(worktree): gate the registered removal on the host home answer too

I argued `git worktree remove --force` did not need the host's home answer,
because the host's own Git registry had already established that the path is a
linked worktree of that repo. That is true and it is not enough: `git worktree
add` accepts a pre-existing empty directory, and that directory can afterwards
be somebody's `$HOME` — a build account's home, a container's `HOME=/workspace`.
Being a linked worktree proves provenance, not that the path is not a home, and
the remove deletes the checkout either way.

With the host's answer that case is already caught by containment. Without it
only the path shapes remain, and a home at a non-standard location
(`/var/home/<u>`, `/export/home/<u>`, `D:\\Profiles\\<u>`) has no shape to match.
So `findRegisteredDeletableWorktree` now requires the answer as well, and every
gate that authorises a delete is on the same rule.

The fixture that models a connected relay session moves out of `ipc/` and is
shared: four runtime specs register an SSH provider without one, and a live
provider implies a reported home in production.
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
Flip `anti-slop/no-shape-in-symbol-names` from "off" to "error" and clear
every violation under src, config, tests and mobile.

What the rule bans
------------------
The case-insensitive substring "shape" in any JS/TS identifier: variables,
functions, parameters, types, type parameters, class members, private names,
object-literal keys and JSX identifiers. The one exemption is a statically
accessed member read owned by another value (`zodObject.shape` is fine), so
third-party APIs stay readable without a suppression.

"Shape" names a value's structure rather than its domain role. `UserShape`,
`validateArgShape` and `errorShape` all tell you the symbol is "an object
with some fields" -- which is already what a type says -- while saying
nothing about what the value is for or who owns it. The rule forces the
name to carry the domain instead.

Violations fixed
----------------
689 violations across 109 files at baseline (verified by re-running the
audit against the pre-change tree with the rule set to "error").

Fix pattern
-----------
Rename for the domain role, not the structure:

  -type FieldShape = 'list' | 'map' | 'whole'
  -const FIELD_SHAPES = { ... } satisfies Record<keyof Observation, FieldShape>
  +type FieldEncoding = 'list' | 'map' | 'whole'
  +const FIELD_ENCODINGS = { ... } satisfies Record<keyof Observation, FieldEncoding>

  -function assertGitPushTargetShape(target: unknown): void
  +function assertValidGitPushTarget(target: unknown): void

  -function describeReadDirPathShape(p: string): ReadDirPathKind
  +function classifyReadDirPath(p: string): ReadDirPathKind

Predicates became statements about the value (`isDeltaShapedProviderFrameKind`
-> `isDeltaProviderFrameKind`, `isDeleteShapedDiscardEntry` ->
`discardDeletesEntryFile`, `isSkillsCliAgentKeyShaped` ->
`isUsableSkillsCliAgentKey`). Type aliases dropped the suffix where the
remaining name was already unambiguous (`GhGraphqlErrorShape` ->
`GhGraphqlError`).

No wire-visible name was renamed: no IPC or RPC channel, stream opcode,
request/response param, persisted field, or i18n key. The `--shape=symlink|copy`
CLI flag read by .github/workflows/skill-update-roundtrip.yml is unchanged --
only the local variable holding it was renamed.

Exemptions
----------
They are file-scoped entries in config/oxlint-anti-slop.json, not inline
`oxlint-disable` comments. An inline directive naming an anti-slop rule reads
back as an UNUSED directive under the root lint scan, which does not load this
plugin -- the changed-code quality gate counts that warning, so the comment form
cannot be used for a rule that lives only in this config.

* src/renderer/src/components/browser-pane/annotate/**:
  in the screenshot annotator a "shape" is the drawn geometry -- pen, arrow,
  rect, ellipse, highlight. That is a genuine domain noun, and it pervades
  every symbol in the module.
* repo-icon.tsx, repo-header-project-actions.tsx, mobile MobileRepoIcon.tsx:
  lucide exports the icon component as `Shapes`. The name is theirs, and the
  matching REPO_LUCIDE_ICONS key is the persisted icon name shared with the
  desktop picker -- renaming it would orphan saved repo icons.
* src/shared/onboarding-state-types.ts, src/shared/constants.ts:
  `shapedSidebar` is a persisted onboarding-checklist field and a telemetry
  enum member; renaming it would orphan saved state.
* src/shared/rpc-contract/rpc-send-params.ts: matching zod's own literal `shape`
  property is what selects the ZodObject branch of the conditional type.

No exemption was added merely to avoid a rename. Eight symbols initially
suppressed as "a cross-module refactor outside this change" were proven to have
zero non-TypeScript references repo-wide and renamed instead.

Zod's `ZodRawShape` needed no exemption at all: `Readonly<Record<string,
z.ZodType>>` is its definition, so repo-update-params.ts and
ui-update-value-tolerance-params.ts spell it out instead. Likewise
telemetry-event-classification.ts now reads `.shape` through an `in` narrowing,
which also retires two pre-existing type assertions; three more assertions the
rename had dragged onto changed lines (two `JSON.parse` sites, one node:sqlite
row read) became annotations and an explicit row mapping.

Verified
--------
* Audit reports zero violations; confirmed the rule genuinely fires by
  planting a probe violation.
* node config/scripts/run-typecheck-projects-in-parallel.mjs exits 0.
* Vitest over src/shared, src/main/github/project-view, the annotate module,
  the repo-icon components and the Chromium SameSite electron spec: all green.
* All 66 removed "shape" identifiers grepped repo-wide across every file type;
  none survive.
* node config/scripts/generate-rpc-params-catalog.mjs --check exits 0.
* node --check on every changed .mjs; oxfmt clean on all changed files.
* `pnpm run check:code-quality:changed` reports 0 findings.

Not machine-verified: the 3 mobile/ files (its Vitest run cannot resolve
`expo/tsconfig.base.json` in this worktree), and the WSL- and Playwright-gated
specs. All are rename- or comment-only hunks, read in full.
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
…d take (stablyai#19865)

* fix(worktree): ask the execution host whose home a remote delete would take

`isDangerousWorktreeRemovalPath` read `os.homedir()` — the machine running
Orca — and then applied POSIX-only shape rules. SSH orphan cleanup feeds it
remote paths, so a Windows host profile (`C:\Users\bob`) was unrecognised from
a macOS/Linux desktop and the recursive delete lost its last guard, while a
coincidental client-home prefix could refuse a legitimate remote delete.

The removal route already resolves one execution host for the whole removal;
it now resolves one home authority the same way. `WorktreeRemovalHomeAuthority`
is `{ kind: 'client' }` or `{ kind: 'executionHost'; homePath }`, required at
every guard entry point, so the ambient read is unreachable from a remote
removal. The host's answer is the `$HOME` the SSH session already read on the
host during relay deploy — no new probe. Unresolved stays `null`, meaning
unknown, never "same as this client's".

Path-shape rules now cover Windows profiles (`C:\Users`, `C:\Users\<name>`,
any drive or UNC root, case-insensitively) and WSL UNC aliases, which front a
Linux filesystem and so take the POSIX shapes.

Fixes stablyai#18275

* fix(worktree): merge the duplicated removal-route import

The focused code-quality plugins deny `import/no-duplicates`.

* test(worktree): pin the IPC removal call site and the unknown-host-home refusal

Mutation testing found four survivors in the home guard:

- Swapping the IPC unregistered-removal call site to the client's home passed
  every suite while the remote delete could reach the host's own home. Only
  the runtime call site was pinned. Add the mirror test for the IPC path.
- Falling back to os.homedir() when the execution host reported nothing was
  indistinguishable from refusing; the client home never coincided with the
  probed path. Assert the fallback stays off with homedir pinned to the path.
- Comparing an execution-host home across path syntaxes survived because no
  row exercised the win32 home under POSIX ops: path.resolve manufactures
  <cwd>/C:/Users/bob, which every ancestor of the cwd contains.
- Dropping the bare /Users rule survived; add the row.

Also cover the forward-slash C:/Users/bob form normalizeRemoteHome reports
for a Windows host, which no existing row used.

* ci: re-run after an unrelated Electron probe startup timeout

* fix(lint): clear the casting and max-lines gates on the home guard

Rebasing onto main brings two gates this branch predates:
typescript/consistent-type-assertions at assertionStyle: never, and the
300-line ceiling that the added home lookup pushed
orca-runtime-remove-managed-worktree.ts past. The fixture casts carry
per-site SAFETY rationales; the route's git-options-and-listing step
moves into its own module, which also stops the local/SSH branch being
spelled twice in one expression.

* fix(lint): name the home predicate for what it matches

main enabled anti-slop/no-shape-in-symbol-names (stablyai#20785) after this
branch was written. The predicate answers whether a path IS a home root,
not whether it resembles one.

* fix(worktree): refuse a removal the execution host cannot vouch for

Review of the home guard found three ways it still let a delete proceed on
evidence about the wrong machine, or on no evidence at all.

`getPathOps` switches to win32 as soon as EITHER the worktree path or the repo
path looks Windows-absolute, and `//nas/share/repo` does. A POSIX worktree path
was then judged by Windows-only shape rules, which recognise `<root>\Users\<name>`
and nothing else, so `/home/alice` — and any client home outside `\Users` —
stopped matching and the last guard in front of a recursive delete went quiet.
The home question involves the worktree path and a home, never the repo path, so
the predicate now reads the path in its own syntax as well and refuses if either
reading names a home. A union of refusals can only ever refuse more.

An execution host that never reported its `$HOME` is `unverifiable`, and
`unverifiable` does not authorise a delete. `isRemovalHomeAuthorityResolved`
gates the two paths that recursively delete a directory —
`canSafelyRemoveOrphanedWorktreeDirectory` and
`canCleanupUnregisteredOrcaLeftoverDirectory` — because the orphan proof they
accept, a `.git` file at the top of a directory, is also what a bare-repo
dotfiles `$HOME` looks like, and there the guard is the only evidence there is.
`git worktree remove` is deliberately not gated: the host's own Git registry
already established that the path is a linked worktree of that repo, and a
missing second opinion does not retract a first one. An empty `$HOME` is
normalised to unanswered rather than read as a resolved home.

The IPC entry point spelled its host two ways. The metadata prune, the
archive-hook route and now the home authority came from
`getRepoExecutionHostId(repo)`, while the `git worktree list` and every delete
came from raw `repo.connectionId`. A row carrying only
`executionHostId: 'ssh:<target>'` therefore listed a remote checkout on this
client and deleted a same-named local path while the guards vouched for the
remote one; the mirror row did the reverse (stablyai#11163, previously fixed on the
runtime path only). Neither spelling is evidence about the other, so a row that
carries two host names is refused before anything is listed or deleted. Both
sides are spelled by `getRepoExecutionHostId`, so they can differ on content but
never on normalisation.

A `runtime:<env>` row refuses here for the same reason. It is not reachable
through this handler today — the renderer sends environment targets to
`worktree.rm`, and the host-qualified catalog refuses to list a runtime host —
so that arm closes a door rather than changing a flow.

Fixtures that register an SSH provider now report a host home, because a
connected relay session always has one: `remoteCliBridgeEnv` is assigned before
`registerSshGitProvider`, is never cleared, and providers are unregistered
before the session leaves `activeSessions`. The wiring lives in its own module
called from the harness rather than in `worktrees-test-module-mocks`, which
`vi.mock` factories import: reaching the production route module from there
pulls in `providers/ssh-git-dispatch` while it is being mocked, and the module
runner deadlocks.

* fix(worktree): compare removal host names after decoding, not as stored text

`getRepoExecutionHostId` returns a row's `executionHostId` as stored, while the
same row's `connectionId` is re-spelled through `toSshExecutionHostId`, which
percent-encodes. A byte compare of the two would refuse a perfectly consistent
row over a `%20`, so the two host ids are now compared after `parseExecutionHostId`
has decoded the target id out of each.

`runtime:<env>` and an unparseable id decode to no machine at all and match
nothing, including each other — a runtime-owned row has a null `connectionId`
and would otherwise read as local, which is a delete on this client.

* fix(lint): clear the static-analysis gates on the removal home authority

The type-aware audit rejects a `default` arm on a discriminated switch, so the
host-kind switch names `runtime` and `undefined` outright — which also makes a
host kind added later a compile error here rather than a silent fallthrough.

The two test casts the changed-code gate flagged are gone: the leftover-cleanup
meta is typed instead of asserted, and the unparseable-host-id case narrows to
`ExecutionHostId` with the SAFETY rationale the gate asks for.

* docs(worktree): say why an unroutable removal host is refused by a plain compare

The comparison refuses `runtime:<env>` because only the left operand can name
no machine — `repoRowHostId` comes from `connectionId` and is always `local` or
an `ssh:` id. That invariant was doing the work silently; an explicit null test
in its place was a branch no input can reach, so the reason is written down
instead.

* fix(worktree): gate the registered removal on the host home answer too

I argued `git worktree remove --force` did not need the host's home answer,
because the host's own Git registry had already established that the path is a
linked worktree of that repo. That is true and it is not enough: `git worktree
add` accepts a pre-existing empty directory, and that directory can afterwards
be somebody's `$HOME` — a build account's home, a container's `HOME=/workspace`.
Being a linked worktree proves provenance, not that the path is not a home, and
the remove deletes the checkout either way.

With the host's answer that case is already caught by containment. Without it
only the path shapes remain, and a home at a non-standard location
(`/var/home/<u>`, `/export/home/<u>`, `D:\\Profiles\\<u>`) has no shape to match.
So `findRegisteredDeletableWorktree` now requires the answer as well, and every
gate that authorises a delete is on the same rule.

The fixture that models a connected relay session moves out of `ipc/` and is
shared: four runtime specs register an SSH provider without one, and a live
provider implies a reported home in production.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant