Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite ViewSchema.checkCompatibility to leverage discrepancies #23192

Merged
merged 24 commits into from
Dec 12, 2024

Conversation

Abe27342
Copy link
Contributor

Description

Updates ViewSchema.checkCompatibility to leverage the getFieldDiscrepancies codepath.

This also puts in place infrastructure to allow viewing the document when the only differences between view and stored schema are extra optional fields in the stored schema on nodes that the view schema author has declared are OK.

@Abe27342 Abe27342 requested a review from a team as a code owner November 22, 2024 23:07
@github-actions github-actions bot added base: main PRs targeted against main branch area: dds Issues related to distributed data structures area: dds: tree public api change Changes to a public API labels Nov 22, 2024
@Abe27342
Copy link
Contributor Author

Abe27342 commented Nov 22, 2024

It's probably feasible to split optional field work into a different PR and make this one more about using the new compatibility logic. I can do that if this space is difficult for the reviewer to reason about, or if we're concerned about risk of this change.

I am aware of a few ways that the new compatibility logic is not totally equivalent to the old one, but only places where it is stricter and probably doesn't matter in practice (e.g. it doesn't detect all types of never fields as equivalent, but realistic customers probably aren't going around and declaring such things anyway).

Another thing which we used to allow but now do not is upgrading from an object node schema to a map node schema over the union of all the object fields' types. This is probably not something people are particularly yearning for, and TBH I'm not totally convinced we have the test coverage which verifies this actually works beyond it being theoretically sound.

One thing to watch out for is that a lot of our test coverage for 'the new code path' being equivalent to 'the old code path' comes from implementing an isRepoSuperset based on getFieldDiscrepancies and asserting it is equivalent to the previous compatibility logic's allowsRepoSuperset. Because the new compatibility check no longer directly uses isRepoSuperset, this coverage doesn't directly apply. As such, I wrote a test suite explicitly for ViewSchema which should cover what we need (but reviewer: please verify this!)

@github-actions github-actions bot added area: examples Changes that focus on our examples area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct labels Nov 25, 2024
Copy link
Collaborator

@msfluid-bot msfluid-bot left a comment

Choose a reason for hiding this comment

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

Code Coverage Summary

↓ packages.dds.tree.src.simple-tree.api:
Line Coverage Change: 0.21%    Branch Coverage Change: -0.83%
Metric NameBaseline coveragePR coverageCoverage Diff
Branch Coverage 89.77% 88.94% ↓ -0.83%
Line Coverage 82.35% 82.56% ↑ 0.21%
↓ packages.dds.tree.src.core.schema-view:
Line Coverage Change: -0.46%    Branch Coverage Change: No change
Metric NameBaseline coveragePR coverageCoverage Diff
Branch Coverage 100.00% 100.00% → No change
Line Coverage 96.80% 96.34% ↓ -0.46%
↓ packages.dds.tree.src.simple-tree:
Line Coverage Change: 0.03%    Branch Coverage Change: -0.10%
Metric NameBaseline coveragePR coverageCoverage Diff
Branch Coverage 94.24% 94.14% ↓ -0.10%
Line Coverage 97.23% 97.26% ↑ 0.03%
↓ packages.dds.tree.src.shared-tree:
Line Coverage Change: -0.01%    Branch Coverage Change: No change
Metric NameBaseline coveragePR coverageCoverage Diff
Branch Coverage 91.70% 91.70% → No change
Line Coverage 97.16% 97.15% ↓ -0.01%
↑ packages.dds.tree.src.core.schema-stored:
Line Coverage Change: 0.01%    Branch Coverage Change: No change
Metric NameBaseline coveragePR coverageCoverage Diff
Branch Coverage 93.61% 93.61% → No change
Line Coverage 99.70% 99.71% ↑ 0.01%
↑ packages.dds.tree.src.feature-libraries:
Line Coverage Change: 0.02%    Branch Coverage Change: 0.03%
Metric NameBaseline coveragePR coverageCoverage Diff
Branch Coverage 94.08% 94.11% ↑ 0.03%
Line Coverage 97.79% 97.81% ↑ 0.02%
↑ packages.dds.tree.src.feature-libraries.modular-schema:
Line Coverage Change: 0.06%    Branch Coverage Change: 0.01%
Metric NameBaseline coveragePR coverageCoverage Diff
Branch Coverage 93.29% 93.30% ↑ 0.01%
Line Coverage 95.14% 95.20% ↑ 0.06%
↑ packages.dds.tree.src.feature-libraries.default-schema:
Line Coverage Change: No change    Branch Coverage Change: 0.11%
Metric NameBaseline coveragePR coverageCoverage Diff
Branch Coverage 93.16% 93.27% ↑ 0.11%
Line Coverage 98.56% 98.56% → No change

