Walden§ docs

Parallel Branches

Walden keeps its state in the repository: the documents with their approval seals, and one evidence ledger per feature. When several features are in flight on parallel branches, as in a team or with a group of coding agents, every merge brings two versions of that state together. This page says what a merge does to it, how to resolve the conflicts it leaves under .walden/, and how to avoid most of them. Every command block was run with v0.15.2.

What a merge does

What you seeWhy
The evidence of many features reads stale-codeThe code identity covers the whole tree. A merge that brings in code makes every record older than the tree, also for features the merge did not touch.
A ledger is in conflictBoth branches ran walden verify on the same feature, and each run rewrote the same records.
The front matter of a document is in conflictBoth branches changed the state of one approved document: one approved it again, and the other completed its tasks or approved it again too.

None of these means that work was lost. Proving again on the merged tree settles the first. The other two are conflicts in text the CLI owns, and the recipes below resolve them without typing a value by hand.

After every merge

git diff --name-only --diff-filter=U   # the paths git left in conflict
walden validate --all                  # every document, and every ledger can be read

Since v0.15.2 walden validate fails on a ledger that cannot be read, such as one left with conflict markers. An earlier release answers VALID on it, so look at the output of the first command too.

Then run walden status <feature> for each feature whose documents the merge touched, and prove again as the last recipe says.

A ledger in conflict

Do not merge a ledger by hand. Take one side whole, finish the merge, and let walden verify rebuild the rest:

git diff --name-only --diff-filter=U -- .walden/evidence/ | while read -r ledger; do
  git checkout --theirs -- "$ledger" && git add "$ledger"
done

Either side works; --ours keeps the ledger of the branch you are on. After a merge that brought in code, the records of both sides are stale anyway. walden verify proves again every completed task that is not verified, including a task whose record was only on the side you dropped: it reads unrecorded until then.

Delivery proofs need care. A ledger that holds an attestation says "schema_version": "v1alpha3". When only one side of the conflict holds attestations, take that side:

ledger=.walden/evidence/<feature>.json
git show ":2:$ledger" | grep -c '"attestation"'   # ours
git show ":3:$ledger" | grep -c '"attestation"'   # theirs

A delivery task whose attestation was on the dropped side is proven again by walden verify and attested at the merge commit. If the delivered text has moved on since, that proof fails, which is what the attestation was there to avoid: take the ledger of the other side instead.

Front matter in conflict

Open the document first. When the conflict markers are all above the second --- line, the conflict is in lines the CLI writes: approval time, last modification, fingerprints. Keep one side of the conflicting block and the changes both sides made to the body:

tmp=$(mktemp -d)
for doc in $(git diff --name-only --diff-filter=U -- .walden/specs/); do
  git show ":1:$doc" > "$tmp/base"
  git show ":2:$doc" > "$tmp/ours"
  git show ":3:$doc" > "$tmp/theirs"
  git merge-file --ours -p "$tmp/ours" "$tmp/base" "$tmp/theirs" > "$doc" && git add "$doc"
done
rm -r "$tmp"
walden status <feature>

git checkout --ours is not the same: it takes the whole file and drops what the other branch changed in the body. When the body is in conflict too, merge the body by hand before anything else, because the loop keeps your side of every conflicting block. Then keep one side of the front matter block whole, without mixing lines of the two sides.

walden status <feature> says what is left to do:

Avoid most of it

Prove again after the merge

walden verify takes one feature per run:

for dir in .walden/specs/*/; do
  walden verify "$(basename "$dir")" || break
done
walden release check

Commit the refreshed ledgers as your project's policy says. CI Integration shows where the persisting run and the report-only run belong in a pipeline.

What these recipes do not do