Skip to content

feat(tree): add schema change telemetry - #27996

Merged
Abram Sanderson (Abe27342) merged 3 commits into
microsoft:mainfrom
Abe27342:user/absander/shared-tree-schema-telemetry
Aug 24, 2026
Merged

feat(tree): add schema change telemetry#27996
Abram Sanderson (Abe27342) merged 3 commits into
microsoft:mainfrom
Abe27342:user/absander/shared-tree-schema-telemetry

Conversation

@Abe27342

@Abe27342 Abram Sanderson (Abe27342) commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Description

Adds a SchemaChangeApplied telemetry event whenever SharedTree applies an effective schema transition. The event classifies initialization, upgrade, restriction, and rollback transitions and records privacy-safe structural metrics without logging schema payloads or identifiers.

All computed event properties are tagged as code artifacts. Tests cover required-root initialization, which applies an intermediate schema, and a compatible schema expansion.

Reviewer Guidance

The review process is outlined on this wiki page.

Please review the event shape and the decision to emit once per applied schema inner-change, including intermediate initialization transitions.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: c15a72a2-03e3-4dbe-bc9b-6d4c60a3ac28
@github-actions github-actions Bot added area: tools area: dds Issues related to distributed data structures area: repo Repo related work area: website area: dds: tree base: main PRs targeted against main branch labels Aug 18, 2026
@github-actions

github-actions Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

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

Based on the diff (160 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

@Abe27342
Abram Sanderson (Abe27342) marked this pull request as ready for review August 18, 2026 00:31
@Abe27342
Abram Sanderson (Abe27342) requested a review from a team as a code owner August 18, 2026 00:31
Copilot AI lite review requested due to automatic review settings August 18, 2026 00:31

Copilot AI 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.

Pull request overview

Adds schema-change telemetry to SharedTree so that whenever an effective stored-schema transition is applied, a SchemaChangeApplied event is emitted with privacy-safe, structural metrics (counts/booleans) and a classification of the transition (initialize/upgrade/restriction/rollback). This fits into the tree DDS’s observability story alongside existing checkout telemetry (e.g., revert telemetry).

Changes:

  • Emit a SchemaChangeApplied telemetry event for each applied schema inner-change, tagging computed properties as code artifacts.
  • Compute and include structural metrics for schema transitions (node-schema added/removed counts, root-field kind/type-count deltas, etc.).
  • Add tests that validate the emitted event shape/values for initialization (including intermediate transitions) and a compatible schema expansion.

Reviewed changes

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

File Description
packages/dds/tree/src/shared-tree/treeCheckout.ts Emits SchemaChangeApplied during schema application and computes privacy-safe schema transition metrics.
packages/dds/tree/src/test/shared-tree/treeCheckout.spec.ts Adds coverage validating schema-change telemetry emission and expected metrics for initialization + upgrade scenarios.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/dds/tree/src/test/shared-tree/treeCheckout.spec.ts
Comment thread packages/dds/tree/src/shared-tree/treeCheckout.ts Outdated
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: c15a72a2-03e3-4dbe-bc9b-6d4c60a3ac28
}

