Skip to content

perf(web): replace quadratic LCS with Myers diff and fix deploy workflow - #281

Merged
williamzujkowski merged 1 commit into
mainfrom
fix/deploy-and-myers-diff
Oct 6, 2026
Merged

williamzujkowski merged 1 commit into
mainfrom
fix/deploy-and-myers-diff

Conversation

@williamzujkowski

Copy link
Copy Markdown
Collaborator

Description

This PR resolves issue #280 and fixes the GitHub Pages deployment failure in the Deploy Site workflow.

Changes

  1. Myers Diff for Legal Redline (perf(web): replace quadratic LCS diff with Myers or linear-space diff in DiffViewer #280):

    • Implemented Eugene W. Myers' (ND)$ Shortest Edit Script (SES) algorithm in apps/web/src/lib/word-diff.ts.
    • Added (\min(N, M))$ common prefix and suffix trimming before edit graph traversal.
    • Added safety cap threshold fallback ( \times M > 250,000$ or tokens $> 1,500$) to guarantee the browser main UI thread never locks on massive textual changes.
    • Refactored DiffViewer.svelte to consume computeWordDiff and WordToken from apps/web/src/lib/word-diff.ts.
    • Added vitest unit test suite covering empty inputs, word substitutions, legislative amendment texts, 50-paragraph performance benchmarks, and fallback caps.
  2. Deploy Site Workflow Monorepo Build Fix:

    • Updated .github/workflows/deploy-site.yml to build web and its workspace monorepo dependencies (@civic-source/shared, @civic-source/types) via pnpm --filter @civic-source/web... build before Astro builds.
    • Expanded workflow push trigger paths to include packages/** and scripts/** so changes to dependencies trigger site deployment.

Closes #280

- Replace O(M*N) 2D matrix LCS in DiffViewer with Myers' O(ND) algorithm in apps/web/src/lib/word-diff.ts
- Add prefix/suffix trimming and max-cells fallback cap to prevent UI locking on large statutory diffs
- Add comprehensive vitest suite in apps/web/src/__tests__/word-diff.test.ts
- Build workspace package dependencies in deploy-site workflow before web build
- Resolves #280
@williamzujkowski
williamzujkowski requested a review from a team as a code owner October 6, 2026 14:01
@williamzujkowski
williamzujkowski merged commit b85c564 into main Oct 6, 2026
3 checks passed
@williamzujkowski
williamzujkowski deleted the fix/deploy-and-myers-diff branch October 6, 2026 14:13
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.

perf(web): replace quadratic LCS diff with Myers or linear-space diff in DiffViewer

1 participant