Skip to content

fix: implicit parents hiding explicit paths - #332

Open
lczyk wants to merge 1 commit into
canonical:mainfrom
lczyk:fix/implicit-parent-until
Open

lczyk wants to merge 1 commit into
canonical:mainfrom
lczyk:fix/implicit-parent-until

Conversation

@lczyk

@lczyk lczyk commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor
  • Have you signed the CLA?

did some formal verification (fizzbee. my specs are here and here btw) of the cut path and found 7 minor bugs:

# slices/test-package.yaml
package: test-package
slices:
  myslice:
    contents:
      /dir/: {make: true, until: mutate}
      /dir/file: {until: mutate}
$ chisel cut --release ./ --arch amd64 --root $rootfs test-package_myslice
Extracting files from package "test-package"...
$ test -d $rootfs/dir && echo still there
still there

/dir/file is removed after mutate, /dir/ is not.

repro using chisel-proxy:

$ alias chisel-proxy='go run github.com/lczyk/chisel-proxy/cmd/chisel-proxy@v0.3.0'
$ mkdir -p test-package/dir
$ echo data > test-package/dir/file
$ chisel-proxy cut --arch amd64 ./test-package ./test-package.yaml \
    -- --root ./rootfs test-package_myslice
Extracting files from package "test-package"...
$ test -d ./rootfs/dir && echo still there
still there

the same happens for a generated directory with a generated child (/gen/: {make: true, until: mutate} + /gen/text: {text: data1, until: mutate}), but there it depends on map iteration order and the directory survives roughly half of the runs.

fix

addKnownPath registers the parents of a known path with empty data and never replaces them. extracting /dir/file registers /dir/ as an implicit parent, and when the explicit /dir/ entry is created afterwards its until: mutate is dropped.

implicit parents are now marked as such and an explicit entry replaces them. an explicit entry still wins over a later explicit one, as before.

addKnownPath registered the parents of a known path with empty data and
never replaced them, so a directory first seen as the parent of an
extracted file lost the "until: mutate" of its own explicit entry when
that entry was processed later. Generated content is created after the
extraction and iterates a map, so this happened every time for a made
directory with an extracted child, and at random for a generated
directory with a generated child.

Implicit parents are now marked as such and an explicit entry replaces
them.
@lczyk lczyk changed the title fix: explicit path entries hidden by implicit parent directories fix: implicit parents hiding explicit paths Oct 10, 2026
@lczyk lczyk changed the title fix: implicit parents hiding explicit paths fix: implicit mutate parents hiding explicit paths Oct 10, 2026
@lczyk lczyk changed the title fix: implicit mutate parents hiding explicit paths fix: implicit parents hiding explicit paths Oct 10, 2026
@lczyk lczyk added the Bug An undesired feature ;-) label Oct 10, 2026
@lczyk
lczyk requested review from upils and a lite review from Copilot October 10, 2026 11:31

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 Approval recommended

The fix is covered by regression tests and has no unresolved review issues.

0 open findings

What changed in this PR

Fixes implicit parent paths so explicit metadata, including until: mutate, is preserved.

Changes:

  • Tracks implicit parent paths.
  • Lets explicit entries replace implicit parents.
  • Adds regression tests.
File Description
internal/​slicer/​slicer.go Updates path registration logic.
internal/​slicer/​slicer_test.go Adds regression coverage.

🧠 Review effort: Lite


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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

Labels

Bug An undesired feature ;-)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants