Skip to content

prompt_bundle: key the extracted tree on the bundle content - #467

Open
ftabba wants to merge 1 commit into
sashiko-dev:mainfrom
ftabba:pr/prompt-bundle-content-key
Open

prompt_bundle: key the extracted tree on the bundle content#467
ftabba wants to merge 1 commit into
sashiko-dev:mainfrom
ftabba:pr/prompt-bundle-content-key

Conversation

@ftabba

@ftabba ftabba commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Summary

prompt_bundle_root() names the extracted prompt tree after
third_party/prompts/REVISION, which records the upstream revision the bundle
was vendored from. Editing a vendored prompt does not move it, and
install_prompt_bundle() returns early whenever the completion marker inside
that tree exists, so a rebuild after a prompt edit keeps serving the tree
extracted before the edit. Anyone iterating on the prompts hits this until they
remember --force.

This keys the root on a sha256 over the bundle content instead, computed in
build.rs and emitted as PROMPT_BUNDLE_DIGEST. REVISION keeps its other two
jobs, the upstream pin and the content of the marker file an extracted tree
carries.

One open question

Keying on content means each distinct bundle leaves its own tree under
$XDG_DATA_HOME/sashiko/prompts/, and nothing removes the older ones. They
accumulate fastest for the workflow this fixes, someone editing a prompt and
rebuilding. I have not picked a retention policy because I am not sure which one
you would want: drop anything that is not current, keep the last N, or prune only
on an explicit init --prompts. Happy to add whichever you prefer, here or as a
follow-up.

Testing

make check-pr passes, with the exception of yamllint, which is not installed on
this machine. This change touches no YAML.

One new test recomputes the hash over PROMPT_BUNDLE_FILES and asserts it
matches the generated PROMPT_BUNDLE_DIGEST. The existing root test now asserts
the root is named by the digest. End to end, editing a vendored prompt with
REVISION untouched changes the digest, and restoring the file changes it back.

The extraction root was named by third_party/prompts/REVISION, which
records the upstream revision the bundle was copied from. A local edit
to a vendored prompt does not bump it, so an install with a persistent
HOME keeps serving the tree extracted before the edit until someone
passes --force.

build.rs now hashes the bundle itself: for each file in sorted order,
the relative path, a NUL, the length as a little-endian u64, and the
bytes. The result is emitted as PROMPT_BUNDLE_DIGEST and names the
extraction root, so any change to the bundle extracts to a new tree.
REVISION keeps its other two jobs, the upstream pin and the content of
the marker an extracted tree carries to record where it came from.

Each distinct bundle content now leaves its own tree under
sashiko/prompts, and nothing removes the older ones. A retention policy
over that directory is a separate change.

sha2 is added as a build-dependency at the version already in
dependencies, so Cargo.lock does not move.

Signed-off-by: Fuad Tabba <fuad.tabba@linux.dev>
@ftabba
ftabba force-pushed the pr/prompt-bundle-content-key branch from aba1a95 to 9228fcf Compare September 6, 2026 17:39
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.

1 participant