Repository navigation
feat(snapshot): portable FileTree candidate with ledger lineage - #1138
Merged
Merged
Conversation
A snapshot is the complete agent context — editable files plus frozen context — together with the id/parent/root the ledger already stores. Capture it from a FileTree, a live ledger, or a finished run; score it read-only on another compatible dataset; restore it with the existing apply backup path. Algorithms still edit only the declared scope. Plugin kind remains the plugin tree, and host selection is unchanged.
Collaborator
Author
|
Self-review (Birfy) Tip SHA: 8496079
|
Birfy
enabled auto-merge (squash)
November 16, 2026 23:59
agentdescent/snapshot.py overwrote the package-level snapshot() callable imported from evidence, so `from agentdescent import snapshot` returned the module and self-improve tests raised TypeError. Rename the new module to artifact_snapshot; ArtifactSnapshot and the `snapshot` CLI stay the same.
Collaborator
Author
|
Self-review (Birfy) Tip SHA: 374017d
|
Birfy
added a commit
that referenced
this pull request
Nov 17, 2026
## Summary `#1138` made a snapshot the complete candidate, and for a text run that candidate is `rendered`. `snapshot eval` already scores that text, but `snapshot apply` materialised `files` (the strategy's internal rule store) into a temp directory and handed it to `apply_from_payload`'s tree path. A user who named a file got a directory of hash-named rule files, and an empty-rules snapshot reported a no-op instead of writing the seed prompt. `cmd_snapshot_apply` now writes `snap.render()` to a temp file when `kind == \"text\"` and passes that file to `apply_from_payload`, so the text plan, `.bak-N` backup, no-op detection, and parent creation apply. A directory `--to` is refused with an error naming FILE. Tree-kind snapshots keep the materialise path. Closes #1149. ## Tests - `tests/test_snapshot_cli.py::test_snapshot_show_export_eval_and_apply`: text fixture now pins `--to missing.txt` writes exactly `rendered`, a second apply is `noop: true`, a directory `--to` is refused, and an empty-rules snapshot writes the seed prompt. Tree assertions move to a `skill_dir` snapshot. ## Checklist - [x] Changelog fragment `changelog.d/1149-snapshot-apply-text.md` - [x] No new dependencies - [x] No Cursor Cloud Coding Sessions ## Verification at the tip Tip SHA: 8e983aa Ran: - pytest -q tests/test_snapshot_cli.py tests/test_snapshot.py tests/test_text_kind_dir_target.py - python -m tools.changelog_fragments check - the issue's offline repro now writes the rendered prompt to `prompt.txt` (exit 0, `noop: false`) Not run: - full `pytest -q` — the CI test matrix is the line - Ark real-model run — no model path changed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This is item 3 from the FlashRSI design review: a portable snapshot on the existing FileTree and ledger, not a second store and not a new algorithm×harness×benchmark layer.
A snapshot is the complete candidate (editable files plus frozen context) plus the lineage the ledger already has:
idis{artifact_id}@v{version},parentis the previous version,rootis{artifact_id}@v1. Algorithms still edit only the declared scope; evaluation and restore use the whole tree.New surface:
ArtifactSnapshot,evaluate_snapshot,evaluate_snapshot_spec,read_artifact_lineageagentdescent snapshot export|show|eval|applydocs/snapshot.md(README was not rewritten)snapshot evalscores a frozen snapshot on a destination spec's tasks and scorer. The spec'stargetis ignored; itsevolveknobs do not start a search. Kind must match. Host selection stays the existing agent/runner path on that destination spec.kind: pluginis still the plugin tree, not “run this snapshot inside Claude Code.”evolve(test_frac=…)defaults and the silentreflect=agentdefault are unchanged.This is a separate PR from the seed-consistency fix in #1137; the two do not share code.
Tests
tests/test_snapshot.py: frozen files are in the snapshot even if omitted from an editable-only state; JSON round-trip keeps lineage; lineage is read from the existing ledger (v3/v2/v1, distinct commits); readonly eval does not callevolve; dest-spec eval uses dest tasks and rejects a kind mismatch; a plugin snapshot is the plugin tree.tests/test_snapshot_cli.py:show/export/eval/applyon a snapshot file, withevolvepatched to fail if search starts.Checklist