Files
DeepSeek-Reasonix/internal/productdocs
SivanCola 4daa815be8 Refactor chat, permissions, and Windows sandbox around Harness / 以 Harness 重构聊天、权限与 Windows 沙箱 (#10209)
* feat: align chat and permissions with Harness

Replace the virtualized transcript and split approval/sandbox policy with a
natural-flow chat surface, stable node subscriptions, unified permission
presets, precise session grants, and platform sandbox enforcement.

Port the Harness-style process rows, turn footer, navigator, file presentation,
and full-access confirmation while preserving Reasonix history and provider
contracts. Add the Windows restricted-token sandbox and fail-closed capability
reporting, together with migration, remote compatibility, documentation, and
acceptance evidence.

* chore: refresh repolint baseline for one-shot refactor

Record the deliberate carry-forward from the transcript, remote presentation,
permission, and Windows sandbox changes. The refreshed baseline also captures
size and complexity reductions produced by the same extraction work.

* fix: align permission refactor with CI contracts

* fix: stabilize cross-platform permission CI

Problem:
The permission refactor left headless Windows tests on the workspace sandbox, exposed Windows-only lint findings, and let the transcript browser resolve Playwright assets from the wrong directory.

Root cause:
Tests used the interactive mode setter for a headless controller, direct Bash fixtures did not stamp their intended unrestricted preset, the transcript benchmark imported Playwright before normalizing its browser path, and Windows-tagged files had not been linted locally.

Fix:
Use the headless permission entry point, make Bash fixture intent explicit, normalize the transcript benchmark root before importing Playwright, and apply the Windows lint corrections without changing sandbox behavior.

Verification:
- go test ./...
- cross-platform golangci-lint for linux, darwin, and windows
- Windows amd64 cross-compilation for boot, builtin, and winsandbox tests
- transcript Chromium browser replay for 240 and 1,000 turns
- go run ./tools/repolint

* test: harden native transcript and shell contracts

Problem:
The Linux native-scrollbar regression clicked the bottom arrow instead of the scrollbar thumb, and direct shell-contract tests inherited the new workspace-write default on Windows hosts without a sandbox backend.

Root cause:
The browser test used a fixed bottom-edge coordinate, while shell fixtures invoked Bash outside the controller path and therefore had no host-stamped permission preset.

Fix:
Compute the native thumb center from scrollbar geometry, retain CI screenshots as artifacts, and mark direct shell execution fixtures with an explicit full-access test context while preserving restricted-sandbox tests.

Verification:
- go test ./internal/tool/builtin -count=1
- Windows amd64 cross-compilation for internal/tool/builtin
- GOOS=windows golangci-lint run --timeout=5m ./...
- Chromium transcript replay for 240 and 1,000 turns
- go run ./tools/repolint

* perf: bound cumulative transcript mounting

Problem: The 1,000-turn Linux browser replay exceeded the 500 ms long-task budget while cumulative history pages were mounted.

Root cause: Transcript subtree mutations repeatedly rescanned all loaded rows, and each 60-turn history page committed its full natural-flow DOM in one frame.

Fix: Observe direct chat-node additions only, retain per-row resize observation for internal content changes, enumerate direct row children, and reveal prepended history across bounded adjacent-frame commits without unmounting existing rows.

Verification: frontend typecheck; chat natural-flow and scroll-controller tests; Chromium transcript replay (1,000 turns: 122.7 ms input P95, 161 ms longest task, 0 px anchor drift); repolint clean.

* fix: keep transcript hydration synchronous

Problem: The progressive history mount delayed initial and replacement transcript content by one frame, breaking remote hydration visibility contracts.

Root cause: The bounded reveal path treated every order change like a history prepend, including an empty initial order and authoritative session replacement.

Fix: Restrict progressive rendering to a contiguous non-empty suffix with newly added leading nodes; hydrate, replace, and grow the tail synchronously.

Verification: remote-session-surface 101/101; frontend typecheck; chat natural-flow and scroll-controller tests; Chromium transcript replay within input and long-task budgets.

* fix: stabilize transcript and Windows CI

Problem:
Linux transcript hydration remapped every mounted node on each history page and exceeded the 500ms long-task budget. The Windows project-session migration test also raced asynchronous catalog startup.

Root cause:
The order subscriber owned the full React child map even while progressive hydration intentionally retained the previous order reference. The catalog test requested reconciliation before the catalog had been published.

Fix:
Memoize the node-seat mapping by rendered-order identity so only committed history chunks reconcile. Wait for catalog publication before requesting the production reconcile path, and move shared catalog polling helpers out of the oversized test file.

Verification:
- 1,000-turn Chromium transcript benchmark: max long task about 249ms
- frontend typecheck and hooks lint
- project CLI migration tests, 10 repetitions
- repolint and git diff checks

* perf: bound cumulative transcript layout

Problem:
Linux 1000-turn transcript replay still exceeded 500ms after seat memoization because each history page reconciled existing seats and the turn rail forced layout of every loaded mark.

Root cause:
Progressive prepend kept one flat React child list, unchanged turns were reprojected, and the navigator read scroll geometry and rendered all marks after every page.

Fix:
Keep immutable 24-node seat chunks, cache unchanged turn projections, isolate row layout, window rail marks while retaining full loaded-turn geometry, and make benchmark waits target exact mounted anchors without weakening thresholds.

Verification:
- Chromium 1000-turn: max 196ms, input P95 119ms, 2407ms full mount
- Full transcript test suite
- Frontend build, typecheck, lint and bundle checks
- Go migration tests 10x
- Repository lint and diff checks

* Serialize permission changes with approval commits

Problem: permission revisions could change while an older approval was still recording and installing its session grant, exposing a mixed snapshot and allowing cross-version authorization.

Root cause: mode changes, grant revocation, approval resolution, and permission snapshot reads used separate synchronization boundaries.

Fix: establish permissionMu -> promptResolveMu -> permissionStateMu ordering, publish preset/revision/grants atomically, cancel the captured old turn outside the state mutation, and cover both legal concurrent orderings with a deterministic barrier test.

Verification: go test -race ./internal/control (including five repeated targeted runs), Windows amd64 cross-compilation, and repository lint all pass.

* Preserve chat nodes across history prepends

Problem: loading older history repartitioned existing messages under different chunk parents, remounting their DOM and losing selection, focus, and local disclosure state.

Root cause: the rendered order was grouped into position-derived SeatChunk components and regrouped whenever a prefix crossed a 24-node boundary.

Fix: render every business node under one stable parent, progressively reveal only the new flat prefix, and publish the committed mounted order so navigation never advertises a missing target.

Verification: transcript unit tests cover 1/5/23/24/25/48/49-node boundaries and 60 resident DOM identities; Chromium, WebKit, and Electron layout and 240/1000-turn production replays pass.

* Clarify full-access host execution semantics

Problem: product copy implied that Reasonix filesystem and network sandbox guarantees continued to apply after selecting full access.

Root cause: permission labels were updated without consistently documenting Harness-style unsandboxed execution across the desktop, CLI, bot, Windows, and site surfaces.

Fix: state that full access runs with the current OS account, retains explicit pre-launch host denies, and does not constrain behavior inside the launched process.

Verification: desktop locale typecheck/build, documentation tests, site tests, and full-text consistency checks pass.

* Stabilize virtual rail navigation coverage

Problem: the Windows Electron layout check sometimes reached the test after the active turn had already scrolled the Harness-style virtual rail to its tail, leaving the early turn mark unmounted.

Fix: explicitly scroll the rail to its loaded start before the early keyboard jump, then to its loaded tail before the final jump.

Verification: Chromium reports 39 passing geometry scenarios and Electron reports 42.

* Make permission ordering test platform-neutral

Problem: the Windows control runner correctly reports restricted presets unavailable before its native sandbox is initialized, so the new concurrency test failed before reaching the transaction it was meant to exercise.

Fix: drive the same serialized Controller mode-change path directly; platform capability rejection remains covered separately at the public preset boundary.

Verification: the ordering suite passes ten times under the race detector and internal/control cross-compiles for Windows amd64.
2026-09-13 13:41:48 +08:00
..