Baseline commit: abde76d
Baseline build: 310021
Happy Coding!!

Code coverage comparison check passed!!

@msfluid-bot
Copy link
Collaborator

msfluid-bot commented Nov 25, 2024

@fluid-example/bundle-size-tests: +6.31 KB
Metric NameBaseline SizeCompare SizeSize Diff
aqueduct.js 467.08 KB 467.11 KB +35 Bytes
azureClient.js 563.85 KB 563.9 KB +49 Bytes
connectionState.js 724 Bytes 724 Bytes No change
containerRuntime.js 263.27 KB 263.29 KB +14 Bytes
fluidFramework.js 428.71 KB 431.76 KB +3.05 KB
loader.js 134.18 KB 134.19 KB +14 Bytes
map.js 42.71 KB 42.71 KB +7 Bytes
matrix.js 150.15 KB 150.16 KB +7 Bytes
odspClient.js 530.45 KB 530.5 KB +49 Bytes
odspDriver.js 98.65 KB 98.67 KB +21 Bytes
odspPrefetchSnapshot.js 43.04 KB 43.05 KB +14 Bytes
sharedString.js 166.23 KB 166.24 KB +7 Bytes
sharedTree.js 419.17 KB 422.21 KB +3.04 KB
Total Size 3.38 MB 3.39 MB +6.31 KB

Baseline commit: abde76d

Generated by 🚫 dangerJS against 06eb65f

* Copy of {@link SchemaFactory} with additional alpha APIs.
*
* @privateRemarks
* Not currently exported to the public API surface as doing so produces errors in API-extractor.
Copy link
Contributor

Choose a reason for hiding this comment

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

What are the errors? Do you mean "problems with API extractor itself" or "it's not actually properly typed for export yet, and naturally API extractor complains"?

Copy link
Contributor

Choose a reason for hiding this comment

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

There are some other features that have been thrown around lately that would be implemented in a SchemaFactoryAlpha, so this will need to get lifted/shared eventually.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. I don't remember exactly what goes wrong, but agreed we'll need to sort this out. I'm planning on lifting this explicitly directly after this PR, so we'll revisit this at that point in a PR that is more scoped :)

Copy link
Contributor

🔗 No broken links found! ✅

Your attention to detail is admirable.

linkcheck output


> fluid-framework-docs-site@0.0.0 ci:check-links /home/runner/work/FluidFramework/FluidFramework/docs
> start-server-and-test "npm run serve -- --no-open" 3000 check-links

1: starting server using command "npm run serve -- --no-open"
and when url "[ 'http://127.0.0.1:3000' ]" is responding with HTTP status code 200
running tests using command "npm run check-links"


> fluid-framework-docs-site@0.0.0 serve
> docusaurus serve --no-open

[SUCCESS] Serving "build" directory at: http://localhost:3000/

> fluid-framework-docs-site@0.0.0 check-links
> linkcheck http://localhost:3000 --skip-file skipped-urls.txt

Crawling...

Stats:
  170006 links
    1595 destination URLs
    1825 URLs ignored
       0 warnings
       0 errors


@Abe27342 Abe27342 enabled auto-merge (squash) December 12, 2024 23:27
@Abe27342 Abe27342 merged commit 195b722 into microsoft:main Dec 12, 2024
30 checks passed
@Abe27342 Abe27342 deleted the rewrite-checkCompatibility branch December 12, 2024 23:31
Abe27342 added a commit that referenced this pull request Dec 19, 2024
## Description

Exposes `SchemaFactoryAlpha` and associated additional options on
`object` and `objectRecursive` to tree's alpha API surface. This lights
up the feature implemented in #23192, so I have also added a changeset
with some user-facing guidance on that feature.

---------

Co-authored-by: Abram Sanderson <absander@microsoft.com>
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: examples Changes that focus on our examples area: framework Framework is a tag for issues involving the developer framework. Eg Aqueduct base: main PRs targeted against main branch public api change Changes to a public API
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants