Skip to content

Snapshot how the global config files load - #4879

Merged
Mpdreamz merged 3 commits into
mainfrom
snap/config-global
Nov 17, 2026
Merged

Mpdreamz merged 3 commits into
mainfrom
snap/config-global

Conversation

@Mpdreamz

Copy link
Copy Markdown
Member

Adds golden snapshots of how assembler.yml, navigation*.yml, products.yml, versions.yml, legacy-url-mappings.yml, related-learning.yml and search.yml load today, so the domain-model refactor in #4530 can prove it changes no behaviour.

Affects: Configuration, Navigation

Prompt summary: Lock in the current behaviour of configuration loading with snapshot tests ahead of a large domain-model refactor. Record what the loaders do today, including odd results, and change no product code.

Why

The refactor in #4530 must not change behaviour, but nothing pins what the global config loaders produce. A silent change to a default, a dropped property or a different error message would pass today's tests.

What

Frozen baseline

The shipped config files are copied once into Golden/Baseline, so later edits to config/ do not churn the snapshots. Repositories marked private are renamed to placeholders in the copies, and a scrubber in SnapshotScrubbing also rewrites any name the loaded config marks private. The scrubber is per test and derives its names from the config.

Full model snapshots

A reflection dump writes every property of every loaded record, so an added, removed or renamed property changes the snapshot. Each file loads through the same provider the CLI uses. Navigation also snapshots the tree and the private-repository filtering of navigation.yml and navigation_preview.yml.

Tables of edge inputs

Each file has cases for empty files, unknown keys, duplicates, wrong types, blank values, bad URIs and bad enum values. Each case records the model or the exception chain, and for navigation the diagnostics, in an inline snapshot. Several results look like bugs; the snapshots record them unchanged.

Verify

dotnet test --project tests/Elastic.Documentation.Configuration.Tests
mise run test
mise run snap:orphans

I broke the loaders on purpose and confirmed each new test class fails.

The loaded model of assembler, navigation, products, versions, legacy URL mapping, related-learning and search config is now snapshotted from frozen copies of the shipped files, with tables of malformed inputs. The golden tests lock behaviour ahead of the domain-model refactor in #4530.

Repositories marked private are renamed to placeholders in the frozen copies, and a scrubber derived from the loaded config keeps their names out of every snapshot.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@Mpdreamz
Mpdreamz requested a review from a team as a code owner November 16, 2026 21:03
@Mpdreamz
Mpdreamz requested a review from akira28 November 16, 2026 21:03
@Mpdreamz Mpdreamz added the chore label Nov 16, 2026
Comment on lines +264 to +280
public void LinkOrderIsKept_Loaded_Outcome() =>
Load("links:\n z:\n title: Z\n url: https://example.com/z\n a:\n title: A\n url: https://example.com/a\n")
.Should()
.MatchInlineSnapshot(
"""
model <RelatedLearningConfiguration>:
Links:
a <RelatedLearningLink>:
Id: "a"
Title: "A"
Url: "https://example.com/a"
z <RelatedLearningLink>:
Id: "z"
Title: "Z"
Url: "https://example.com/z"
"""
);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Severity: P3 (Low)

LinkOrderIsKept_Loaded_Outcome can't check what its name says. Links is a FrozenDictionary, and ModelDump sorts any hashed or frozen map by key before writing it. So the snapshot shows a before z, the reverse of the input, and it would look the same whatever order the loader kept. Readers will think link order is locked in, but #4530 could change it without this test failing. Either rename the test to say the keys are written sorted, or check the order of Links.Keys directly if order matters.

Generated by Libra. Specialist: libra-complexity. React with 👍 or 👎 to give feedback on this comment.

@github-actions

Copy link
Copy Markdown
Contributor

The loader drops a repository's path when CI is set, so the snapshot that set one read differently in CI. That test no longer sets a path. The model dump also no longer doubles backslashes, so the path scrubber matches Windows paths.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Comment on lines +688 to +690
);

