Files
rune/scripts/merge_scaffold_conflict.py
T
Nick 0e8cc14a09
CI Pipeline / best-practices (push) Successful in 8s
CI Pipeline / documentation (push) Successful in 8s
CI Pipeline / rust-surface (push) Failing after 17s
CI Pipeline / go-surface (push) Failing after 19s
CI Pipeline / gitea-offline (push) Successful in 22s
CI Pipeline / required-checks (push) Canceled after 0s
CI Pipeline / CI Pipeline / notify-event-bridge (push) Canceled after 0s
Auto-version and Release / release (push) Canceled after 51s
CI Pipeline / type-check (push) Canceled after 1m1s
CI Pipeline / lint (push) Canceled after 1m10s
CI Pipeline / unit-tests (push) Canceled after 1m10s
deploy / deploy (push) Canceled after 56s
CI Pipeline / canary (push) Canceled after 1m16s
chore(store): close failure_auto_filer dichotomy contract BUILDER-2026-10-13T06:30:42Z-b381e6-factory-gap-faf (feat 5cadd401, phase B 8aa48134)
2026-10-13 07:37:04 +01:00

37 lines
1.3 KiB
Python

#!/usr/bin/env python3
"""Union-merge a conflicted store/scaffold/current.json during rebase.
Both sides append entities/observations/relationships to the shared
scaffold doc; the rebase conflict is two writers appending. Union by
exact-content identity: base side first (the rebased HEAD, i.e. what
other agents pushed), then the incoming commit's new items.
Rebase index stages: `git show :2:<path>` = ours = rebased HEAD,
`git show :3:<path>` = theirs = the incoming commit. Usage:
git show :2:store/scaffold/current.json > /tmp/base.json
git show :3:store/scaffold/current.json > /tmp/inc.json
python3 scripts/merge_scaffold_conflict.py /tmp/base.json /tmp/inc.json \
> store/scaffold/current.json
"""
import json
import sys
base = json.load(open(sys.argv[1]))
incoming = json.load(open(sys.argv[2]))
merged = dict(base)
for key in ("entities", "observations", "relationships"):
seen = set()
out = []
for side in (base, incoming):
for item in side.get(key, []):
ident = json.dumps(item, sort_keys=True)
if ident in seen:
continue
seen.add(ident)
out.append(item)
merged[key] = out
merged["generated_at"] = max(base.get("generated_at", ""), incoming.get("generated_at", ""))
print(json.dumps(merged, indent=2, ensure_ascii=False))