Repository navigation
Snapshot how the global config files load - #4879
Conversation
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]>
| 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" | ||
| """ | ||
| ); |
There was a problem hiding this comment.
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.
Docs preview (local build)Handbook preview: https://docs-v3-preview.elastic.dev/elastic/docs-builder/pull/4879/ Sample changed pages: |
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]>
| ); | ||
|
|
||
| // `path` is left out: the loader drops it when CI is set, so it reads differently on a build server |
There was a problem hiding this comment.
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) + "\"", |
There was a problem hiding this comment.
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]>
## 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]>
Adds golden snapshots of how
assembler.yml,navigation*.yml,products.yml,versions.yml,legacy-url-mappings.yml,related-learning.ymlandsearch.ymlload 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 toconfig/do not churn the snapshots. Repositories marked private are renamed to placeholders in the copies, and a scrubber inSnapshotScrubbingalso 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.ymlandnavigation_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
I broke the loaders on purpose and confirmed each new test class fails.