// `path` is left out: the loader drops it when CI is set, so it reads differently on a build server

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Severity: P3 (Low)

Please retain a separate case for a configured repository path rather than dropping that input entirely. Neither the frozen baseline nor the remaining assembler cases supplies this key, so a refactor that always discards local path overrides—or stops clearing them in CI—will now pass the golden tests. An environment-aware assertion can cover the existing local/CI distinction without making this snapshot machine-dependent.

Generated by Libra. React with 👍 or 👎 to give feedback on this comment.

private static string Scalar(object? value) => value switch
{
null => "null",
string s => "\"" + s.Replace("\"", "\\\"", StringComparison.Ordinal).Replace("\n", "\\n", StringComparison.Ordinal) + "\"",

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Severity: P3 (Low)

Removing backslash escaping makes distinct model strings produce identical snapshots: a literal backslash followed by n and an actual newline are both emitted as \n. That prevents the golden comparison from detecting an escaping/unescaping regression for those values. Preserve unambiguous string escaping and normalize filesystem paths separately if needed for cross-platform scrubbing.

Generated by Libra. React with 👍 or 👎 to give feedback on this comment.

The CI lint job runs an older curb than the local tool and formats `typeof(X<,>)` differently. The dump now matches generic types by name instead.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
@Mpdreamz
Mpdreamz merged commit 7cad187 into main Nov 17, 2026
44 checks passed
@Mpdreamz
Mpdreamz deleted the snap/config-global branch November 17, 2026 09:47
Mpdreamz added a commit to nullean/snapshots that referenced this pull request Nov 17, 2026
## Why
Agents migrating docs-builder tests wrote reflection-based dumpers
(ModelDump in elastic/docs-builder#4879 and another in #4877) so that a
property added to a record shows up as a diff. \`MatchJsonSnapshot\`
needs System.Text.Json to be able to write the type: a cycle or a
\`System.Type\` throws, and a set comes out in hash order.

## What
A new package, \`Nullean.Snapshots.Objects\`:
\`Should().MatchObjectSnapshot()\` and \`ObjectSnapshot.Dump\`. Public
properties and fields are dumped as YAML and compared through the YAML
format, so a new property is an added path.

- Cycles are \`"<cycle to $.Path>"\`; \`HashSet<T>\` is sorted by
rendering; a throwing property is \`"<throws Type>"\` with no message
(it differs per OS).
- \`ObjectDumpOptions\`: \`IgnoreMember\`, \`IgnoreType<T>\`,
\`Render<T>\`, \`Include<T>\`, \`SortAsSet\`, \`MaxDepth\`,
\`MaxItems\`.
- Public API snapshot for the package, README, core skill for the
package, docs page, DECISIONS.md section, solution and test project.

## AOT: checked, not assumed
Reflection is not automatically out of native AOT. I published a native
AOT app (osx-arm64, .NET 11 SDK) dumping a nested graph and compared it
with the JIT run:

- Without help, the AOT dump lost the members of every type reached only
through another object (\`Inner: {}\`), and a \`HashSet<Uri>\` came out
unsorted, because trimming removes \`ISet<>\` from \`GetInterfaces()\`.
- So sets are found by type, never by interface (same text in both
runs); \`Include<T>()\` carries \`[DynamicallyAccessedMembers]\` so the
trimmer keeps a type; and under AOT a member-less type that was not
included throws with a message naming the fix, instead of dumping
\`{}\`.
- With every type included, the AOT output was identical to the JIT's.
The package keeps \`IsAotCompatible\` with the analyzers on; the calls
are \`[RequiresUnreferencedCode]\`.
- Not verified: other RIDs, and trimmed (non-AOT) publishes.

Tests: 15, including CsCheck properties (set order is independent of
insertion order; any string round-trips through the YAML parser).
Mutating set sorting fails 2, mutating cycle detection fails 1.

Independent of #110 to #113. #113 can link here once this merges.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Sonnet 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant