Skip to content

fix(tree): Constrain column removal on rows like we constrain row removal on columns#27226

Closed
Josmithr wants to merge 1 commit intomicrosoft:mainfrom
Josmithr:tree/table/constrainRemoveColumns
Closed

fix(tree): Constrain column removal on rows like we constrain row removal on columns#27226
Josmithr wants to merge 1 commit intomicrosoft:mainfrom
Josmithr:tree/table/constrainRemoveColumns

Conversation

@Josmithr
Copy link
Copy Markdown
Contributor

@Josmithr Josmithr commented May 4, 2026

See new unit test for the scenario being captured.

@Josmithr Josmithr requested review from Copilot and jumyhre May 4, 2026 23:43
@Josmithr Josmithr requested a review from a team as a code owner May 4, 2026 23:43
@Josmithr Josmithr closed this May 4, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 4, 2026

Hi! Thank you for opening this PR. Want me to review it?

Based on the diff (48 lines, 2 files), I've queued these reviewers:

  • Correctness — logic errors, race conditions, lifecycle issues
  • Security — vulnerabilities, secret exposure, injection
  • API Compatibility — breaking changes, release tags, type design
  • Performance — algorithmic regressions, memory leaks
  • Testing — coverage gaps, hollow tests

How this works

  • Adjust the reviewer set by ticking/unticking boxes above. Reviewer toggles alone don't trigger anything.

  • Tick Start review below to dispatch the review fleet.

  • After review finishes, tick Start review again to request another run — it auto-resets after each dispatch.

  • This comment updates as new commits land; your reviewer selections are preserved.

  • Start review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR tightens Table.removeColumns() undo behavior so that reverting a column removal is dropped if doing so would reintroduce cells for rows that have since been removed (mirroring the existing constraint pattern in removeRows()).

Changes:

  • Add preconditionsOnRevert constraints to removeColumns() to require the relevant rows still exist when the column-removal is undone.
  • Add a unit test capturing the cross-client scenario where a row removal would otherwise orphan cells when a column removal is undone.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
packages/dds/tree/src/tableSchema.ts Adds row-existence constraints on revert for removeColumns() transactions to prevent orphaned cells after undo.
packages/dds/tree/src/test/tableSchema.spec.ts Adds a regression test for dropping undo of removeColumns() when a row is concurrently removed.

Comment on lines +777 to +786
// Relevant invariant: each cell corresponds to an existing row and column
// Adding a constraint on rows here to prevent cells being orphaned. The relevant scenario is:
// Client A removes columns
// Client B (either concurrently or not, so long as B's edit is sequenced after A's edit) removes a row,
// Client A reverts the removal of the columns
// TODO: Replace with "no detach on revert" constraint on the row array when available.
const rowConstraints: TransactionConstraintAlpha[] = this.table.rows.map((row) => ({
type: "nodeInDocument",
node: row as RowValueType,
}));
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