Repository navigation
Snapshot-test assembler navigation ahead of the domain model refactor - #4880
Conversation
Adds frozen, scrubbed copies of the shipped assembler and navigation config, stub docsets for every repository, and snapshots of the site navigation with flags on and off, private repositories skipped, top nav, mount resolution and SemVersion order. They record today's behaviour, including cases that look wrong, ahead of the domain model refactor. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
| public void FrozenBaseline_ContainsNoPrivateRepositoryOfTheShippedConfig() | ||
| { | ||
| var root = Paths.GetSolutionDirectory() ?? throw new InvalidOperationException("solution root not found"); | ||
| var shipped = AssemblyConfiguration.Deserialize(File.ReadAllText(Path.Join(root.FullName, "config", "assembler.yml"))); | ||
| var scrub = PrivateRepositoryScrubbing.For(shipped.AllPrivateRepositoryNames); | ||
| shipped.AllPrivateRepositoryNames.Should().NotBeEmpty("the check below would pass vacuously"); | ||
|
|
||
| var files = Directory | ||
| .EnumerateFiles(Path.Join(root.FullName, "tests", "Navigation.Tests", "Assembler", "Baseline")) | ||
| .Concat( | ||
| Directory.EnumerateFiles( | ||
| Path.Join(root.FullName, "tests", "Navigation.Tests", ".snapshots", "Assembler"), | ||
| "*", | ||
| SearchOption.AllDirectories | ||
| ) | ||
| ) | ||
| .ToArray(); | ||
| files.Should().NotBeEmpty(); | ||
|
|
||
| var leaking = files.Count(f => scrub(File.ReadAllText(f)) != File.ReadAllText(f)); | ||
|
|
||
| // the names are not part of the message on purpose | ||
| leaking.Should().Be(0, "a frozen copy or a verified file names a private repository"); | ||
| } |
There was a problem hiding this comment.
Severity: P3 (Low)
The leak guard can miss a single-word private repository name. It reuses the snapshot scrubber, which only matches a single-word name right before :// or right after elastic/. The frozen assembler.yml names each repository as a bare key ( name:), so if a re-frozen copy keeps an unrenamed single-word private repo there, the guard still passes. That is most likely for repos marked skip: true, which never show up in navigation as name://. To close the gap, the guard could do a whole-token match for every private name, or parse the frozen assembler.yml and assert that every private: true key starts with private-repo-.
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/4880/ |
## Why Agents migrating docs-builder tests wanted a check that a snapshot or fixture contains none of a set of values (private repository names, secrets) and fails without printing them. They built it by hand (elastic/docs-builder#4880). ## What \`SnapshotOptions.Forbid(IEnumerable<string>)\` and \`SnapshotDefaults.Forbid(IEnumerable<string>)\` (with \`ClearForbidden\`). - Checks the scrubbed value and the verified file (a secret already committed is caught); inline snapshots check the expected literal too. - The message gives line numbers only, never the values. It fails before a received file is written, so a forbidden value does not land on disk. Accepting does not get around it, and \`IgnoreDefaultScrubbers\` does not skip the default list. - The values are held internally; no property exposes them. - Public API snapshot: three additions (minor). Docs, core skill and DECISIONS.md updated. - Tests: 8, including a CsCheck property for the line numbers. Mutating the verified-file check fails 2 of them. Independent of #110; pairs well with \`Scrubbers.Values\`. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Sonnet 5.5 <[email protected]>
Adds snapshot tests that record how the assembler builds its site navigation and resolves mounts today, so #4530 can prove it changes none of it.
Affects: Internals only
Prompt summary: Lock in current assembler navigation behaviour with snapshot tests before the large domain model refactor in #4530 lands. The tests record what the code does now, including cases that look wrong, and fix nothing.
Why
The refactor in #4530 must keep behaviour identical, but nothing pins the assembled navigation, the private-repository filtering, the top nav, the cross-link resolver or the version order. A silent change there would reach the published site.
What
Frozen real-shape config
Baseline/holds copies ofassembler.yml,navigation.ymlandnavigation_preview.ymlwith private repositories renamed toprivate-repo-N, comments removed and volatile values (versions, tag manager ids) replaced. One stub docset per repository is generated from the navigation file. Tests read them through the realConfigurationFileProvider, including its--skip-private-repositoriesfiltering.Navigation snapshots
Full tree, diagnostics and top nav of the shipped shape with the navigation preview off and on, with private repositories skipped, and with an API floating section. Small hand-written layouts cover path-prefix mounts, nested tocs, hidden pages, duplicate and missing mounts, islands, site prefixes, sections and every top-nav tab shape.
Resolver and version tables
PublishEnvironmentUriResolveris recorded for the real mappings and for prefixes such asreference/apmandreference/apm-agents.SemVersionis recorded as a full pairwise matrix plus parse and operator tables.Private-name scrubbing
PrivateRepositoryScrubbingderives the names from the loaded config'sprivate: trueflag and replaces them in snapshots. A guard test fails when a frozen copy or verified file names a private repository of the shipped config, without printing the name. A similar scrubber is being added on branchsnap/config-globalfor config goldens; the two can be unified later.Out of scope: product code is untouched. Recorded oddities are not fixed here: prefix over-matching in the resolver,
SemVersionmetadata comparison that is not symmetric, a double slash for an environment prefix with a trailing slash, and an empty section whose URL ignores the site prefix.Verify
Mutation checked: breaking
PromoteSectionListingIslands, the top-nav external flag, resolver prefix matching,SemVersionmetadata comparison and the private-navigation re-indent each fails the matching tests.