Skip to content

refactor(terminal): one commit module for terminal topology closes, with a boundary check - #25329

Merged
Jinwoo-H merged 18 commits into
mainfrom
terminal-topology-b1-1-commit-module
Oct 5, 2026
Merged

Jinwoo-H merged 18 commits into
mainfrom
terminal-topology-b1-1-commit-module

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 10 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​293 $\color{#cf222e}{\Huge{\mathbf{−}}}$​8 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​285
Prod 13 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​125 $\color{#cf222e}{\Huge{\mathbf{−}}}$​68 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​57

ELI5

The terminal layout (which tabs exist, which panes they hold, and which process each pane shows) is changed from many places in the main process. This PR adds the single place those changes are meant to go through and sends the explicit tab/pane close through it. It also adds a test that fails when new code outside that place starts calling the session or binding writers. Users see no difference.

What Changed

  • New src/main/persistence/terminal-topology/ module.
    • terminal-topology-commit.ts exposes closeLeafOrTab. It runs today's close (terminalSurfaceCloseMutation) unchanged, inside one persistence.terminal-topology trace span. The span records the kind (close_leaf / close_tab), the outcome (committed / noop / refused / threw) and the fixed refusal code. It carries no ids, paths or pane keys. The runtime's close (closeTerminalSurface) now calls it.
    • terminal-topology-membership.ts takes three helpers moved verbatim from runtime/workspace-session-terminal-membership-authority.ts: advanceTerminalTopologyRevision, findTerminalTabIdForLeaf and hasHostAuthoritativeTerminalMembership. Their importers are repointed, including the docs/audits/acknowledged-tab-retirement fixture.
  • Boundary ratchet test (terminal-topology-boundary-ratchet.test.ts). It parses every non-test file under src/main and pins, as an exact set, which files reference each named layout writer: the binding writer persistPtyBinding, the session setters setWorkspaceSession, patchWorkspaceSession, stageWorkspaceSessionBeforeUnload, setWorkspaceSessionForWorktree, the runtime controller's setForWorktree, the partition sinks setLocalWorkspaceSession / setHostWorkspaceSession, and the close transform terminalSurfaceCloseMutation (no file outside the module may use it). Code under terminal-topology/ is always allowed.
    • A new reference fails the test, whatever its static shape: a plain or ! call, x['name'], an alias, any destructure (renamed, quoted-key or into existing variables), .call / .bind, an extends argument. Type-only mentions (including import type) and the writers' own definitions (functions, class members) don't count. Every other mention of the name does, including object-literal keys: the check prefers a loud false alarm to a silent miss. A name computed at runtime (store[key], Reflect.get) can't be seen by any name-based check.
    • A listed file that stopped referencing also fails, so each later routing PR deletes its own rows.
    • Not covered: in-place mutation of the object getWorkspaceSession returns, and lifecycle writers (repo/worktree removal, identity rekey, SSH lease marks dropping a dead PTY's binding), which delete or rekey layout but never choose it. Later PRs route the layout-choosing writers explicitly.
  • The runtime session controller's set is renamed setForWorktree (one caller) so the ratchet can list it without matching every Map.set.

Before/after for users: none. Every path writes the same session contents as before. The only production difference is the new trace span on every pane/tab close transaction (explicit, cleanup, or main-initiated) when diagnostic tracing is on.

Why

This is the first step of the terminal layout refactor. Later PRs move each remaining writer behind this module, deleting their ratchet rows as they go. Doing it this way leaves no parallel path behind if later steps stall: the module only wraps existing code, and the ratchet only describes today's callers.

Alternatives considered:

  • A runtime write guard in tests (compare sessions at the sinks, blame the writer by stack trace). It was built and then removed. In the full unit suite it saw only two writers, it needed per-platform stack-path handling, and it cannot see writers that bypass the sinks. It can return once pane-to-process binding writes go through the store's session setters.
  • Routing binding (bindLeaf) now. Deferred to a later PR. Today the binding write never reaches a sink, so a wrapper would add nothing.
  • An oxlint rule instead of the AST test. It would need two rules with per-file overrides, and it loses exact-set semantics, so stale rows would never be forced out.

Known debt: the commit module imports the close transform from runtime/ until the close logic itself moves into the module.

Testing

  • pnpm tc, oxlint on changed files and pnpm run check:code-quality:changed pass.
  • New tests:
    • span outcomes for a pane close, a tab close, a refusal (pinned tab), a no-op (an echo of a recorded close) and a throw, with no ids in the record;
    • the boundary ratchet, which fails when one listed caller row is deleted.
  • Full unit suite (vitest run --config config/vitest.config.ts): the only failures also fail on base 4a41e24 on the test machine (browser-manager identity/viewport, a shell-ready repro, two fish-config-dependent shell tests, relay-region-correction).
  • The docs/audits/acknowledged-tab-retirement fixture's import is repointed. Its 20 tests fail the same way on origin/main (Writable Store construction requires a SQLite profile-state authority), so that audit was already stale before this PR.
  • Not manually tested in the app: there is no UI change and no change to what is saved; the trace span is covered by unit tests.
  • SSH and folder workspaces: the moved helpers and the close resolve the owning host partition exactly as before. The ratchet covers the relay reattach caller in ssh-relay-session.ts.

Linked Issue

Maintainer PR. Context: Linear STA-9417, STA-9259, STA-7961.

Visual Proof

N/A: no UI or behavior change (internal refactor plus a test).

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

…s into terminal-topology

advanceTerminalTopologyRevision, findTerminalTabIdForLeaf and
hasHostAuthoritativeTerminalMembership move verbatim from the renderer-save
membership rebase into persistence/terminal-topology, the home of the commit
boundary. Importers are repointed; no behavior change.
…t boundary

The three session sinks now publish through one commitWorkspaceSessionPartition
helper, which hands the prior and published partition to the topology write
guard. Production never arms the guard, so each sink pays one global lookup.

The unit suite arms it in report mode: a sink write that changes class-(a)
topology (membership, root, bindings, titles, incarnations, sleeping records,
remote session ids, tombstones, default-applied, revision) outside a commit
scope is attributed to its writer's file by stack, and fails the test unless
the writer is on the unrouted-writers allowlist that later routing PRs shrink.
Renderer saves and test seeding are exempt. Deep-freeze is available but stays
off suite-wide until the in-place writers return new sessions.
…seLeaf and closeTab

terminal-topology-commit.ts is the boundary for class-(a) terminal topology.
bindLeaf forwards to persistPtyBinding, whose write now runs in a commit
scope; the spawn commits and the relay reattach bind through it. closeLeaf and
closeTab wrap the existing close mutation in a commit scope and one
persistence.terminal-topology span (kind, outcome, refusal reason; no ids),
and the runtime close goes through them. Session output is unchanged: tests
compare it byte for byte with the old writers for local, ssh: and folder
workspaces.
…root

The guard read a frame's file through its last /src/ segment, so a test under
tests/ (folder-upgrade-identity-persistence.unit.test.ts) had no source frame
and failed as an unknown writer. Frames are now taken relative to the repo
root the setup passes in, tests/ counts as test seeding, Windows backslashes
are normalized before the node_modules skip, and nested src/ paths keep their
full path. The two runtime funnel files skip only their funnel function, so
another writer in them still shows. The R9 allowlist key names the file whose
frame actually writes. The class-(a) diff and the attribution move into their
own files; the stack limit is restored in a finally.
…he boundary ratchet

bindLeaf and the commit scope inside persistPtyBinding changed nothing: the
binding write never reaches a session sink, and a scope inside the Store method
would have admitted every direct caller once it did. Both return in B1-4; the
spawn commits and the relay reattach call persistPtyBinding directly again.

The runtime close now calls one closeLeafOrTab entry, so its callbacks keep
their contextual types. A census test is the primary enforcement: only
persistence/terminal-topology and the callers it lists may call
persistPtyBinding, the session setters or the three sinks, and every
unrouted-writer allowlist entry must name an existing file.
Under happy-dom the global URL is not Node's, so fileURLToPath(new URL(...))
threw in the setup file and failed every happy-dom test file.
@coderabbitai

coderabbitai Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

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: 2206f50d-3004-4f6d-a5f3-e3a962ad6a5b
📥 Commits

Reviewing files that changed from the base of the PR and between fe045c8 and c770c6a.

📒 Files selected for processing (2)
  • src/main/persistence/terminal-topology/terminal-topology-boundary-ratchet.test.ts
  • src/main/persistence/terminal-topology/terminal-topology-commit.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.


📝 Walkthrough

Walkthrough

Terminal membership helpers now reside in terminal-topology persistence, and runtime and test imports use that module. The workspace-session setter is now named setForWorktree. The terminal close path uses closeLeafOrTab, which records close outcomes in a topology span. New tests check persistence API caller allowlists and close span outcomes.

Priority: ⬇️ Low

Merge Risk: ⚪ Minimal · up to c770c

The previously reported caller-check bypasses are addressed for the cited call forms. No actionable merge-blocking risk remains after normal checks.

Security Architecture Review

Security architecture risk: 🔵 Low · up to c770c

Terminal ownership checks and close permissions remain unchanged. The main remaining risk is that an exceptional diagnostic failure could interrupt closing a terminal and disable further saving. No new attack path was established.

Retained concerns

  • Low · reliability · inferred: Optional diagnostics now share the close mutation’s fatal persistence failure domain. If span construction or completion throws, the durable executor freezes profile writes and closes the persistence authority, even when span construction failed before any terminal state changed. The disabled-tracing path and guarded sink writes reduce likelihood, but do not isolate all diagnostic operations.
Security review details

Security Blast Radius

  • inferred — The inspected change affects existing local and SSH terminal membership consumers rather than introducing a new remotely callable authority. The diagnostic failure concern can extend beyond one terminal to the active profile’s persistence writer, but no attacker-controlled trigger or privilege escalation was established.

Trust Boundaries and Controls

  • observed — Existing runtime controls still resolve the execution host, revalidate retirement ownership, check pane incarnation, and enforce pinned-tab behavior. The boundary ratchet adds a test-time exact file-set check for recognized writer names; its exclusions and name-based scanning mean it is not complete mediation of topology writes or a runtime security boundary.

Resilience and Maintainability Implications

  • observed — Tracing is a no-op without an active sink, and sink push failures are suppressed. Those controls protect common diagnostic failure modes, but span construction and redaction occur outside the sink-write catch, leaving the conditional failure-containment concern unresolved.

Hardening Proposals

  • proposed — Isolate optional span construction and completion failures from the admitted state-mutation result, while retaining fatal handling for genuine mutation exceptions. This would keep diagnostics from widening the persistence failure domain.
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 35 functions across 36 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title clearly summarizes the main changes: a terminal-topology close module and a boundary check. It is concise and specific.
Description check ✅ Passed The description covers the required sections and explains the change, rationale, testing, visual proof, and compatibility considerations. It also identifies the PR as a maintainer PR and provides issu…
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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 critical issues — one classification fix and one coverage note, both informational.

Reviewed changes

Foundation refactor for the single-writer terminal topology series (STA-9417, STA-9259). No user-visible behavior change; the only production delta is a new persistence.terminal-topology span on each close.

  • New persistence/terminal-topology/ module. terminal-topology-commit.ts wraps the existing terminalSurfaceCloseMutation in closeLeafOrTab and emits one low-cardinality span per close; terminal-topology-membership.ts receives the revision/leaf-lookup helpers moved verbatim from runtime/workspace-session-terminal-membership-authority.ts.
  • Sinks funnel through one helper. setLocalWorkspaceSession, setHostWorkspaceSession, and publishSession now publish via commitWorkspaceSessionPartition, preserving the local-vs-host partition split.
  • Boundary ratchet. A new test scans non-test src/** and asserts only an explicit allowlist calls persistPtyBinding, the session setters, the three sinks, or commitWorkspaceSessionPartition; it also fails when a listed caller stops calling.
  • Test-only write guard. Armed suite-wide by a vitest setup file; classifies class-(a) topology changes and fails tests whose sink write bypasses the commit module. Freeze stays off suite-wide because the binding write still mutates in place.
  • Moved call sites. Every importer of the moved membership helpers was updated; no stale imports remain. New tests pass locally (56 across the four new files), and the ratchet is green at head.

I verified that production behavior is preserved: the helper reproduces the prior assignments, setHostWorkspaceSession is only reached with a non-local host, and runDurableMutation runs the mutation exactly once so the span cannot double-emit.

ℹ️ The boundary check does not see direct session writes

The ratchet asserts that only allowlisted files call a fixed set of function names, and the write guard only observes writes that pass through commitWorkspaceSessionPartition. Neither sees a direct state.workspaceSession = … / state.workspaceSessionsByHostId = …, nor an in-place mutation of an already-published session. Several production paths do exactly that and change class-(a) fields today, so the "one writer" boundary can be crossed without either check firing.

Technical details
# Direct session writes bypass both enforcement mechanisms

## Affected sites (class-(a) impact)
- `src/main/persistence/loading-store/session-host-partitions.ts:142,145` — `removeWorkspaceSessionOwnerInPartition` (deletes tabs/layouts/incarnations/tombstones/revision via `removeWorkspaceSessionOwner`)
- `src/main/persistence/restoring-sessions/session-owner-removal.ts:84,95` — `removeWorkspaceSessionOwnerEverywhere`
- `src/main/persistence/loading-store/repo-lifecycle-operations.ts:79-88,113-131,151-155`
- `src/main/persistence/tracking-repos/repo-worktree-pruning.ts:108,117`
- `src/main/persistence/tracking-repos/worktree-identity-migration.ts:324-326` — in-place mutation of published sessions
- `src/main/persistence/loading-store/pty-binding-session-update.ts` (called from `pty-binding-persistence.ts:154`) — in-place binding mutation; the PR already acknowledges this via `freeze:false`

## Required outcome
- Decide whether these are in scope for the series. If yes, extend the ratchet to flag direct assignments to the session fields (not only calls to the named functions), or route them through `commitWorkspaceSessionPartition`; if they are deliberately out of scope, record that so "one writer" is not read as complete.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@Jinwoo-H Jinwoo-H closed this Oct 5, 2026
@Jinwoo-H Jinwoo-H reopened this Oct 5, 2026
@Jinwoo-H Jinwoo-H closed this Oct 5, 2026
@Jinwoo-H Jinwoo-H reopened this Oct 5, 2026
@Jinwoo-H Jinwoo-H closed this Oct 5, 2026
@Jinwoo-H Jinwoo-H reopened this Oct 5, 2026
…ry ratchet enforces

The AST boundary ratchet is the enforcement for B1. The stack-attributed
runtime guard, its class-(a) diff, the unrouted-writer allowlist, the vitest
setup and the freeze option are removed; it saw two writers in the whole unit
suite and its real value starts only once binding reaches a sink (B1-4).

Also: one closeLeafOrTab wraps the close in the span (no per-kind copies or
narrowed types), the span has one finish like persistence.pty-binding, the
sink helper is publishWorkspaceSessionPartition (it publishes; the commit
boundary is the module), the ratchet drops the private publishSession row and
checks that every listed caller file exists, and the close comparison keeps
its two meaningful cases with span cases chosen by name.
@Jinwoo-H Jinwoo-H changed the title refactor(terminal): one commit module for terminal topology writes, with a boundary check refactor(terminal): one commit module for terminal topology closes, with a boundary check Oct 5, 2026

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

🧹 Nitpick comments (1)
src/main/persistence/terminal-topology/terminal-topology-boundary-ratchet.test.ts (1)

62-66: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Detect string-literal element-access calls to listed sinks.

A new production call such as store['setWorkspaceSession'](session) passes the text prefilter, but calleeName returns null for its element-access expression. The caller is omitted from the exact-caller assertion. Handle string-literal element access; alias resolution is not needed for this call form.

Suggested fix
 function calleeName(callee: ts.Expression): string | null {
   if (ts.isIdentifier(callee)) {
     return callee.text
   }
-  return ts.isPropertyAccessExpression(callee) ? callee.name.text : null
+  if (ts.isPropertyAccessExpression(callee)) {
+    return callee.name.text
+  }
+  return ts.isElementAccessExpression(callee) && callee.argumentExpression &&
+    ts.isStringLiteral(callee.argumentExpression)
+    ? callee.argumentExpression.text
+    : null
 }

ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3e93541e-fad6-49cb-96de-4d3ecde2f541
📥 Commits

Reviewing files that changed from the base of the PR and between b1f5fd6 and 61982b0.

📒 Files selected for processing (8)
  • src/main/persistence/loading-store/session-host-partitions.ts
  • src/main/persistence/loading-store/session-snapshot-operations.ts
  • src/main/persistence/loading-store/workspace-session-partition-publication.ts
  • src/main/persistence/loading-store/workspace-session-snapshot-publication.ts
  • src/main/persistence/terminal-topology/terminal-topology-boundary-ratchet.test.ts
  • src/main/persistence/terminal-topology/terminal-topology-commit.test.ts
  • src/main/persistence/terminal-topology/terminal-topology-commit.ts
  • src/main/persistence/terminal-topology/terminal-topology-write-span.ts

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

@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 re-review of the delta since the prior pullfrog review (b1f5fd6): the commit that drops the test-only runtime topology write guard and renames the publish helper. The prior review covered the other 7 commits.

  • Removed the runtime write guard. Deleted the test-only guard, its class-(a) diff, writer attribution, the unrouted-writer allowlist, and the vitest setup that armed it; the AST boundary ratchet is now the sole enforcement.
  • Renamed the sink helper. commitWorkspaceSessionPartition → publishWorkspaceSessionPartition (workspace-session-partition-commit.ts → workspace-session-partition-publication.ts); the guard's observation calls are gone and the local-vs-host assignment is unchanged.
  • Simplified the commit wrapper and span. closeLeafOrTab is now one wrapper (no per-kind helpers or narrowed target types), and the span exposes a single finish(outcome, detail) in place of the separate finish/fail.
  • Updated the ratchet. Dropped the private publishSession row (its call sites reach the now-tracked helper), renamed the helper row, and the existence check now covers every listed caller file.
  • Trimmed the close test. Byte-equality now covers a pane close and a tab close, plus the four span outcomes.

The prior titlesByLeafId classification thread is resolved by deleting the class-(a) diff. I verified the ratchet and commit tests pass (pnpm exec vitest run --config config/vitest.config.ts, 15 tests) and tsc --noEmit -p config/tsconfig.node.json is clean; a grep confirms no dangling references to the removed modules.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

…hey enforce

- Point the acknowledged-tab-retirement audit fixture at the moved
  advanceTerminalTopologyRevision; its old import no longer resolved.
- Drop publishWorkspaceSessionPartition: it was the removed guard's
  interception point, so the three session sinks return to origin/main.
- One traced(kind, mutate) wrapper in the commit file replaces the span
  factory; closeLeafOrTab is one call.
- The ratchet walks src/main with the shared scanSourceTree, drops the
  loading-store-internal rows and the redundant file-exists test; exact-set
  equality already fails on a missing file.
- The commit test is a pure unit test of the span outcomes: no Store
  harness, electron mock or self-comparing close.

@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 re-review of the delta since the prior pullfrog review (61982b0): the single trim commit d54fc73. The earlier 8 commits were covered by the two prior reviews.

  • Reverted the sink funnel. publishWorkspaceSessionPartition and the session-host-partitions.ts / session-snapshot-operations.ts / workspace-session-snapshot-publication.ts changes are gone, so the three sinks are back to their base implementation and the ratchet no longer tracks them.
  • Narrowed the boundary ratchet. It now scans src/main through the shared scanSourceTree, uses paths relative to src/main, tracks only persistPtyBinding plus the four session setters, drops the redundant existence check, and exempts the audit fixture via TEST_SUPPORT.
  • Inlined the span. terminal-topology-write-span.ts is deleted; terminal-topology-commit.ts owns a private traced helper that emits the same persistence.terminal-topology span.
  • Trimmed the commit test. Byte-equality against terminalSurfaceCloseMutation is dropped; the test now asserts the five span outcomes.

The one prior inline thread (titlesByLeafId) is resolved. I re-ran the ratchet/commit/membership tests (14) and the repointed close/binding suites (46), and tsc --noEmit -p config/tsconfig.node.json is clean.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

… drop stage ids from comments

The controller's setter was named set, which the boundary census could not
list without matching every Map.set, so a new OrcaRuntime mixin could write
sessions through it unseen. Rename it setForWorktree and census it.
Comments now describe state instead of citing plan stage ids.

@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: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 0c00dced-f673-4dae-a904-b15eacff1be0
📥 Commits

Reviewing files that changed from the base of the PR and between d54fc73 and fe045c8.

📒 Files selected for processing (4)
  • src/main/persistence/terminal-topology/terminal-topology-boundary-ratchet.test.ts
  • src/main/persistence/terminal-topology/terminal-topology-commit.ts
  • src/main/runtime/orca-runtime-get-runtime-id.ts
  • src/main/runtime/runtime-workspace-session-controller.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/main/persistence/terminal-topology/terminal-topology-commit.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

…llback

- traced() takes refusalOf instead of assuming an Error refusal, and only
  mutate() sits in the try, so a span outcome of threw means the write threw.
- The boundary ratchet counts references, not just direct calls: non-null
  calls, bracket keys, aliases, destructures, .call/.bind and parenthesized
  callees all count; declared names and type positions do not.
- Census terminalSurfaceCloseMutation (boundary-only) and the partition sinks
  setLocalWorkspaceSession / setHostWorkspaceSession.
…ns, skip type-only imports and local declarations

The census skipped ExpressionWithTypeArguments as a type, which also holds
`extends f(x)` and `x<T>` value expressions. Type-only import/export
specifiers and declared names (variables, parameters, accessors, enum
members) no longer count as uses. The audit fixture is listed in the table
instead of a separate exemption.
…inition

Telling definitions from uses per syntax kind kept missing nested and
for-of destructures. Exempt only the writer's own function or class-member
definition; any other mention (including object-literal keys) counts, so the
census errs toward a loud false alarm rather than a silent miss. Quoted names
count only in member-name position.
Member-name positions missed wrapped keys like store[('name')] and
store['name' as const]. Counting every string literal outside types is
shorter and errs toward a loud false alarm.
…initions

Object-literal methods and accessors were exempt while equivalent arrow
properties counted; all object-literal keys now count alike.
A name spelled with a \u escape never appears verbatim, so the text
prefilter skipped it.
\x, identity and line-continuation escapes also decode to a writer name
without it appearing verbatim.

@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 re-review of the delta since the prior pullfrog review (d54fc73): the census rewrite that turns the boundary ratchet from a call-name check into a reference census, plus its supporting refactor.

  • Ratchet rewritten as a reference census. terminal-topology-boundary-ratchet.test.ts now parses each non-test src/main file with parent nodes and records any identifier or string literal naming a listed writer, excluding the writer's own function/class-member definition and type-only nodes. This catches element-access, alias, destructure, .call/.bind, and extends forms the prior call-only check missed.
  • Allowlist regrown to the reference semantics. setWorkspaceSession expands to every referencing file; setLocalWorkspaceSession, setHostWorkspaceSession, setForWorktree, and terminalSurfaceCloseMutation (empty outside the boundary) gain their own rows, all relative to src/main. The audit fixture is now listed directly, replacing the TEST_SUPPORT exemption.
  • Escape-aware prefilter. Files are parsed when they contain any backslash, not just \u, so a writer name spelled with a hex/unicode escape is still seen; the raw-text name prefilter is unchanged.
  • set renamed setForWorktree. The runtime session controller's write and its single caller in orca-runtime-get-runtime-id.ts are renamed so the census can list it without matching every Map.set.
  • Commit span refusal by callback. traced now takes a refusalOf callback and reads the mutation result outside the try, so topology.outcome: 'threw' means the write threw, never tracing.

I confirmed production behavior is unchanged (the only delta is the span's shape and the rename), and verified the ratchet/commit tests (14), the repointed close/binding suites (46), and pnpm tc:node are green.

Pullfrog  | View workflow run | Using deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@Jinwoo-H
Jinwoo-H merged commit 2a68ea9 into main Oct 5, 2026
60 of 61 checks passed
OrcaWin added a commit that referenced this pull request Oct 6, 2026
…'s boundary ratchet (#25823)

Main's #25329 added the ratchet; phase3's mobile-session-editor-projection.ts writes the host's
own session through setWorkspaceSessionForWorktree, the same way the listed headless
mobile-session tab writers do.

Co-authored-by: m4air <[email protected]>
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