return {
changeKind: isInverse

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.

Consider adding these properties in a "details" object. These will likely end up in "Payload" anyway because we reached the max number of columns in our tables (at least we had some time back).
Adding to "details" will also make it easier to look for in telemetry in one place.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: c15a72a2-03e3-4dbe-bc9b-6d4c60a3ac28
@github-actions

Copy link
Copy Markdown
Contributor

Bundle size comparison

Base commit: 53eb97dcb06a9563caf37275f89f20b28104461d
Head commit: 48b9a662baf4b7e4845a1a0786d02e7a62921241

Notable changes

  • 🔴 fluidFrameworkAllAlpha.js: parsed 784455 → 785341 (+886), gzip 215039 → 215321 (+282)
  • 🔴 fluidFramework.js: parsed 403755 → 404619 (+864), gzip 114484 → 114731 (+247)
  • 🔴 sharedTree.js: parsed 393159 → 394016 (+857), gzip 111926 → 112175 (+249)
Per-bundle deltas

@fluid-example/bundle-size-tests

  • 🔴 fluidFrameworkAllAlpha.js: parsed 784455 → 785341 (+886), gzip 215039 → 215321 (+282)
  • azureClient.js: parsed 624847 → 624903 (+56), gzip 166640 → 166686 (+46)
  • odspClient.js: parsed 597135 → 597191 (+56), gzip 159785 → 159828 (+43)
  • aqueduct.js: parsed 531223 → 531258 (+35), gzip 142114 → 142143 (+29)
  • 🔴 fluidFramework.js: parsed 403755 → 404619 (+864), gzip 114484 → 114731 (+247)
  • 🔴 sharedTree.js: parsed 393159 → 394016 (+857), gzip 111926 → 112175 (+249)
  • containerRuntime.js: parsed 309144 → 309158 (+14), gzip 84569 → 84576 (+7)
  • sharedString.js: parsed 176510 → 176517 (+7), gzip 49798 → 49806 (+8)
  • experimentalSharedTree.js: parsed 160665 → 160665 (0), gzip 46265 → 46265 (0)
  • matrix.js: parsed 160341 → 160348 (+7), gzip 45798 → 45805 (+7)
  • loader.js: parsed 145704 → 145718 (+14), gzip 39286 → 39302 (+16)
  • odspDriver.js: parsed 103906 → 103927 (+21), gzip 32404 → 32411 (+7)
  • directory.js: parsed 67110 → 67117 (+7), gzip 18859 → 18866 (+7)
  • 578.js: parsed 58686 → 58686 (0), gzip 17657 → 17657 (0)
  • map.js: parsed 47205 → 47212 (+7), gzip 14455 → 14462 (+7)
  • odspPrefetchSnapshot.js: parsed 45635 → 45649 (+14), gzip 15242 → 15249 (+7)
  • 252.js: parsed 44362 → 44362 (0), gzip 13735 → 13735 (0)
  • summarizerDelayLoadedModule.js: parsed 30717 → 30717 (0), gzip 7716 → 7716 (0)
  • socketModule.js: parsed 26469 → 26476 (+7), gzip 7896 → 7904 (+8)
  • createNewModule.js: parsed 12454 → 12454 (0), gzip 4797 → 4797 (0)
  • summaryModule.js: parsed 3789 → 3789 (0), gzip 1857 → 1857 (0)
  • connectionState.js: parsed 909 → 909 (0), gzip 500 → 500 (0)
  • sharedTreeAttributes.js: parsed 847 → 854 (+7), gzip 499 → 508 (+9)
  • debugAssert.js: parsed 429 → 429 (0), gzip 299 → 299 (0)
  • FluidFramework-HashFallback.js: parsed 419 → 419 (0), gzip 313 → 313 (0)

@Abe27342
Abram Sanderson (Abe27342) merged commit 68f844c into microsoft:main Aug 24, 2026
34 checks passed
@Abe27342
Abram Sanderson (Abe27342) deleted the user/absander/shared-tree-schema-telemetry branch August 24, 2026 17:38
Noah Encke (noencke) added a commit that referenced this pull request Aug 27, 2026
…17 (#28104)

## Description

Cherry-picks the SharedTree history and persisted-commit-metadata work
onto the
`release/client/2.117` branch. This is step 4 of the 2.117 release plan
(branch created from
`release/client/2.116` + version bump); release notes, changelogs and
assert tagging are handled
separately by the release engineers.

Four commits, applied in merge order (each with `git cherry-pick -x`, so
the original SHA is recorded
in the commit message):

| Commit on `main` | PR | What it provides |
|---|---|---|
| `22e5b4ee` |
[#27932](#27932) |
Renames the alpha `TreeBranchAlpha` interface to `UntypedTreeViewAlpha`
(old name kept as a deprecated alias, so it is additive). Carries no
feature, but #28012 is written against the new name, so it is a
prerequisite rather than an optional cleanup. |
| `3b665a2a` |
[#28036](#28036) |
`retainHistory` now retains the trunk in *summaries*, not just in
memory. Without it, retained history is discarded at the next summary
and never reaches clients that load from it. No persisted format change;
the `retainHistory: false` default is untouched. |
| `920e9469` |
[#28012](#28012) |
`UntypedTreeViewAlpha.branchHistory` (`length`, `getHead()` →
`TreeBranchCommitMetadata { revision, getParent() }`), plus
`rewindTo(revision)` and `revertTo(revision, options?)`. |
| `90337165` |
[#28064](#28064) |
Persisted commit metadata: `customMetadata` on
`RunTransactionParamsAlpha` and the revert options, read back as
`.custom` / `.customTree`. Stored inline on commits in the `EditManager`
summary under `EditManagerFormatVersion.v7` / `MessageFormatVersion.v7`,
written only when `minVersionForCollab` is at least `2.117.0`. |

A fifth commit adapts the picks to this branch — details below.

### Why a minor rather than a patch

#28064 changes a persisted format, and the format gate is a version
string baked into SharedTree's
source. The config map that selects a format version rejects patch
versions, so the gate has to be an
`X.Y.0`. It is `FluidClientVersion.v2_117 = "2.117.0"`.

### Forward compatibility with 3.0

All four commits are already on `main`, and `main`'s tip was #28064 when
this was prepared, so the two
lines could be compared directly. Everything that ships here is
identical to 3.0:

- The whole persisted-format surface — `src/codec/` and
`src/shared-tree-core/` — is byte-identical
between this branch and `main`, including the `v2_117` → v7 gate. A
mixed 2.117/3.0 session cannot
  silently disagree about the format.
- Every alpha symbol added here (`TreeBranchHistory`,
`TreeBranchCommitMetadata`, `branchHistory`,
`rewindTo`, `revertTo`, `customMetadata`, `customTree`, `retainHistory`,
`UntypedTreeViewAlpha`,
`RunTransactionParamsAlpha`, `RevertOptionsAlpha`,
`RevertToOptionsAlpha`) is identical on both
  lines, at the same API tier, with the same deprecation state.
- `minVersionForCollab: '2.117.0'` stays valid on 3.0:
`OldestSupportedClientVersion` *widens* from
`` `${1 | 2}.${bigint}.${bigint}` `` to `` `${1 | 2 | 3}....` ``, so
consumers who adopt 2.117 need
  no change in this area when they later move to 3.0.

## Adapting the picks to this branch

`main` is on TypeScript 6 and past the 3.0 bump; this branch is
TypeScript 5.4 and pre-3.0. Conflicts
were all of one shape — an import list where `main` has accumulated
names from commits that are *not*
being backported — and were resolved by keeping only what this branch
actually uses:

- `src/index.ts` — kept `asTreeViewAlpha` (removed on `main` by 3.0
work) alongside the incoming
  `TreeBranchCommitMetadata` / `TreeBranchHistory`.
- `src/shared-tree/treeCheckout.ts` — kept `StableId` and
`findAncestor`, which #28012 uses; dropped
`tagCodeArtifacts` (used on `main` only by schema-change telemetry,
#27996) and
`getDeltaChangeProfile` (introduced by #27989). Neither is backported
here.
- `src/test/shared-tree/schematizeTree.spec.ts` — kept
`TreeBranchHistory`; dropped
`UntypedTreeViewAlpha`, which was added to that import by the TypeScript
6 upgrade (#28052) rather
  than by #28012.

One genuine TypeScript-version difference, in the fifth commit:

- `customCommitMetadata.spec.ts` used `.filter((m) => m !== undefined)`
and then read `.tag`, relying
on **inferred type predicates**, a TypeScript 5.5 feature. On 5.4 the
element type stays
`T | undefined` and the compiler reports TS18048. The predicate is now
spelled explicitly. This was
  the only TypeScript error in the entire build.

The two conflicted `*.api.md` files are generated artifacts, so rather
than hand-resolving them they
were regenerated by a full clean build from the repo root. That
correctly drops `asAlpha`,
`codePointCount` and `utf16LengthForCodePoints` — whose exports come
from #28011 and #28004, not
backported here — and narrows `OldestSupportedServiceClientVersion` to
`` `2.${bigint}.0` ``.

## Validation

- Full `pnpm clean && pnpm build` from the repo root: succeeded, and
left the working tree clean apart
  from the intended API report updates. No unexpected API report drift.
- `@fluidframework/tree` test suite: **15301 passing, 488 pending, 1
failing**. The one failure is a
pre-existing Windows-only issue in
`snapshotCompatibilityChecker.spec.ts`, which builds the
directory under test with `path.join(...)` but hardcodes forward slashes
in the expected error
  string. It is untouched by these commits and passes on Linux CI.

## Reviewer Guidance

The review process is outlined in [the pull request
guidelines](../docs/content/Contributing/PR-Guidelines.md#guidelines).

- The first four commits are unmodified cherry-picks; review effort is
best spent on the fifth
(`fix(tree): adapt the backported history work to the 2.117 line`) and
on the conflict resolutions
described above, since those are the only places this branch diverges
from what was reviewed on
  `main`.
- **Assert tagging is deliberately not included here.** The three new
asserts are still untagged
string literals, so `flub release prepare client` will report them.
Running
`flub generate assertTags` on a release branch allocates short codes
from the branch's own
high-water mark, which can disagree with `main` — on `main` today it
would reassign `0xd33`, a code
that shipped in 2.116 as `"compatibilityMode must be defined"`, to a
tree assert. Happy to follow
  whatever sequencing the release engineers prefer.

---------

Co-authored-by: jzaffiro <110866475+jzaffiro@users.noreply.github.com>
Co-authored-by: yann-achard-MS <97201204+yann-achard-MS@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 3af96e03-702e-49da-adaa-bc99ca75ee27
Copilot-Session: eedf6254-a76e-4efe-af90-1f7b43da8665
Copilot-Session: a037b96b-478f-4a65-9555-d7a970e7855e
Copilot-Session: 42b443d7-0621-42a1-b087-f4e4765046af
Copilot-Session: 797fba3e-0e9a-48db-86c6-530aa2837434
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: dds: tree area: dds Issues related to distributed data structures area: repo Repo related work area: tools area: website base: main PRs targeted against main branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants