Skip to content

feat: add optional unique mock roots - #400

Open
Dan Streetman (ddstreet) wants to merge 2 commits into
microsoft:mainfrom
ddstreet:mock-uniqueext
Open

Dan Streetman (ddstreet) wants to merge 2 commits into
microsoft:mainfrom
ddstreet:mock-uniqueext

Conversation

@ddstreet

Copy link
Copy Markdown
Contributor

Add the global --unique-mockroot flag and pass mock a stable --uniqueext for each runner. Limit extensions to 24 characters with component labels of up to 12 characters and a six-character random suffix. Use bld, rndr, qry, and shl for build, render, query, and shell actions. Preserve the extension across runner clones and cleanup without changing default root naming.

Propagate component labels through builds, rendering, queries, custom source preparation, and advanced mock commands. Add lifecycle and label boundary tests, update user and agent guidance, and refresh generated CLI docs and help snapshots.

Quality checks and affected unit packages pass. Help snapshots were refreshed from verified CLI output.

Add the global --unique-mockroot flag and pass mock a stable --uniqueext
for each runner. Limit extensions to 24 characters with component labels
of up to 12 characters and a six-character random suffix. Use bld, rndr,
qry, and shl for build, render, query, and shell actions. Preserve the
extension across runner clones and cleanup without changing default root
naming.

Propagate component labels through builds, rendering, queries, custom source
preparation, and advanced mock commands. Add lifecycle and label boundary
tests, update user and agent guidance, and refresh generated CLI docs and
help snapshots.

Quality checks and affected unit packages pass. Help snapshots were
refreshed from verified CLI output.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 086236b0-c4cd-4289-ace7-c82d78940883

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.

🔵 Needs a closer look

Root initialization, reuse, and cleanup across workflows need human validation with real mock beyond the command-capture tests.

No open issues 🎉

What changed in this PR

Adds opt-in mock-root isolation to azldev while preserving default root naming. Each runner receives a bounded, labeled extension that remains stable across commands, clones, and cleanup.

Changes:

  • Adds global --unique-mockroot support with action/component labels and a six-character random suffix.
  • Propagates labels through build, render, query, source-preparation, and advanced mock workflows.
  • Adds lifecycle and boundary tests, updates user and agent guidance, and refreshes CLI documentation and help snapshots.
File Description
scenario/​__snapshots__/​TestSnapshotsContainer_help_stdout_1.snap Adds flag to container help snapshot.
scenario/​__snapshots__/​TestSnapshotsContainer_--help_stdout_1.snap Adds flag to container --help snapshot.
scenario/​__snapshots__/​TestSnapshotsContainer_--bogus-flag_stderr_1.snap Updates container error-help snapshot.
scenario/​__snapshots__/​TestSnapshots_help_stdout_1.snap Adds flag to help snapshot.
scenario/​__snapshots__/​TestSnapshots_--help_with_color_stdout_1.snap Updates colored help snapshot.
scenario/​__snapshots__/​TestSnapshots_--help_stdout_1.snap Adds flag to --help snapshot.
scenario/​__snapshots__/​TestSnapshots_--bogus-flag_stderr_1.snap Updates error-help snapshot.
internal/​rpm/​mock/​uniqueroot.go Generates bounded, sanitized root extensions.
internal/​rpm/​mock/​uniqueroot_test.go Tests labels, lifecycle stability, and defaults.
internal/​rpm/​mock/​mock.go Stores, clones, and passes --uniqueext.
internal/​app/​azldev/​env.go Adds root-label context helpers.
internal/​app/​azldev/​env_test.go Tests context propagation and isolation.
internal/​app/​azldev/​core/​workdir/​workdir.go Labels component build environments.
internal/​app/​azldev/​core/​workdir/​workdir_test.go Tests component-specific root extensions.
internal/​app/​azldev/​cmds/​component/​update.go Passes component labels and worker context.
internal/​app/​azldev/​cmds/​component/​render.go Labels batch rendering and source preparation.
internal/​app/​azldev/​cmds/​component/​refreshupstreamcommit.go Passes component labels and worker context.
internal/​app/​azldev/​cmds/​component/​query.go Labels query processor roots.
internal/​app/​azldev/​cmds/​component/​preparesources.go Labels source-preparation roots.
internal/​app/​azldev/​cmds/​component/​diffsources.go Labels source-diff roots.
internal/​app/​azldev/​cmds/​component/​build.go Labels batch and individual builds.
internal/​app/​azldev/​cmds/​advanced/​mock.go Labels advanced builds and shell sessions.
internal/​app/​azldev/​cmds/​advanced/​mock_test.go Tests advanced command extension propagation.
internal/​app/​azldev/​app.go Registers and applies the global flag.
internal/​app/​azldev/​app_test.go Tests flag wiring and default behavior.
internal/​app/​azldev/​agentskill/​content/​mock.md.tmpl Explains unique shell roots and re-entry.
internal/​app/​azldev/​agentskill/​content/​build-component.md.tmpl Documents isolated builds and inspection.
internal/​app/​azldev/​agentskill/​agentskill_test.go Checks emitted unique-root guidance.
docs/​user/​reference/​cli/​azldev.md Documents the global flag.
docs/​user/​reference/​cli/​azldev_version.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_repo.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_repo_query.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_repo_compare.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_project.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_project_new.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_project_init.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_package.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_package_list.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_image.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_image_test.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_image_list.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_image_inject-files.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_image_customize.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_image_build.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_image_boot.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_docs.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_docs_markdown.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_docs_agent.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_docs_agent_show.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_docs_agent_install.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_config.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_config_generate-schema.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_config_dump.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_component.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_component_update.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_component_test.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_component_render.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_component_query.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_component_prepare-sources.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_component_metadata.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_component_list.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_component_history.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_component_diff-sources.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_component_changed.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_component_build.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_component_add.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_completion.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_completion_zsh.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_completion_powershell.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_completion_fish.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_completion_bash.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_advanced.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_advanced_wget.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_advanced_mock.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_advanced_mock_shell.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_advanced_mock_build-rpms.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_advanced_mcp.md Lists inherited flag.
docs/​user/​reference/​cli/​azldev_advanced_download-sources.md Lists inherited flag.
docs/​user/​how-to/​build-component.md Explains isolation, labels, and preserved-root inspection.

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings October 27, 2026 20:56

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.

🟡 Changes recommended

Package-free unique mock shells fail because their chroots are not initialized, and the stale MCP tool-schema snapshot causes TestMCPServerMode to fail.

2 open issues

Review effort: Balanced

Comment on lines +198 to +199
app.cmd.PersistentFlags().BoolVar(&app.uniqueMockRoot, "unique-mockroot", false,
"use unique mock roots labeled with the action, components, and a random suffix (at most 24 characters)")
packages[idx] = filepath.Base(pkg)
}

env = env.WithMockRootComponents(packages...)
Comment thread internal/rpm/mock/mock.go

args = append(args, "--configdir", filepath.Dir(r.mockConfigPath))
if r.uniqueExtension != "" {
args = append(args, "--uniqueext", r.uniqueExtension)

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.

Is leaving the unique bootstrap roots behind intentional? With bootstrap enabled, --uniqueext gives the bootstrap root a unique name too, but the normal cleanup path still uses --scrub chroot, which only removes the main build root. Previously the retained bootstrap could be reused; with a fresh extension for each runner, wouldn’t these accumulate across components and subsequent commands? Should we also clean up the unique bootstrap root while preserving shared caches, or is there another cleanup mechanism I’m missing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants