Skip to content

fix(lint): enable anti-slop/no-object-parameters - #20781

Merged
nwparker merged 1 commit into
mainfrom
nwparker/anti-slop/no-object-parameters
Sep 15, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/anti-slop/no-object-parameters

Conversation

@nwparker

@nwparker nwparker commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 54 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​214 $\color{#cf222e}{\Huge{\mathbf{−}}}$​95 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​119
Prod 67 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​379 $\color{#cf222e}{\Huge{\mathbf{−}}}$​203 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​176

Based on #20726 (now merged) — base is nwparker/2x-lint, not main. Review that one first.

What the rule rejects

anti-slop/no-object-parameters flags the broad object type on any function
input: declarations, function expressions, arrows, methods, call/construct
signatures and standalone function types. It also resolves local type aliases
and unions, so type Owner = object and object | Foo are caught too.

Why it matters: object accepts every non-primitive but exposes no properties.
It tells a reader nothing about what the function needs, lets unrelated values
through, and typically forces the callee (or a caller) to assert its way back to
a usable type. The rule's message asks for an owner-provided type, parsed at its
boundary.

Violation count

185 at baseline, all fixed. Verified by materialising the base-branch copies
of every changed file and linting them:

$ npx oxlint --config config/oxlint-anti-slop.json <base copies> | grep -c no-object-parameters
185

The rule is flipped off → error in config/oxlint-anti-slop.json.
121 files changed.

Fix pattern

Each object input was replaced with the type its owner already had — an
existing domain type where one existed (36 type-only imports added), a new named
alias where none did (40 added).

// before
let sshCapabilitiesByProvider = new WeakMap<object, GitCapabilityCache>()

export function getSshGitCapabilityCache(provider: object): GitCapabilityCache {

// after
let sshCapabilitiesByProvider = new WeakMap<SshGitProvider, GitCapabilityCache>()

export function getSshGitCapabilityCache(provider: SshGitProvider): GitCapabilityCache {

A meaningful subset of sites hold a value that is only ever compared by
reference — route keys, retry generations, lock owners, claim owners. Inventing
a shape for those would be a lie, so they get a named identity token instead:
Record<string, never>, the built-in WeakKey, or a unique symbol brand,
matching the branding already used in src/shared (StablePaneId,
SshProviderEpoch, ProviderRequestId, …).

/** Holder identity token: the registry only compares references, never reads fields. */
export type HostClientAcquisition = Record<string, never>

Two as unknown as casts became unnecessary once the parameter carried a real
type and were deleted. No new casts were added.

Suppressions

None. No oxlint-disable for this rule anywhere, no max-lines disable, and
no per-file max-lines bump.

Three files sat exactly at their max-lines cap, where the obvious fix would
have needed one extra import line. Since AGENTS.md forbids bumping the cap, each
was made line-neutral instead:

  • src/main/ipc/browser.ts — the guest-registration args type was private and
    duplicated inline in the test. It is now exported (renamed
    BrowserGuestRegistrationArgs → BrowserGuestArgs so the import fits) and
    browser.test.ts reuses it on one line instead of re-declaring the shape.
  • pane-scroll.ts — takes TerminalScrollIntentTarget through its existing
    ./pane-manager-types import, via a type-only re-export added there.
  • direct-rpc-client.ts — drops the identity parameter entirely; the
    session-identity check moved into the sendProbe callback that owns the
    token, so sendLivenessProbe() only checks connectedness.

Please look closely at

  1. relay-dial-stage.ts (mobile/src/transport/) — this one had a real bug
    mid-review. Typing the param Partial<RelayDialStageSource> compiles in
    isolation but breaks the only caller: every property is optional, so
    TypeScript's weak-type check rejects RpcClient, which shares none of them
    (TS2559). It is now RpcClient & Partial<RelayDialStageSource> narrowed by
    a type predicate, which keeps the original reference-returning behaviour and
    needs no assertion. Mobile is not covered by pnpm tc, so this would not have
    been caught by the normal gates — see verification below.
  2. The three object & { brand } aliases — RpcSessionIdentity,
    GitHubChecksContextOwner, RendererPtyVisibilityClaimOwner. These are
    structurally still object (the brand is optional, so any object is
    assignable); they satisfy the rule by being named and documented rather than
    by narrowing. That is deliberate for opaque reference tokens, but it is the
    weakest form of fix in this PR and worth a second opinion. The alternative —
    making RpcSessionLivenessWatchdog generic over the session type — is a
    larger refactor across 4 files that mobile's (unrunnable) tests could not
    validate here, so I left it out.
  3. pane-scroll.ts key type — I first tightened it to Terminal, which
    typechecks for every caller but one: terminal-structural-replay-coordinator
    declares its own param as TerminalScrollIntentTarget. Reverted to the wider
    type. The re-export through pane-manager-types is slightly inconsistent with
    the 8 other modules that import this type directly from
    ./terminal-scroll-intent; it is done that way purely to stay under the line
    cap, and is type-only so it is erased at runtime.

Verification

  • npx oxlint --config config/oxlint-anti-slop.json src config tests mobile → exit 0, zero violations.
    Sanity-checked that the rule actually fires by linting a scratch file with an
    object param first, so "zero" is not a silently-misconfigured run.
  • node config/scripts/run-typecheck-projects-in-parallel.mjs → exit 0.
  • pnpm test over the 144 affected test files (changed tests, sibling tests of
    changed sources, and tests importing the changed test-harness modules) →
    144 files, 1749 passed, 1 skipped.
  • npx oxlint and npx oxlint --config config/oxlint-react-doctor.json on all
    changed files → exit 0. npx oxfmt --write applied to all changed files.

Mobile caveat, stated plainly: mobile/node_modules/expo is not installed in
this worktree, so mobile's vitest and tsc both fail before running any code —
including on completely untouched files and on the base branch. Mobile is also
not part of pnpm tc. To avoid shipping its 6 changed files unverified, I
typechecked the mobile tree with a standalone tsconfig (no expo base) on both
the base branch and this branch and diffed the results: error sets are
byte-identical, including test files.
I also confirmed that probe detects the
relay-dial-stage bug above (it reports TS2559) before the fix and not after,
so the check is not blind. Mobile tests themselves have not been executed.


Recreated from #20743, 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 (121 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

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

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: 61be3eed-d677-479f-8f48-09d740c78135

📥 Commits

Reviewing files that changed from the base of the PR and between 722a940 and 4157e1b85b2c5afdb75980e226b92725fc2dfeb6.

📒 Files selected for processing (2)
  • config/oxlint-anti-slop.json
  • src/main/runtime/runtime-linear-command-surface.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/runtime/runtime-linear-command-surface.ts

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


📝 Walkthrough

Walkthrough

The pull request enables anti-slop/no-object-parameters and replaces generic object annotations with domain-specific, structural, and branded types across mobile, main-process, relay, and renderer code. It updates test doubles to match production contracts. It also adds typed relay payloads, typed persistence targets, typed terminal identities, and a liveness-probe identity guard. Most runtime behavior remains unchanged.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to 4157e

The updated contracts and test mocks do not introduce a supported current-head failure, so the change is mergeable with normal checks.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the implementation and verification in detail, but it does not follow the repository template. It omits the required section headings, an explicit Linked Issue entry, Visual P… Restructure the description using the required template. Add the missing sections and checklist items, include an explicit issue reference such as Fixes #20726 or `Fixes `#20743, and write N/A with a brief reason under Visual Proof beca…
Docstring Coverage ⚠️ Warning Docstring coverage is 10.96% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 73 functions across 59 files. (1 skipped:… Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the main change: enabling the anti-slop/no-object-parameters lint rule.
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: Description check

Explanation

The description explains the implementation and verification in detail, but it does not follow the repository template. It omits the required section headings, an explicit Linked Issue entry, Visual Proof with N/A justification, checklist items, and the Agent skill upstream boundary section.

Resolution

Restructure the description using the required template. Add the missing sections and checklist items, include an explicit issue reference such as Fixes #20726 or `Fixes `#20743, and write N/A with a brief reason under Visual Proof because this change has no UI or interaction impact.

Full details: Docstring Coverage

Explanation

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

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

@coderabbitai coderabbitai 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.

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 4a4ef3a0-9519-4c75-8e36-d145525e45af

📥 Commits

Reviewing files that changed from the base of the PR and between 11180fa and de8e3bb.

📒 Files selected for processing (121)
  • config/oxlint-anti-slop.json
  • config/scripts/agent-status-hot-path-benchmark.test.ts
  • config/scripts/happy-dom-mutation-observer-retention.ts
  • mobile/src/diagnostics/connection-diagnostics-screen-data.ts
  • mobile/src/session/mobile-terminal-viewport-resubscribe.ts
  • mobile/src/transport/direct-rpc-client.ts
  • mobile/src/transport/host-client-acquisition-registry.ts
  • mobile/src/transport/relay-dial-stage.ts
  • mobile/src/transport/rpc-session-liveness-watchdog.ts
  • src/main/ai-vault-search/session-search-clock.ts
  • src/main/artifacts/artifact-cloud-recovery.test.ts
  • src/main/browser/agent-browser-bridge-test-harness.ts
  • src/main/browser/browser-cookie-import-clear.ts
  • src/main/browser/browser-cookie-import-concurrency.test.ts
  • src/main/browser/browser-cookie-import-google-exclusion.test.ts
  • src/main/browser/browser-cookie-import-partition-fidelity.test.ts
  • src/main/browser/browser-cookie-import-replacement.test.ts
  • src/main/browser/browser-cookie-import-route-partition-staging.test.ts
  • src/main/browser/browser-cookie-import-scope.test.ts
  • src/main/browser/browser-cookie-import-undecryptable.test.ts
  • src/main/browser/browser-cookie-import.test.ts
  • src/main/browser/cdp-keyboard-us-layout.test.ts
  • src/main/browser/doc-preview-download-block-notice.test.ts
  • src/main/codex-accounts/managed-codex-auth-readiness.test.ts
  • src/main/codex/codex-session-migration-scheduler.ts
  • src/main/daemon/daemon-pty-adapter-history-recovery.test.ts
  • src/main/git/git-capability-state.test.ts
  • src/main/git/git-capability-state.ts
  • src/main/ipc/browser-preview-tool-authorization.test.ts
  • src/main/ipc/browser.test.ts
  • src/main/ipc/browser.ts
  • src/main/ipc/filesystem-test-harness.ts
  • src/main/ipc/runtime-watcher-process-pool.test.ts
  • src/main/ipc/settings.test.ts
  • src/main/ipc/worktrees-authoritative-local-metadata-pruning.test.ts
  • src/main/ipc/worktrees-lineage-hydration.test.ts
  • src/main/ipc/worktrees-test-ipc-surface.ts
  • src/main/native-chat/wsl-transcript-fs-process-dispatch.ts
  • src/main/network/electron-proxy-credentials.ts
  • src/main/opencode/hook-plugin-fail-open-ownership.test.ts
  • src/main/opencode/hook-plugin-lifecycle-delivery.test.ts
  • src/main/persistence/loading-store/automation-persistence.ts
  • src/main/persistence/loading-store/metadata-lineage-operations.ts
  • src/main/persistence/loading-store/mobile-tab-selection-persistence.ts
  • src/main/persistence/loading-store/primary-state-writes.ts
  • src/main/persistence/loading-store/profile-preferences.ts
  • src/main/persistence/loading-store/project-collection-operations.ts
  • src/main/persistence/loading-store/pty-binding-persistence.ts
  • src/main/persistence/loading-store/repo-lifecycle-operations.ts
  • src/main/persistence/loading-store/retired-worktree-name-persistence.ts
  • src/main/persistence/loading-store/session-host-partitions.ts
  • src/main/persistence/loading-store/session-snapshot-operations.ts
  • src/main/persistence/loading-store/sparse-preset-persistence.ts
  • src/main/persistence/loading-store/ssh-lease-recovery-operations.ts
  • src/main/persistence/loading-store/ssh-profile-operations.ts
  • src/main/persistence/loading-store/store-domain-composition.ts
  • src/main/persistence/loading-store/write-flush-barriers.ts
  • src/main/persistence/loading-store/write-scheduling.ts
  • src/main/persistence/tracking-repos/missing-local-worktree-metadata-pruning.test.ts
  • src/main/runtime/browser-client-download-transfer-store.ts
  • src/main/runtime/browser-host-lease-download-transfer-cleanup.test.ts
  • src/main/runtime/relay/relay-control-client.test.ts
  • src/main/runtime/relay/relay-control-client.ts
  • src/main/runtime/relay/relay-control-requests.ts
  • src/main/runtime/runtime-browser-page-registry.ts
  • src/main/runtime/runtime-linear-command-surface.ts
  • src/main/runtime/structured-session-worktree-teardown.test.ts
  • src/main/runtime/structured-worker-terminal-read.test.ts
  • src/main/source-control/hosted-review-branch-cache.ts
  • src/main/worktree-retirement-backfill-scan.test.ts
  • src/main/worktree-retirement-backfill-scan.ts
  • src/relay/dispatcher-frame-guard-regressions.test.ts
  • src/relay/dispatcher.test.ts
  • src/relay/relay-filesystem-watch-registry.test.ts
  • src/renderer/src/components/agent/AgentSettingsDialog.test.tsx
  • src/renderer/src/components/dashboard/useAgentBucketCounts.gate.test.ts
  • src/renderer/src/components/diff-comments/useDiffCommentDecorator.model-lifecycle.test.tsx
  • src/renderer/src/components/editor/markdown-preview-search.ts
  • src/renderer/src/components/editor/rich-markdown-auto-focus.test.ts
  • src/renderer/src/components/editor/rich-markdown-key-handler.test.ts
  • src/renderer/src/components/editor/rich-markdown-list-continuation.test.ts
  • src/renderer/src/components/editor/rich-markdown-paragraph.test.ts
  • src/renderer/src/components/editor/rich-markdown-tab-key-handler.test.ts
  • src/renderer/src/components/editor/use-markdown-preview-source-foundation.ts
  • src/renderer/src/components/github-checks-tab-state.ts
  • src/renderer/src/components/github-item-dialog/inspect-pull-request/checks-tab-actions.ts
  • src/renderer/src/components/github-item-dialog/inspect-pull-request/checks-tab.tsx
  • src/renderer/src/components/pull-request-page/checks/rerun.ts
  • src/renderer/src/components/pull-request-page/checks/tab.tsx
  • src/renderer/src/components/settings/GeneralWorkspaceSettingsSection.test.tsx
  • src/renderer/src/components/settings/RepositoryWorktreeDefaultsSection.test.tsx
  • src/renderer/src/components/sidebar/worktree-agent-orchestration-index.test.ts
  • src/renderer/src/components/task-page-github-work-item-quiet-state.ts
  • src/renderer/src/components/terminal-pane/hidden-output-restore-scheduler.ts
  • src/renderer/src/components/terminal-pane/pty-renderer-delivery-claims.ts
  • src/renderer/src/components/terminal-pane/terminal-captured-input-dispatch.ts
  • src/renderer/src/components/terminal-pane/terminal-ime-xterm-adversarial.test.ts
  • src/renderer/src/components/terminal-pane/terminal-pane-lifecycle-primitives.ts
  • src/renderer/src/components/use-task-page-github-quiet-refresh.ts
  • src/renderer/src/hooks/useSettingsNavigationMetadata.capability-owner.test.tsx
  • src/renderer/src/hooks/useWindowsTerminalCapabilityOwnerKey.test.tsx
  • src/renderer/src/i18n/technical-literal-catalog-values.test.ts
  • src/renderer/src/lib/ime-composition-keyboard-event.ts
  • src/renderer/src/lib/pane-manager/pane-cursor-blink-suspension.test.ts
  • src/renderer/src/lib/pane-manager/pane-lifecycle.test.ts
  • src/renderer/src/lib/pane-manager/pane-manager-types.ts
  • src/renderer/src/lib/pane-manager/pane-rendering-control.ts
  • src/renderer/src/lib/pane-manager/pane-scroll.ts
  • src/renderer/src/lib/pane-manager/pane-terminal-output-ack-credit.ts
  • src/renderer/src/lib/pane-manager/terminal-parsed-dirty-rows.ts
  • src/renderer/src/lib/pane-manager/terminal-scroll-intent-rebuild.ts
  • src/renderer/src/lib/pane-manager/terminal-webgl-hidden-retention.test.ts
  • src/renderer/src/lib/pane-manager/terminal-webgl-hidden-retention.ts
  • src/renderer/src/lib/pane-manager/terminal-write-pipeline-health.ts
  • src/renderer/src/lib/react-commit-cascade-store-write-samples.test.ts
  • src/renderer/src/lib/react-commit-cascade-store-write-samples.ts
  • src/renderer/src/lib/simulator-launch-coordination.ts
  • src/renderer/src/lib/state-collection-byte-estimate.ts
  • src/renderer/src/store/react-commit-cascade-write-probe.test.ts
  • src/shared/browser-client-host-reconciliation-protocol.test.ts
  • src/shared/repro-7732-gitlab-job-id-dropped.test.ts

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

const registries = new WeakMap<WeakKey, RuntimeBrowserPageRegistry>()

export function getRuntimeBrowserPageRegistry(runtime: object): RuntimeBrowserPageRegistry {
export function getRuntimeBrowserPageRegistry(runtime: WeakKey): RuntimeBrowserPageRegistry {

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.

🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win

Reject registered symbols before weak-map insertion. WeakKey permits symbol identities, including Symbol.for(...). Both APIs pass the key to WeakMap.get() and then call WeakMap.set() on a miss. WeakMap.set() rejects registered symbols, so either API can throw. Reject only registered symbols and preserve non-registered symbol support. Do not restrict the parameters to objects.

const actual = (await vi.importActual('@tiptap/extension-paragraph')) as {
Paragraph: { extend: (config: object) => { config: Record<string, unknown> } }
Paragraph: {
extend: (config: Record<string, unknown>) => { config: Record<string, unknown> }

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Return the mock extension object.

This block does not return an object. It parses config: as a label and uses Record<string, unknown> in value position. The mocked Paragraph.extend() returns undefined, so consumers that use its result fail.

Proposed fix
-      extend: (config: Record<string, unknown>) => { config: Record<string, unknown> }
+      extend: (config: Record<string, unknown>) => ({ config })
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
extend: (config: Record<string, unknown>) => { config: Record<string, unknown> }
extend: (config: Record<string, unknown>) => ({ config })

@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.

ℹ️ Minor suggestions only.

Reviewed changes

Read the full 121-file diff, verified the lint/type gates locally, and traced every behavioral-looking edit back to its call sites.

  • Rule flip — anti-slop/no-object-parameters moved off → error in config/oxlint-anti-slop.json; confirmed the rule actually fires on a scratch object param and that the whole tree is clean (pnpm run audit:anti-slop → 0/0 over 24798 files).
  • Type-only object replacement — parameters now carry their owner's domain type, a new alias, or an identity token. No runtime effect.
  • Identity tokens — reference-compared owners use WeakKey, Record<string, never>, a symbol-brand intersection, or a union; all behavioral sites are compare-only.
  • mobile/src/transport/direct-rpc-client.ts — the session-identity check moved from sendLivenessProbe into the sendProbe callback. Verified equivalent: sendLivenessProbe has exactly one caller and the && preserves the old guard order.
  • mobile/src/transport/relay-dial-stage.ts — RpcClient & Partial<RelayDialStageSource> plus a type predicate replaces the old cast; returns the same object.
  • codex-session-migration-scheduler.ts — extracted isMigrationResultFields guard; confirmed null/primitive/object outcomes are unchanged.
  • Test harnesses — Object.defineProperty (with enumerable/writable/configurable matching a plain assignment) replaces an assignment to a protected member.

No correctness issues found. One low-priority consistency note inline. The mobile tree is not exercised by pnpm tc/pnpm test, which is disclosed in the PR body; the two mobile files with real changes read as behavior-preserving.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

declare const checksContextOwnerBrand: unique symbol

/** Identity minted per checks context; only its reference is ever compared. */
export type GitHubChecksContextOwner = object & { readonly [checksContextOwnerBrand]?: never }

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.

object & { readonly [brand]?: never } is structurally just object — an optional never brand adds no nominality, so any object satisfies this. The rule only misses it because it does not recurse into TSIntersectionType, which makes this an accidental bypass rather than a narrowing. This same PR already uses the honest WeakKey idiom for exactly this reference-identity case, so aligning the three brand aliases (GitHubChecksContextOwner here, RpcSessionIdentity, RendererPtyVisibilityClaimOwner) on WeakKey would be more consistent. Non-blocking.

Technical details
# Brand intersections are structurally `object`

## Affected sites
- `src/renderer/src/components/github-checks-tab-state.ts:13` — `GitHubChecksContextOwner`
- `mobile/src/transport/rpc-session-liveness-watchdog.ts:8` — `RpcSessionIdentity`
- `src/renderer/src/components/terminal-pane/pty-renderer-delivery-claims.ts:11` — `RendererPtyVisibilityClaimOwner`

## Required outcome
- Reference-identity owner types either narrow to a real shape or are expressed with the identity-token idiom used elsewhere in this PR.

## Suggested approach (optional)
- Match `CookieMutationLockOwner` / `HiddenWebglRetentionOwner` / `ParsedDirtyRowTerminal`, which use `WeakKey`.
- If a nominal token is genuinely wanted, note that an *optional* `never` brand is not nominal; only a required brand is, and a required `unique symbol` key is uninhabitable for callers.

@nwparker
nwparker force-pushed the nwparker/anti-slop/no-object-parameters branch 5 times, most recently from 722a940 to 4157e1b Compare September 15, 2026 08:16
The rule rejects the broad `object` type on any function input (declarations,
expressions, arrows, methods, call/construct signatures, function types), plus
local aliases and unions that resolve to `object`. `object` accepts every
non-primitive while exposing no properties, so it documents nothing and pushes
callers into assertions at the boundary.

Fixes all 185 violations across src, config, tests and mobile, and flips the
rule from "off" to "error" in config/oxlint-anti-slop.json.

Approach: replace each `object` input with the type its owner already has.
Most sites took an existing domain type or a type-only import (36 added);
40 new aliases name shapes that had none. Where a value is genuinely only
compared by reference, it gets a named identity token instead of a shape --
`Record<string, never>`, the built-in `WeakKey`, or a `unique symbol` brand,
matching the branding already used in src/shared. Same treatment for WeakMap
and Map key parameters. Two `as unknown as` casts became unnecessary once the
parameter carried a real type and were removed; no new casts were added.

Suppressions added: none. No `oxlint-disable` for this rule anywhere, and no
max-lines disable or per-file bump.

Three files sat exactly at their max-lines cap, so the added type imports were
made line-neutral rather than suppressed:
- src/main/ipc/browser.ts exports the existing guest-registration args type
  (renamed BrowserGuestArgs) so browser.test.ts reuses it on one line.
- pane-scroll.ts takes TerminalScrollIntentTarget through the existing
  pane-manager-types import via a type-only re-export.
- direct-rpc-client.ts drops the identity parameter entirely: the session
  check moved into the sendProbe callback that owns the token.

Verified: anti-slop config reports zero violations over src config tests
mobile; run-typecheck-projects-in-parallel exits 0; 144 affected test files
pass (1749 tests); oxlint and oxfmt clean on all changed files. Mobile has no
runnable test/typecheck target in this worktree (expo is not installed), so
its 6 files were typechecked against a standalone config and diffed against
the base branch -- error sets are byte-identical, including test files.
@nwparker
nwparker force-pushed the nwparker/anti-slop/no-object-parameters branch from 4157e1b to 3665cc6 Compare September 15, 2026 08:24
@nwparker
nwparker merged commit bfdec26 into main Sep 15, 2026
40 checks passed
@nwparker
nwparker deleted the nwparker/anti-slop/no-object-parameters branch September 15, 2026 09:00
brennanb2025 added a commit that referenced this pull request Sep 15, 2026
…oundary

anti-slop/no-object-parameters flagged terminalLaunchWarning's `result: object`.
The rule is pointing at a real seam rather than a style nit: the helper advertised
a loose object and did the narrowing inside itself, so every caller handed it
unparsed wire data and nothing downstream held a real type.

Parsed at the boundary instead. parseTerminalLaunchOutcome takes `unknown` and
returns TerminalLaunchOutcome | null, so the narrowing happens once, where the
untrusted payload enters, and the consumer works with a named type.

The type is taken from the shared contract rather than restated - a Pick over the
terminal member of AgentLaunchOutcome - so a change to that union fails here
instead of flowing through. `handle` is deliberately excluded: nothing reads it,
and requiring it would drop the warning off a reply that omitted one, which is a
behaviour change smuggled in under a typing change.

No assertion and no config exemption: reintroducing `as Partial<AgentLaunchResult>`
would trade this finding for the defect removed earlier in this branch, and the
rule is correct here.

The rule arrived with the merge-forward (#20781, newer than this branch's
merge-base), and anti-slop is not one of the changed-code gate's six scans - it
runs only repo-wide - which is why a clean local gate did not predict it.

Behaviour is unchanged across all five warning cases, and the positive case was
re-ablated on the new parser: dropping the warning reddens exactly it,
1 failed | 18 passed, restored byte-identical to 19 passed.
brennanb2025 added a commit that referenced this pull request Sep 16, 2026
…agent (#19850)

* refactor(agent-launch): make the launch-mode decision surface-neutral

`decideWorkerStartMode` was the only shared answer to "structured chat session
or terminal agent?", but it lived in an orchestration-named module and spoke
orchestration's vocabulary, so the other launch surfaces could not call it.
Move the decision to `main/agent-launch/agent-launch-mode` unchanged and leave
`orchestration-worker-start-mode` as the adapter that supplies the noun.

A worker is not a special kind of launch; it is the same launch with a dispatch
attached. Naming the receipt's subject is the only thing orchestration actually
contributed, so that is the only thing the adapter keeps: "worker" in both
sentences, plus the `--terminal` wording, which reads as nonsense anywhere a
`--terminal` flag does not exist. Both are pinned, because they are asserted.

No behavior change. The receipts are byte-identical for every reachable case,
proven by running the new pin against both implementations.

Also pins the wording, which nothing was holding. The existing suites assert
`toContain` fragments ('terminal agent', 'cannot create') and the CLI suite
asserts a receipt handed to it by a mock rather than one this code produced;
all six files stayed green against a deliberately corrupted vocabulary. A
dispatch receipt is the only place a structured-to-terminal downgrade explains
itself, so the whole sentence is the contract, not a fragment of it.

* feat(agent-launch): add the launch intent and the one executor that runs it

The sequencing around the launch decision was duplicated per surface, and the
duplicate is where the bug lives. A new worktree was created agent-first, so
its startup terminal WAS the agent and the structured branch below it could
never be reached — every new-worktree launch was a PTY regardless of the user's
default. Orchestration fixed that for itself in #19431; mobile and the CLI
still have it.

`executeAgentLaunch` inverts the order once, for everyone. When the preference
is structured the worktree is created with NO startup agent, the executing host
is then asked whether it can host a session for the workspace that now exists,
and only then is a surface created. The host verdict cannot be hoisted above
creation: `agentSession.createSupport` only answers for a workspace it can
resolve, which is why the decision stays in two halves.

Agent-first creation is deliberately preserved for PTY launches — it is what
sequences the agent's startup command behind the setup runner, so wait-for-setup
comes for free there.

What actually differs per surface is only how a surface is built (an
orchestration worker's session takes a dispatch hold and a mailbox a plain
launch must not take), so that is injected as a factory rather than branched on.

The intent also strips the reserved agent fields from a migrated create payload:
a caller moving off `worktree.create` passes its existing params, and a stale
`startupAgent` in there would re-create the very path this replaces.

Tests assert order and arguments, not just the resulting mode. Reintroducing
agent-first creation reddens 4 of 11.

* feat(agent-launch): expose the launch executor as the agent.launch RPC

Adds `agent.launch` — one host-side method that decides structured-vs-terminal and
creates the surface — wired to the real runtime factories: `createManagedWorktree`
for the workspace, forking on `startupAgent` exactly as the orchestration worker
path does; `createStructuredAgentSessionForWorktree` for a chat session; and
`createTerminal` for a PTY agent. Allowlisted for mobile, which is the surface the
routing gap was reported on.

`worktree.create` is untouched. Its `startupAgent` keeps meaning "spawn a PTY agent"
verbatim, because it answers with `agentTerminalHandle` only on that path: a host
that quietly routed it to a structured session would hand every older client a
response with no handle and no error. All new behaviour sits behind
`agent.launch.v1`, which the host now advertises and a remote client must negotiate,
so a client that does not gets today's behaviour unchanged.

* feat(mobile): route workspace creates through agent.launch

Picking an agent on the mobile create sheet always produced a terminal, even
when the user's default was native chat, because all three create paths put
`startupAgent` on `worktree.create`. That means "create the worktree
agent-first", so its startup terminal IS the agent and the structured branch
below it is unreachable — while the same phone's in-workspace "+" button opened
a chat.

The blank, branch and new-branch creates now send the same payload through
`agent.launch` and let the host settle the surface. `worktree.create` is
untouched, and a host that does not advertise `agent.launch.v1` (read from the
existing `status.get` probe) keeps today's path exactly.

Work-item creates stay on `worktree.create`: they pre-fill the issue/PR URL as
an unsent `startupDraft`, which a structured session cannot hold yet, so routing
them would submit the URL as a first turn.

* fix(agent-launch): drop the deleted draft-prompt blocker from the reason map

main removed the draft-prompt blocker in #19681 (a structured session now holds
an unsent draft), so the exhaustive Record no longer typechecks.

* chore(agent-launch): carry a SAFETY rationale on the agent placement cast

The type-assertion gate landed after this branch's base, so the new file's
copy of the worker-start cast is now a changed-code finding.

* chore(agent-launch): carry agent.launch through main's RPC typing and casting gates

The typed-method contract, the generated params catalog and the
`assertionStyle: never` casting scan all landed after this branch's base.

- AGENT_LAUNCH_METHODS kept an `RpcMethod[]` annotation, which widened its
  method name to `string` and broke assignability; every sibling infers instead.
- `agent.launch` binds a schema under src/main, so it joins the catalog's
  RPC_METHODS_WITHOUT_SHARED_PARAMS and the parity gate's hand-listed twin.
- The now-typed methods make most test casts unnecessary; the few that remain
  carry the line-specific SAFETY rationale the casting gate requires.

* test(mobile): supply the agent-launch fixture the create-submit recording needs

The golden RPC recordings landed upstream while this branch was out, so they
first met agent.launch here. Three things had to happen, and only one of them is
a fixture bump.

1. workspace-settings-mounts.ts mounts useNewWorkspaceCreateSubmit against a
   fixture model that throws on any member it was not given. This PR added a
   required getAgentLaunchSupport, so the submit aborted with "Missing model
   fixture" before it ever issued the create, and three cleanup checkpoints
   vanished. That read like a product regression and was not one. Supplying the
   member restores the recording byte-for-byte; it is pinned false for the same
   reason the cutover probe is, so the baseline stays on worktree.create.

2. Editing that adapter moves adapterSha256 for the twelve settings goldens it
   mounts. Their recordings are unchanged - header only, by design: the digest
   is per-golden so editing a module fails exactly the goldens that mounted it.

3. Five goldens changed behaviourally, and both changes are this PR's:
   the capability probe now reports agentLaunch, and a create whose reply
   carries no worktree returns "Failed to create workspace" instead of throwing
   a TypeError off an unguarded result.worktree read. The launch route needs
   that guard, since a receipt can arrive without a worktreeId.

* refactor(mobile): decode the launch receipt instead of asserting its shape

The changed-code quality gate refuses type assertions, and the eight it flagged
were worth removing rather than suppressing.

The production one was the point. readAgentLaunchCreateOutcome asserted the RPC
payload into Partial<AgentLaunchResult> and then runtime-checked it anyway, so
the assertion bought nothing and claimed a contract the host had not proven. It
now narrows with `in` and validates each hop, which is the same nullability
question readCreateResult already answers on the sibling path - a launch receipt
can legitimately arrive without a worktreeId. AgentLaunchCreateOutcome ties
worktreeId to the shared contract so a change there fails this reader's
typecheck rather than passing a differently-typed field through.

The test fakes claimed a whole RpcClient via `as unknown as RpcClient` while
implementing one member. They now build a typed literal, matching the pattern in
use-mobile-structured-agent-options.test.ts. The read sites cast params and then
read one field; they now assert the payload with toMatchObject, which removes
the cast and pins more of the shape than the cast did.

Also pins the warning passthrough, which nothing covered: a terminal launch that
seats the workspace but cannot start the pty reports why, and the absent, blank,
non-string and structured-surface cases report nothing. Writing that test caught
a real drop I had introduced in the reader.

* ci(mobile): re-run Mobile Checks when a shared capability changes

Mobile Checks is path-filtered to mobile/**, but mobile imports the negotiated
capability names straight from src/shared/protocol-version.ts and records the
whole capability read verbatim in its goldens. So a capability added desktop-side
rewrites a mobile fixture while never triggering the suite that would catch it.

That is what happened here: #19849 introduced agent.launch.v1 and Mobile Checks
never ran on it. Verified at the run level rather than by check name - the
window-free check-runs API on 3837ae8 returns 49 check-runs across six runs
(PR Checks x2, PR test LoC x2, Track Community PRs, Review) and no Mobile Checks
among them. The breakage surfaced only in this PR, which happens to touch mobile/**.

The workflow already concedes this pattern for terminal-file-link-conformance.ts;
protocol-version.ts has the stronger claim, since mobile records its output.

Also corrects the mount adapter's SAFETY comment. It claimed the recorder supplies
only the members the hook reads, which was false the moment the hook gained a
required getAgentLaunchSupport - and the assertion it annotates is exactly what
stopped the compiler from saying so. The twelve goldens are adapterSha256 churn
from that comment: every body is byte-identical, which is the digest doing its job.

* docs(agent-launch): stop the receipt-wording comment claiming a migration

The decision was never moved out of orchestration-worker-start-mode; this PR
adds a second copy beside it. Say so, and name the unenforced agreement.

* docs(agent-launch): stop the executor comment claiming a migration that has not happened

The header asserted two things the tree does not support: that every launch
surface routes through the executor, and that the mode decision "already lived"
in `agent-launch-mode`. `agent.launch` is the executor's only consumer, and
`orchestration-worker-start-mode.ts` is byte-identical (blob 92dc5c6, 217
lines) at the merge base and all three stack heads, still used by workers.ts.
Describe the two live copies and leave the cutover to later stack work.

* fix(agent-launch): preserve setup and refusal fallbacks

* refactor(mobile): parse the launch outcome into a named type at its boundary

anti-slop/no-object-parameters flagged terminalLaunchWarning's `result: object`.
The rule is pointing at a real seam rather than a style nit: the helper advertised
a loose object and did the narrowing inside itself, so every caller handed it
unparsed wire data and nothing downstream held a real type.

Parsed at the boundary instead. parseTerminalLaunchOutcome takes `unknown` and
returns TerminalLaunchOutcome | null, so the narrowing happens once, where the
untrusted payload enters, and the consumer works with a named type.

The type is taken from the shared contract rather than restated - a Pick over the
terminal member of AgentLaunchOutcome - so a change to that union fails here
instead of flowing through. `handle` is deliberately excluded: nothing reads it,
and requiring it would drop the warning off a reply that omitted one, which is a
behaviour change smuggled in under a typing change.

No assertion and no config exemption: reintroducing `as Partial<AgentLaunchResult>`
would trade this finding for the defect removed earlier in this branch, and the
rule is correct here.

The rule arrived with the merge-forward (#20781, newer than this branch's
merge-base), and anti-slop is not one of the changed-code gate's six scans - it
runs only repo-wide - which is why a clean local gate did not predict it.

Behaviour is unchanged across all five warning cases, and the positive case was
re-ablated on the new parser: dropping the warning reddens exactly it,
1 failed | 18 passed, restored byte-identical to 19 passed.

* fix(agent-launch): dedupe complete launch and cancel setup wait

* fix(agent-launch): memoize the whole launch so a replay cannot mint a second session

A replayed agent.launch could create a second structured session in the same
worktree, with activate: true.

dedupeWorktreeCreate wrapped only the worktree half, inside the workspace
factory. On a replay the create was reused, and the executor then continued to
createSurface and built another surface inside it. The terminal route hid this:
its cached create carries a startup terminal handle, so the executor returns on
early. A structured create has no handle by construction - that is the whole
point of the structured fork - so it fell through every time. Mobile replays
this method deliberately on a delivery-ambiguous response, up to five attempts,
so the path is reachable by design rather than in theory.

The handler now wraps the entire launch in the same dedupe, on the same
(repo, clientMutationId) identity, exactly as worktree.create wraps its own
body. A replay returns the original AgentLaunchResult instead of re-running
createSurface, which makes the two routes replay-identical.

The inner dedupe is removed rather than kept. Wrapping both levels on one key
deadlocks: dedupeWorktreeCreate stores the in-flight promise before the inner
call runs, so the inner call would be handed the outer's promise, which is
waiting on it. The launch-level memo subsumes the worktree-level one.

Failures are still dropped rather than cached, so an unknown outcome stays
unknown instead of replaying as a fabricated success.

The guard replays a STRUCTURED launch: the terminal route cannot reproduce this
and a test there would pass either way. Ablated against the pre-fix files -
1 failed | 22 passed, "expected vi.fn() to be called 1 times, but got 2 times",
which is the duplicate session - then restored to 23 passed. The stub's dedupe
had to be made faithful for that to be observable; the shared one passes through
so other tests can see raw calls.

* Revert "fix(agent-launch): memoize the whole launch so a replay cannot mint a second session"

This reverts commit 59bc5e9.

The same defect was already fixed upstream on this stack's base branch by
539e283, which landed while this was being written. That change is broader
(it also cancels the setup wait) and namespaces the dedupe key, so it supersedes
this one. Reverting rather than hand-merging keeps a single implementation
instead of a hybrid nobody chose.

The behavioural guard from this commit is ported back on top of the upstream
implementation separately: it asserts exactly one structured session survives a
replay, where the upstream tests assert the dedupe wiring.

* ci(mobile): close the round-1 signal gaps around agent.launch

Three review findings, all narrow.

Mobile Checks is path-filtered, and this branch made mobile's types depend on the
shared RPC contract: rpc-params-contract.ts is a type-only re-export of the
generated params catalog, and mobile/tsconfig.json includes **/*.ts. So a
desktop-only edit under src/shared/rpc-contract/ could break mobile's typecheck
with no mobile signal at all - the same blind spot the protocol-version.ts entry
closed, one directory over. Added src/shared/rpc-contract/** to the paths filter.

agent.launch had no cross-version trigger. Added the three prefixes a paired peer
actually exchanges: the intent contract, the wire schema, and the RPC method.
src/main/agent-launch/ is deliberately NOT listed - the executor shapes behaviour
but is not itself wire, and AgentLaunchResult's shape is already covered by
agent-launch-intent. Extending the cross-version SUITE to cover a negotiated
handshake is separate work, not this.

The break branch that answers an accepted-but-empty reply with "Failed to create
workspace" had no unit coverage; the golden that used to discriminate it
collapsed five partitions into one shared error when the null guard replaced the
unchecked read. Covered on BOTH routes - worktree.create with no worktree.id and
agent.launch with no worktreeId - since the branch serves both. Ablated by
bypassing the guard: 2 failed | 11 passed, the two new cases returning a
fabricated worktree instead of the error, restored to 13 passed.

* fix(agent-launch): give a launch one place to say the workspace is incomplete

createManagedWorktree reports an unspawned startup terminal or an uncopied
working tree as a top-level `warning`, and worktree.create hands it straight to
mobile. The launch path narrowed that result down to
{worktreeId, startupTerminalHandle} and dropped it, so every agent.launch create
lost a warning the old method surfaces - on both arms.

The channel was also asymmetric by accident rather than design: a terminal
outcome could carry `warning`, a structured one had nowhere to put it, so the
arm this PR exists to enable was the arm that could not report an incomplete
create at all.

Now there is exactly one place a launch warning lives: AgentLaunchResult.warning,
at the top level. It is about the create as often as the surface, it applies to a
structured session and a terminal alike, and a reader should not branch on
outcome.kind to discover the workspace it just opened is missing something. The
terminal arm's own `warning?` is removed rather than left beside it - two homes
for one fact is how they drift. Every producer folds in: the create, the surface,
and the refusal downgrade.

Consumer census before removing it: one production reader (mobile's
readAgentLaunchCreateOutcome) and no others - the renderer and mobile launch
call sites never read it. The mobile reader now reads the top-level field, which
also lets its outcome parser go away entirely.

Guard ablated by restoring the pre-fix narrowing: 2 failed | 24 passed, both
carriers reporting `expected undefined`, which is the dropped warning itself;
restored to 26 passed. The third case asserts an absence and stays green under
the mutation by construction - it pins shape, not the defect.

* fix(agent-launch): combine both launch warnings instead of dropping one

Round 2 found the comment here was false. A create warning and a surface warning
CAN both be set, on two reachable paths:

  1. The create warns precisely BECAUSE it produced no startup terminal -
     didSpawnStartup stays false when that spawn throws, and
     orca-runtime-create-managed-worktree.ts:283 gates startupTerminal on it - so
     the executor's early return is skipped and a second surface is built, which
     can warn too.
  2. An untracked-copy warning, then a definitive structured refusal downgrading
     to a terminal that also warns.

`??` kept the first and lost the second with nothing saying so. They are now
combined the way the create combines its own failures - appendFailure in
runtime-local-worktree-terminal-startup.ts, and the startup-terminal catch in
runtime-remote-managed-worktree-create.ts - which append rather than replace.

The comment is rewritten to say what is true, and records the gap NOT fixed
here: a create warning about a failed startup terminal is stale once the launch
recovers by building a working one, so a user can be told the agent did not start
while looking at it. Distinguishing those needs createManagedWorktree to stop
multiplexing two unrelated failures into one string.

Guarded and ablated: restoring `??` reddens exactly the new test, with the
surface clause missing from the received string; restored to 27 passed. The
structured-create stub had to admit its real ok-or-refusal union for the
downgrade path to be modellable at all - it previously declared only the ok arm.

Also: mobile.yml gains src/shared/agent-launch-intent.ts. It is the sole holder
of the agent.launch RESULT shape - the rpc-contract catalog holds params only -
and mobile imports it as a value. CROSS_VERSION_WIRE_PREFIXES already treats it
as wire-critical; without this, one gate does and the other cannot see it.

And the agent-first warning test no longer pairs "startup terminal failed" with a
returned handle, a combination the producer cannot emit.

* fix(mobile): read a launch warning an older host nests on the outcome

agent.launch moved `warning` from the terminal outcome to the top level of the
result. That is the right shape - a reader should not branch on `outcome.kind`
to learn the workspace it just opened is incomplete - but on the wire it is a
REMOVAL, and mobile only read the new place.

A host built before the move still advertises the same `agent.launch.v1`
capability, so the capability probe cannot tell the two apart and mobile takes
this route against one:

  protocol-version.ts:360       AGENT_LAUNCH_RUNTIME_CAPABILITY is in
                                RUNTIME_CAPABILITIES, the host list
  orca-runtime-get-status.ts:64 publishes it via status.get; the filter drops
                                only browser.screencast.v1 and three E2E-gated
                                capabilities, never agent.launch
  agent-launch-executor.ts      such a host writes warning INSIDE outcome

The result was a regression rather than a contract cleanup: the worktree.create
path this replaces returned the warning at the top level and mobile read it, so
a create that seated the workspace but could not start the agent surface - pty
exhaustion, untracked files not copied - stopped explaining itself on the phone.

Read both shapes for as long as such a host can be paired. Top level wins, and
cannot be shadowed: AgentLaunchOutcome has no `warning` on either arm, so a
current host cannot nest one.

The test that pinned the old behaviour is inverted here. Its comment was the
actual defect - it framed a legitimate warning from an older peer as a stale
shape to defend against, which is what made dropping it look deliberate.

* chore(mobile): raise the unchecked-reader ceiling for the agent.launch receipt

main landed `unchecked-rpc-reader-inventory.ts`, a ratchet on RpcOperation
readers that re-type their reply instead of validating it. Its ceiling for
mobile-workspace-create-operations.ts is 4, counted on a tree without this
branch's `agentLaunchRun`, so the merge produced "listed 4, found 5".

The inventory's own header prescribes this case: a merge is the one time a line
goes up without a migration undoing itself, and the instruction is to raise it
and name the PR that brought it. It describes main landing an operation the
branch never saw; here it is the mirror - the branch holds one main had not
seen - so the line is annotated with #19850 rather than left bare.

Not converted to `rpcResultVariant(variant, schema)`, which would lower the line
instead. That is a validation change rather than a migration, which is exactly
what the file's own comment says these five readers deliberately are not; the
agent.launch reply is already guarded at the consumer, where
readAgentLaunchCreateOutcome returns null on a malformed payload and the create
surfaces "Failed to create workspace". Writing a schema now would also target a
reply shape #20999 is actively redefining.

Ablated: with the line back at 4 the ratchet fails "listed 4, found 5"; at 5 it
passes.

---------

Co-authored-by: Merge Sim <sim@local>
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
The rule rejects the broad `object` type on any function input (declarations,
expressions, arrows, methods, call/construct signatures, function types), plus
local aliases and unions that resolve to `object`. `object` accepts every
non-primitive while exposing no properties, so it documents nothing and pushes
callers into assertions at the boundary.

Fixes all 185 violations across src, config, tests and mobile, and flips the
rule from "off" to "error" in config/oxlint-anti-slop.json.

Approach: replace each `object` input with the type its owner already has.
Most sites took an existing domain type or a type-only import (36 added);
40 new aliases name shapes that had none. Where a value is genuinely only
compared by reference, it gets a named identity token instead of a shape --
`Record<string, never>`, the built-in `WeakKey`, or a `unique symbol` brand,
matching the branding already used in src/shared. Same treatment for WeakMap
and Map key parameters. Two `as unknown as` casts became unnecessary once the
parameter carried a real type and were removed; no new casts were added.

Suppressions added: none. No `oxlint-disable` for this rule anywhere, and no
max-lines disable or per-file bump.

Three files sat exactly at their max-lines cap, so the added type imports were
made line-neutral rather than suppressed:
- src/main/ipc/browser.ts exports the existing guest-registration args type
  (renamed BrowserGuestArgs) so browser.test.ts reuses it on one line.
- pane-scroll.ts takes TerminalScrollIntentTarget through the existing
  pane-manager-types import via a type-only re-export.
- direct-rpc-client.ts drops the identity parameter entirely: the session
  check moved into the sendProbe callback that owns the token.

Verified: anti-slop config reports zero violations over src config tests
mobile; run-typecheck-projects-in-parallel exits 0; 144 affected test files
pass (1749 tests); oxlint and oxfmt clean on all changed files. Mobile has no
runnable test/typecheck target in this worktree (expo is not installed), so
its 6 files were typechecked against a standalone config and diffed against
the base branch -- error sets are byte-identical, including test files.
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
…agent (stablyai#19850)

* refactor(agent-launch): make the launch-mode decision surface-neutral

`decideWorkerStartMode` was the only shared answer to "structured chat session
or terminal agent?", but it lived in an orchestration-named module and spoke
orchestration's vocabulary, so the other launch surfaces could not call it.
Move the decision to `main/agent-launch/agent-launch-mode` unchanged and leave
`orchestration-worker-start-mode` as the adapter that supplies the noun.

A worker is not a special kind of launch; it is the same launch with a dispatch
attached. Naming the receipt's subject is the only thing orchestration actually
contributed, so that is the only thing the adapter keeps: "worker" in both
sentences, plus the `--terminal` wording, which reads as nonsense anywhere a
`--terminal` flag does not exist. Both are pinned, because they are asserted.

No behavior change. The receipts are byte-identical for every reachable case,
proven by running the new pin against both implementations.

Also pins the wording, which nothing was holding. The existing suites assert
`toContain` fragments ('terminal agent', 'cannot create') and the CLI suite
asserts a receipt handed to it by a mock rather than one this code produced;
all six files stayed green against a deliberately corrupted vocabulary. A
dispatch receipt is the only place a structured-to-terminal downgrade explains
itself, so the whole sentence is the contract, not a fragment of it.

* feat(agent-launch): add the launch intent and the one executor that runs it

The sequencing around the launch decision was duplicated per surface, and the
duplicate is where the bug lives. A new worktree was created agent-first, so
its startup terminal WAS the agent and the structured branch below it could
never be reached — every new-worktree launch was a PTY regardless of the user's
default. Orchestration fixed that for itself in stablyai#19431; mobile and the CLI
still have it.

`executeAgentLaunch` inverts the order once, for everyone. When the preference
is structured the worktree is created with NO startup agent, the executing host
is then asked whether it can host a session for the workspace that now exists,
and only then is a surface created. The host verdict cannot be hoisted above
creation: `agentSession.createSupport` only answers for a workspace it can
resolve, which is why the decision stays in two halves.

Agent-first creation is deliberately preserved for PTY launches — it is what
sequences the agent's startup command behind the setup runner, so wait-for-setup
comes for free there.

What actually differs per surface is only how a surface is built (an
orchestration worker's session takes a dispatch hold and a mailbox a plain
launch must not take), so that is injected as a factory rather than branched on.

The intent also strips the reserved agent fields from a migrated create payload:
a caller moving off `worktree.create` passes its existing params, and a stale
`startupAgent` in there would re-create the very path this replaces.

Tests assert order and arguments, not just the resulting mode. Reintroducing
agent-first creation reddens 4 of 11.

* feat(agent-launch): expose the launch executor as the agent.launch RPC

Adds `agent.launch` — one host-side method that decides structured-vs-terminal and
creates the surface — wired to the real runtime factories: `createManagedWorktree`
for the workspace, forking on `startupAgent` exactly as the orchestration worker
path does; `createStructuredAgentSessionForWorktree` for a chat session; and
`createTerminal` for a PTY agent. Allowlisted for mobile, which is the surface the
routing gap was reported on.

`worktree.create` is untouched. Its `startupAgent` keeps meaning "spawn a PTY agent"
verbatim, because it answers with `agentTerminalHandle` only on that path: a host
that quietly routed it to a structured session would hand every older client a
response with no handle and no error. All new behaviour sits behind
`agent.launch.v1`, which the host now advertises and a remote client must negotiate,
so a client that does not gets today's behaviour unchanged.

* feat(mobile): route workspace creates through agent.launch

Picking an agent on the mobile create sheet always produced a terminal, even
when the user's default was native chat, because all three create paths put
`startupAgent` on `worktree.create`. That means "create the worktree
agent-first", so its startup terminal IS the agent and the structured branch
below it is unreachable — while the same phone's in-workspace "+" button opened
a chat.

The blank, branch and new-branch creates now send the same payload through
`agent.launch` and let the host settle the surface. `worktree.create` is
untouched, and a host that does not advertise `agent.launch.v1` (read from the
existing `status.get` probe) keeps today's path exactly.

Work-item creates stay on `worktree.create`: they pre-fill the issue/PR URL as
an unsent `startupDraft`, which a structured session cannot hold yet, so routing
them would submit the URL as a first turn.

* fix(agent-launch): drop the deleted draft-prompt blocker from the reason map

main removed the draft-prompt blocker in stablyai#19681 (a structured session now holds
an unsent draft), so the exhaustive Record no longer typechecks.

* chore(agent-launch): carry a SAFETY rationale on the agent placement cast

The type-assertion gate landed after this branch's base, so the new file's
copy of the worker-start cast is now a changed-code finding.

* chore(agent-launch): carry agent.launch through main's RPC typing and casting gates

The typed-method contract, the generated params catalog and the
`assertionStyle: never` casting scan all landed after this branch's base.

- AGENT_LAUNCH_METHODS kept an `RpcMethod[]` annotation, which widened its
  method name to `string` and broke assignability; every sibling infers instead.
- `agent.launch` binds a schema under src/main, so it joins the catalog's
  RPC_METHODS_WITHOUT_SHARED_PARAMS and the parity gate's hand-listed twin.
- The now-typed methods make most test casts unnecessary; the few that remain
  carry the line-specific SAFETY rationale the casting gate requires.

* test(mobile): supply the agent-launch fixture the create-submit recording needs

The golden RPC recordings landed upstream while this branch was out, so they
first met agent.launch here. Three things had to happen, and only one of them is
a fixture bump.

1. workspace-settings-mounts.ts mounts useNewWorkspaceCreateSubmit against a
   fixture model that throws on any member it was not given. This PR added a
   required getAgentLaunchSupport, so the submit aborted with "Missing model
   fixture" before it ever issued the create, and three cleanup checkpoints
   vanished. That read like a product regression and was not one. Supplying the
   member restores the recording byte-for-byte; it is pinned false for the same
   reason the cutover probe is, so the baseline stays on worktree.create.

2. Editing that adapter moves adapterSha256 for the twelve settings goldens it
   mounts. Their recordings are unchanged - header only, by design: the digest
   is per-golden so editing a module fails exactly the goldens that mounted it.

3. Five goldens changed behaviourally, and both changes are this PR's:
   the capability probe now reports agentLaunch, and a create whose reply
   carries no worktree returns "Failed to create workspace" instead of throwing
   a TypeError off an unguarded result.worktree read. The launch route needs
   that guard, since a receipt can arrive without a worktreeId.

* refactor(mobile): decode the launch receipt instead of asserting its shape

The changed-code quality gate refuses type assertions, and the eight it flagged
were worth removing rather than suppressing.

The production one was the point. readAgentLaunchCreateOutcome asserted the RPC
payload into Partial<AgentLaunchResult> and then runtime-checked it anyway, so
the assertion bought nothing and claimed a contract the host had not proven. It
now narrows with `in` and validates each hop, which is the same nullability
question readCreateResult already answers on the sibling path - a launch receipt
can legitimately arrive without a worktreeId. AgentLaunchCreateOutcome ties
worktreeId to the shared contract so a change there fails this reader's
typecheck rather than passing a differently-typed field through.

The test fakes claimed a whole RpcClient via `as unknown as RpcClient` while
implementing one member. They now build a typed literal, matching the pattern in
use-mobile-structured-agent-options.test.ts. The read sites cast params and then
read one field; they now assert the payload with toMatchObject, which removes
the cast and pins more of the shape than the cast did.

Also pins the warning passthrough, which nothing covered: a terminal launch that
seats the workspace but cannot start the pty reports why, and the absent, blank,
non-string and structured-surface cases report nothing. Writing that test caught
a real drop I had introduced in the reader.

* ci(mobile): re-run Mobile Checks when a shared capability changes

Mobile Checks is path-filtered to mobile/**, but mobile imports the negotiated
capability names straight from src/shared/protocol-version.ts and records the
whole capability read verbatim in its goldens. So a capability added desktop-side
rewrites a mobile fixture while never triggering the suite that would catch it.

That is what happened here: stablyai#19849 introduced agent.launch.v1 and Mobile Checks
never ran on it. Verified at the run level rather than by check name - the
window-free check-runs API on 3837ae8 returns 49 check-runs across six runs
(PR Checks x2, PR test LoC x2, Track Community PRs, Review) and no Mobile Checks
among them. The breakage surfaced only in this PR, which happens to touch mobile/**.

The workflow already concedes this pattern for terminal-file-link-conformance.ts;
protocol-version.ts has the stronger claim, since mobile records its output.

Also corrects the mount adapter's SAFETY comment. It claimed the recorder supplies
only the members the hook reads, which was false the moment the hook gained a
required getAgentLaunchSupport - and the assertion it annotates is exactly what
stopped the compiler from saying so. The twelve goldens are adapterSha256 churn
from that comment: every body is byte-identical, which is the digest doing its job.

* docs(agent-launch): stop the receipt-wording comment claiming a migration

The decision was never moved out of orchestration-worker-start-mode; this PR
adds a second copy beside it. Say so, and name the unenforced agreement.

* docs(agent-launch): stop the executor comment claiming a migration that has not happened

The header asserted two things the tree does not support: that every launch
surface routes through the executor, and that the mode decision "already lived"
in `agent-launch-mode`. `agent.launch` is the executor's only consumer, and
`orchestration-worker-start-mode.ts` is byte-identical (blob 92dc5c6, 217
lines) at the merge base and all three stack heads, still used by workers.ts.
Describe the two live copies and leave the cutover to later stack work.

* fix(agent-launch): preserve setup and refusal fallbacks

* refactor(mobile): parse the launch outcome into a named type at its boundary

anti-slop/no-object-parameters flagged terminalLaunchWarning's `result: object`.
The rule is pointing at a real seam rather than a style nit: the helper advertised
a loose object and did the narrowing inside itself, so every caller handed it
unparsed wire data and nothing downstream held a real type.

Parsed at the boundary instead. parseTerminalLaunchOutcome takes `unknown` and
returns TerminalLaunchOutcome | null, so the narrowing happens once, where the
untrusted payload enters, and the consumer works with a named type.

The type is taken from the shared contract rather than restated - a Pick over the
terminal member of AgentLaunchOutcome - so a change to that union fails here
instead of flowing through. `handle` is deliberately excluded: nothing reads it,
and requiring it would drop the warning off a reply that omitted one, which is a
behaviour change smuggled in under a typing change.

No assertion and no config exemption: reintroducing `as Partial<AgentLaunchResult>`
would trade this finding for the defect removed earlier in this branch, and the
rule is correct here.

The rule arrived with the merge-forward (stablyai#20781, newer than this branch's
merge-base), and anti-slop is not one of the changed-code gate's six scans - it
runs only repo-wide - which is why a clean local gate did not predict it.

Behaviour is unchanged across all five warning cases, and the positive case was
re-ablated on the new parser: dropping the warning reddens exactly it,
1 failed | 18 passed, restored byte-identical to 19 passed.

* fix(agent-launch): dedupe complete launch and cancel setup wait

* fix(agent-launch): memoize the whole launch so a replay cannot mint a second session

A replayed agent.launch could create a second structured session in the same
worktree, with activate: true.

dedupeWorktreeCreate wrapped only the worktree half, inside the workspace
factory. On a replay the create was reused, and the executor then continued to
createSurface and built another surface inside it. The terminal route hid this:
its cached create carries a startup terminal handle, so the executor returns on
early. A structured create has no handle by construction - that is the whole
point of the structured fork - so it fell through every time. Mobile replays
this method deliberately on a delivery-ambiguous response, up to five attempts,
so the path is reachable by design rather than in theory.

The handler now wraps the entire launch in the same dedupe, on the same
(repo, clientMutationId) identity, exactly as worktree.create wraps its own
body. A replay returns the original AgentLaunchResult instead of re-running
createSurface, which makes the two routes replay-identical.

The inner dedupe is removed rather than kept. Wrapping both levels on one key
deadlocks: dedupeWorktreeCreate stores the in-flight promise before the inner
call runs, so the inner call would be handed the outer's promise, which is
waiting on it. The launch-level memo subsumes the worktree-level one.

Failures are still dropped rather than cached, so an unknown outcome stays
unknown instead of replaying as a fabricated success.

The guard replays a STRUCTURED launch: the terminal route cannot reproduce this
and a test there would pass either way. Ablated against the pre-fix files -
1 failed | 22 passed, "expected vi.fn() to be called 1 times, but got 2 times",
which is the duplicate session - then restored to 23 passed. The stub's dedupe
had to be made faithful for that to be observable; the shared one passes through
so other tests can see raw calls.

* Revert "fix(agent-launch): memoize the whole launch so a replay cannot mint a second session"

This reverts commit 59bc5e9.

The same defect was already fixed upstream on this stack's base branch by
539e283, which landed while this was being written. That change is broader
(it also cancels the setup wait) and namespaces the dedupe key, so it supersedes
this one. Reverting rather than hand-merging keeps a single implementation
instead of a hybrid nobody chose.

The behavioural guard from this commit is ported back on top of the upstream
implementation separately: it asserts exactly one structured session survives a
replay, where the upstream tests assert the dedupe wiring.

* ci(mobile): close the round-1 signal gaps around agent.launch

Three review findings, all narrow.

Mobile Checks is path-filtered, and this branch made mobile's types depend on the
shared RPC contract: rpc-params-contract.ts is a type-only re-export of the
generated params catalog, and mobile/tsconfig.json includes **/*.ts. So a
desktop-only edit under src/shared/rpc-contract/ could break mobile's typecheck
with no mobile signal at all - the same blind spot the protocol-version.ts entry
closed, one directory over. Added src/shared/rpc-contract/** to the paths filter.

agent.launch had no cross-version trigger. Added the three prefixes a paired peer
actually exchanges: the intent contract, the wire schema, and the RPC method.
src/main/agent-launch/ is deliberately NOT listed - the executor shapes behaviour
but is not itself wire, and AgentLaunchResult's shape is already covered by
agent-launch-intent. Extending the cross-version SUITE to cover a negotiated
handshake is separate work, not this.

The break branch that answers an accepted-but-empty reply with "Failed to create
workspace" had no unit coverage; the golden that used to discriminate it
collapsed five partitions into one shared error when the null guard replaced the
unchecked read. Covered on BOTH routes - worktree.create with no worktree.id and
agent.launch with no worktreeId - since the branch serves both. Ablated by
bypassing the guard: 2 failed | 11 passed, the two new cases returning a
fabricated worktree instead of the error, restored to 13 passed.

* fix(agent-launch): give a launch one place to say the workspace is incomplete

createManagedWorktree reports an unspawned startup terminal or an uncopied
working tree as a top-level `warning`, and worktree.create hands it straight to
mobile. The launch path narrowed that result down to
{worktreeId, startupTerminalHandle} and dropped it, so every agent.launch create
lost a warning the old method surfaces - on both arms.

The channel was also asymmetric by accident rather than design: a terminal
outcome could carry `warning`, a structured one had nowhere to put it, so the
arm this PR exists to enable was the arm that could not report an incomplete
create at all.

Now there is exactly one place a launch warning lives: AgentLaunchResult.warning,
at the top level. It is about the create as often as the surface, it applies to a
structured session and a terminal alike, and a reader should not branch on
outcome.kind to discover the workspace it just opened is missing something. The
terminal arm's own `warning?` is removed rather than left beside it - two homes
for one fact is how they drift. Every producer folds in: the create, the surface,
and the refusal downgrade.

Consumer census before removing it: one production reader (mobile's
readAgentLaunchCreateOutcome) and no others - the renderer and mobile launch
call sites never read it. The mobile reader now reads the top-level field, which
also lets its outcome parser go away entirely.

Guard ablated by restoring the pre-fix narrowing: 2 failed | 24 passed, both
carriers reporting `expected undefined`, which is the dropped warning itself;
restored to 26 passed. The third case asserts an absence and stays green under
the mutation by construction - it pins shape, not the defect.

* fix(agent-launch): combine both launch warnings instead of dropping one

Round 2 found the comment here was false. A create warning and a surface warning
CAN both be set, on two reachable paths:

  1. The create warns precisely BECAUSE it produced no startup terminal -
     didSpawnStartup stays false when that spawn throws, and
     orca-runtime-create-managed-worktree.ts:283 gates startupTerminal on it - so
     the executor's early return is skipped and a second surface is built, which
     can warn too.
  2. An untracked-copy warning, then a definitive structured refusal downgrading
     to a terminal that also warns.

`??` kept the first and lost the second with nothing saying so. They are now
combined the way the create combines its own failures - appendFailure in
runtime-local-worktree-terminal-startup.ts, and the startup-terminal catch in
runtime-remote-managed-worktree-create.ts - which append rather than replace.

The comment is rewritten to say what is true, and records the gap NOT fixed
here: a create warning about a failed startup terminal is stale once the launch
recovers by building a working one, so a user can be told the agent did not start
while looking at it. Distinguishing those needs createManagedWorktree to stop
multiplexing two unrelated failures into one string.

Guarded and ablated: restoring `??` reddens exactly the new test, with the
surface clause missing from the received string; restored to 27 passed. The
structured-create stub had to admit its real ok-or-refusal union for the
downgrade path to be modellable at all - it previously declared only the ok arm.

Also: mobile.yml gains src/shared/agent-launch-intent.ts. It is the sole holder
of the agent.launch RESULT shape - the rpc-contract catalog holds params only -
and mobile imports it as a value. CROSS_VERSION_WIRE_PREFIXES already treats it
as wire-critical; without this, one gate does and the other cannot see it.

And the agent-first warning test no longer pairs "startup terminal failed" with a
returned handle, a combination the producer cannot emit.

* fix(mobile): read a launch warning an older host nests on the outcome

agent.launch moved `warning` from the terminal outcome to the top level of the
result. That is the right shape - a reader should not branch on `outcome.kind`
to learn the workspace it just opened is incomplete - but on the wire it is a
REMOVAL, and mobile only read the new place.

A host built before the move still advertises the same `agent.launch.v1`
capability, so the capability probe cannot tell the two apart and mobile takes
this route against one:

  protocol-version.ts:360       AGENT_LAUNCH_RUNTIME_CAPABILITY is in
                                RUNTIME_CAPABILITIES, the host list
  orca-runtime-get-status.ts:64 publishes it via status.get; the filter drops
                                only browser.screencast.v1 and three E2E-gated
                                capabilities, never agent.launch
  agent-launch-executor.ts      such a host writes warning INSIDE outcome

The result was a regression rather than a contract cleanup: the worktree.create
path this replaces returned the warning at the top level and mobile read it, so
a create that seated the workspace but could not start the agent surface - pty
exhaustion, untracked files not copied - stopped explaining itself on the phone.

Read both shapes for as long as such a host can be paired. Top level wins, and
cannot be shadowed: AgentLaunchOutcome has no `warning` on either arm, so a
current host cannot nest one.

The test that pinned the old behaviour is inverted here. Its comment was the
actual defect - it framed a legitimate warning from an older peer as a stale
shape to defend against, which is what made dropping it look deliberate.

* chore(mobile): raise the unchecked-reader ceiling for the agent.launch receipt

main landed `unchecked-rpc-reader-inventory.ts`, a ratchet on RpcOperation
readers that re-type their reply instead of validating it. Its ceiling for
mobile-workspace-create-operations.ts is 4, counted on a tree without this
branch's `agentLaunchRun`, so the merge produced "listed 4, found 5".

The inventory's own header prescribes this case: a merge is the one time a line
goes up without a migration undoing itself, and the instruction is to raise it
and name the PR that brought it. It describes main landing an operation the
branch never saw; here it is the mirror - the branch holds one main had not
seen - so the line is annotated with stablyai#19850 rather than left bare.

Not converted to `rpcResultVariant(variant, schema)`, which would lower the line
instead. That is a validation change rather than a migration, which is exactly
what the file's own comment says these five readers deliberately are not; the
agent.launch reply is already guarded at the consumer, where
readAgentLaunchCreateOutcome returns null on a malformed payload and the create
surfaces "Failed to create workspace". Writing a schema now would also target a
reply shape stablyai#20999 is actively redefining.

Ablated: with the line back at 4 the ratchet fails "listed 4, found 5"; at 5 it
passes.

---------

Co-authored-by: Merge Sim <sim@local>
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