Repository navigation
Description
Problem
FileOps::rename and FileOps::copy (pkgs/id/src/fileops.rs) archive a file they replace at the destination — the replaced content gets a blob tag <to>.archive.<unix-ts> — but the replaced file's metadata tags are neither moved to that archive nor removed. The transfer/copy then layers the source file's tags on top of whatever the destination already had:
rename(fileops.rs:262-335):archive_existing(&to, ts)archives only the blob tag (archive_existing,fileops.rs:182-194, sets a blob tag and nothing else). Thentransfer_all_tags(ns, from, to)(tags.rs:983-1009) copies each source tag ontotowithset_tagand deletes the source's tags. Nothing ever reads, moves or deletesto's pre-existing tags.copy(fileops.rs:345-390): same shape viacopy_all_tags(tags.rs:1018-1034). Its trailingstamp(&to, true)resetscreated/modifiedsingletons, but every other pre-existing destination tag survives the same way.
set_tag (tags.rs:820-850) is keyed by (subject, key, value), so tags are multi-valued per key: the same key with a different value is a separate entry, not a replacement. Consequences for a destination that is replaced:
- Keys only the replaced file had stay on the new file. E.g. the replaced file's
color=rednow describes the source's content. - Keys both files had end up with both values. E.g.
statusis bothwip(source) anddone(replaced file) after the rename. - Singleton-intended keys duplicate (rename path).
created/modifiedare maintained as singletons everywhere else (stampusesset_singleton/set_if_absent,fileops.rs:215-247), but rename never stamps, so after a rename onto an existing file the new name carries twocreatedvalues — its own and the replaced file's. - The archive is left with no metadata at all. The archived version's tags are stranded on the destination name (points 1-3), so the archive tag
<to>.archive.<ts>has zero metadata tags: the version it preserves cannot be found by the metadata that described it.
Evidence (verified this run, main 07448571)
Probe on the laptop (~/git/fleet/probe-2026-10-30-laneA2-replacemeta/, a worktree of origin/main with a probe-only test module appended to fileops.rs in the worktree; real FileOps over a MemStore blob store + a real TagStore over in-memory iroh-docs):
Setup for both tests: put a.md (content A), put b.md (content B); a.md gets status=wip, created=111 (singleton); b.md gets status=done, color=red, created=222 (singleton).
BEFORE b.md: ["color=red", "created=222", "file=b.md", "modified=1793402633", "name=b.md", "status=done"]
rename a.md -> b.md (archived_replaced = "b.md.archive.1793402633"):
AFTER-RENAME b.md: ["archive.replace=b.md.archive.1793402633", "color=red",
"created=111", "created=222", "file=b.md", "modified=1793402633",
"name=b.md", "status=done", "status=wip"]
ARCHIVE b.md.archive.1793402633 tags: []
copy a.md -> b.md (fresh store, same seed; archived_replaced = "b.md.archive.1793402633"):
AFTER-COPY b.md: ["archive.replace=b.md.archive.1793402633", "color=red",
"created=1793402633", "file=b.md", "modified=1793402633",
"name=b.md", "status=done", "status=wip"]
ARCHIVE b.md.archive.1793402633 tags: []
So after the rename, b.md (now holding content A) has two created values (111 from A, 222 from the replaced B), both status values (wip and done), and B-only color=red — while the archive tag preserving B's content has no metadata at all. Copy shows the same merge; only created escapes duplication there because copy's trailing stamp(..., reset_created=true) happens to reset that one singleton. (In this probe both files' modified values fell in the same second, so that key did not visibly duplicate; it goes through the identical transfer path as created in rename, which never stamps.)
Why it matters
Rename-onto-existing and copy-onto-existing are normal flows (the meta protocol renames with archiving, protocol.rs:572; the web UI exposes both). Metadata is how this system describes files — tag list/search, the web file list's user-visible tags, and archive.* bookkeeping all read it. After such a rename/copy, the destination's metadata is a blend of two different files' metadata, with duplicated created timestamps and contradictory values for the same key, while the archived version that metadata partly belongs to is undiscoverable by it. Nothing errors; the corruption is silent and persists in the synced tag store.
Acceptance criteria
- After
renameorcopyreplaces a file at the destination, no metadata tag that belonged only to the replaced file remains on the destination name (whether the ruling is move-to-archive-subject or delete-with-the-replace — triage pins it, consistently for both operations). - After a rename onto an existing file, the destination has exactly one
createdand onemodifiedvalue, belonging to the renamed file. - A key both files had carries only the source file's value(s) on the destination after rename/copy.
- The archive subject (
<to>.archive.<ts>), if the ruling is move-to-archive, carries the replaced file's metadata; if the ruling is delete, a test pins that the archive intentionally has none and the destination is clean either way. - Regression tests in
fileops.rs(realFileOps+TagStore): rename onto an existing file with disjoint and overlapping tag keys; copy onto an existing file likewise; rename/copy onto a fresh name behave exactly as today. - Triage pins the ruling for the replaced file's
archive.*system tags and forput-style overwrite (which intentionally keeps metadata) so this fix does not changeputsemantics.
Dedup checked this run: open+closed search for fileops rename/copy metadata — #2856 (delete misses previous-name archives) is the same module but a different operation and defect; #1612/#2462 cover archive blob-tag naming/races only; no issue covers replaced-file metadata handling in rename/copy.
Activity
dezren39 commentedon Oct 30, 2026
🤖 Agent note · filed
createdvalues, both files' values for shared keys, replaced-only keys stranded) and the archive subject keeps none; triage pins move-to-archive vs delete ruling, then routes the fix.48 remaining items
dezren39 commentedon Nov 2, 2026
🤖 Agent note · parked
dezren39 commentedon Nov 2, 2026
agent-note:v1
queue/5447-2862-archive-metadata, head 83a4884, worktree~/git/fleet/5447clean):transfer_all_tags_exceptat thearchive_existingseam per the task 4042 ruling; PR body records fileops 5 passed / tags 73 passed after a main merge.fix(id): move replaced metadata to archive on rename/copy (#2862) (#4266
dezren39 commentedon Nov 2, 2026
agent-note:v1