Skip to content

fix(markdown): secure browser document bindings [4/5] - #2969

Draft
George Ng (GeorgeNgMsft) wants to merge 7 commits into
mainfrom
georgengmsft-markdown-browser-server
Draft

fix(markdown): secure browser document bindings [4/5]#2969
George Ng (GeorgeNgMsft) wants to merge 7 commits into
mainfrom
georgengmsft-markdown-browser-server

Conversation

@GeorgeNgMsft

@GeorgeNgMsft George Ng (GeorgeNgMsft) commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Summary

This change makes Markdown documents safer and more reliable to edit in the browser by keeping the browser, agent, collaboration session, and file on disk synchronized to the same document. It prevents stale or mismatched updates from overwriting newer work, supports nested document paths correctly, and behaves consistently across Windows, macOS, and Linux.

  • Securely binds every browser and agent operation to the active document, workspace, and revision.
  • Uses single-use read tokens and revision checks to reject stale, concurrent, or externally modified updates.
  • Keeps same-named files in different folders isolated in separate collaboration rooms.
  • Preserves nested document paths when loading, switching, saving, and collaborating.
  • Serializes browser binding transitions and server events so delayed responses cannot attach to the wrong document.
  • Keeps browser snapshots from overwriting newer editor changes.
  • Hydrates the shared collaboration state from the authoritative file content.
  • Restricts the Markdown service to IPv4 loopback and validates every durable file path against its canonical workspace root.
  • Handles macOS path aliases such as /var and /private/var correctly.
  • Refactors large IPC and event handlers into focused units that satisfy the repository complexity limits.

Rebase

  • Replayed only fix(markdown): secure browser document bindings [4/5] #2969's two commits from historical parent ab068c61a3275cad6762f82d0a10de6338e37931 onto main at c9eeb933b317afe2e29a432b325eabf02e8c1871.
  • Preserved current main's existing-only /file/load behavior and adapted browser fallbacks to the hardened asynchronous bound-document reader.
  • Current head: fe0a39c9d2beba1e1d63ae7f164e8903eba3d511.
  • Diff against main: 17 files changed, 2,203 insertions, 641 deletions.

Validation

  • pnpm run build markdown
  • pnpm --filter '@typeagent/markdown-agent' test — 98/98 tests passing
  • Prettier on all changed files
  • lint ratchet against origin/main
  • complexity ratchet against origin/main — over-threshold counts remain unchanged at 1 cyclomatic and 1 cognitive
  • circular-dependency ratchet against origin/main
  • debt-marker gate against origin/main
  • git diff --check
  • repeated adversarial reviews with GPT-5.6 Sol and Grok 4.6; findings were fixed and regression-covered
  • final complexity-only refactor independently reviewed by GPT-5.6 Sol and Grok 4.6 with no substantive findings
  • GitHub CI: 26 checks passing, 1 intentionally skipped; CodeQL reports no open alerts and both macOS Node 22/24 matrices pass

Stack

Native stack #2970 remains unchanged and ordered as [2966, 2967, 2968, 2969, 2971], including merged #2966, #2967, and #2968. This PR remains draft with base main; no stack metadata or #2971 branch content was modified.

@GeorgeNgMsft
George Ng (GeorgeNgMsft) force-pushed the georgengmsft-markdown-browser-server branch from 7bb4504 to 876bdb5 Compare September 3, 2026 23:01
@GeorgeNgMsft
George Ng (GeorgeNgMsft) force-pushed the georgengmsft-markdown-browser-server branch from 876bdb5 to 3f3cd47 Compare September 5, 2026 05:29
Base automatically changed from georgengmsft-markdown-durable-updates to main September 10, 2026 01:56
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@GeorgeNgMsft
George Ng (GeorgeNgMsft) force-pushed the georgengmsft-markdown-browser-server branch from 3f3cd47 to 970bb9d Compare September 11, 2026 00:57
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Comment thread ts/packages/agents/markdown/src/agent/documentUpdatePersistence.ts Fixed
Comment thread ts/packages/agents/markdown/src/agent/documentUpdatePersistence.ts Fixed
Comment thread ts/packages/agents/markdown/src/agent/documentUpdatePersistence.ts Fixed
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Comment thread ts/packages/agents/markdown/src/agent/documentPathPolicy.ts Fixed
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@GeorgeNgMsft
George Ng (GeorgeNgMsft) marked this pull request as ready for review September 11, 2026 05:08
@GeorgeNgMsft George Ng (GeorgeNgMsft) changed the title fix(markdown): secure browser document bindings fix(markdown): secure browser document bindings [4/5] Sep 11, 2026
@GeorgeNgMsft
George Ng (GeorgeNgMsft) marked this pull request as draft September 11, 2026 18:52
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.

2 participants