Skip to content

id(fileops): archive tag namespace is not reserved — a user file named <name>.archive.<digits> is misclassified as an archive, hard-deleted by delete(<name>), and a put to an existing archive's name silently overwrites it #4720

Closed

Description

@dezren39

Summary

FileOps mints archive tags in a reserved-looking namespace — <name>.archive.<unix-ts> (claim_archive_name, pkgs/id/src/fileops.rs:166) — but nothing reserves that namespace against user-created files. validate_name (fileops.rs:221-242) rejects empty, rooted, drive-prefixed, and ./.. names, but accepts archive-shaped names, and every consumer of the namespace then treats a user file with that shape as an archive:

  1. Misclassified in the web file list. classify_tag (pkgs/id/src/web/routes.rs:153-184) returns (FileKind::Archive, Some(ts)) for any name ending in .archive.<digits> — a user file named report.archive.1700000000 renders as an archive of report, sorted/grouped with archives, instead of as the primary file its owner created.
  2. Hard-deleted by deleting a different file. FileOps::delete (fileops.rs:496+) collects the base name's archives by a prefix scan ({name}.archive. + all-digit suffix, fileops.rs:523-545) and via archive.* metadata references filtered by is_archive_tag_name (fileops.rs:155-160), then deletes those tags and their metadata. Deleting report therefore hard-deletes the independent user file report.archive.1700000000 and its metadata with it.
  3. Archives can be silently overwritten. put (fileops.rs:307-318) validates the name, then unconditionally tags().set(name, hash). A put (directly, or as a rename/copy target — validate_target uses the same validate_name) to the exact name of an existing archive replaces the archived version's hash, destroying the one copy the archive mechanism exists to preserve, with no archive-of-the-archive and no error.

The non-numeric lookalike case is already defended and pinned by a test (delete_only_removes_numeric_archive_suffixes, protocol.rs: a.archive.notes survives delete("a") because the suffix is not digits). The numeric-suffix case — the only shape that actually collides — has no equivalent guard, because the guard lives in the readers (classification/delete) while the writer (validate_name) never got the reservation.

Evidence (verified this run, origin/main b882c9d5e)

Laptop probe ~/git/fleet/probe-2026-11-02-laneB-archivename/ — verbatim extracts of validate_name and is_archive_tag_name from fileops.rs (blob md5 721b667fe3bb56a6198e49328ea7b3b7), classify_tag/parse_iso_timestamp from web/routes.rs, and delete()'s prefix-scan collection logic over an in-memory tag list. Results:

  • PROBE1 validate_name("report.archive.1700000000") == Ok (put accepts it): PASS (controls: "../x" and " " are rejected)
  • PROBE2 classify_tag("report.archive.1700000000") == (Archive, Some(1700000000)): PASS (control: "a.archive.notes" classifies Primary)
  • PROBE3 delete("report") collects user file report.archive.1700000000 for deletion: PASS (controls: report.archive.notes and report2.archive.5 are spared)
  • PROBE4 is_archive_tag_name("report.archive.1700000000") == true: PASS

Why it matters

Archives are the only recovery copy when a file is replaced or renamed over (archive_existing, #1612/#2462 hardened their claiming precisely so a replaced version is never lost). A namespace collision breaks that guarantee in both directions: user data that merely looks like an archive is destroyed by an unrelated delete, and a genuine archive can be clobbered by an ordinary put — silently in both cases, since each operation reports success. Any surface that can create files (meta protocol Put/Rename/Copy, web routes, REPL — all funnel through FileOps) can trigger it, accidentally (a user naming an export data.archive.2024… the shape only needs trailing digits, e.g. notes.archive.1) or deliberately.

Acceptance criteria

  • Creating a file whose name matches the archive shape (<something>.archive.<all-digits>) is refused with a clear error at the FileOps layer (validate_name / validate_target), so put, rename, and copy all inherit it; the error is distinguishable like the existing InvalidName/EmptyName variants.
  • Regression test mirroring delete_only_removes_numeric_archive_suffixes from the writer side: put/rename/copy to an archive-shaped name fails, and a pre-existing archive tag's hash is unchanged after such an attempt.
  • The chosen spelling rule matches the readers exactly (unsigned decimal digits only — no + sign, per id(web): classify_tag timestamp parsers accept non-canonical spellings — non-padded, '+'-signed and over-wide components classify as Auto/Archive with the canonical instant #4329's note in classify_tag); non-numeric lookalikes such as a.archive.notes remain valid user files and still survive delete("a").
  • If reserving the namespace is judged too breaking, the alternative is implemented instead and this issue updated: archives move to a namespace users cannot mint (or delete/classify stop inferring archives from names alone and use the archive.* metadata references as the sole source) — with the same writer/reader agreement tests.

Related

Activity

  1. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    priority/normalOrdinary priority (the default)
    source/creatorFiled by the new-issue-creator job
    task/triageQueue packet kind: verify, reproduce, and route this item
    app/idPackage/app: id (pkgs/ or apps/ in this repo)
    effort/sSmall: expected under 2 hours of work
    on Nov 3, 2026
  2. dezren39 commented on Nov 3, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · filed

    • Agent: new-issue-creator job (new-issue-creator-code-b, Lane B)
    • Session / ID: cron new-issue-creator-code-b run 2026-11-02 19:50 CST (2026-11-03T01:56Z)
    • Found via: filed this run
    • Task: Filed after verifying on the laptop that FileOps' archive namespace (<name>.archive.<digits>) is not reserved: validate_name accepts archive-shaped user names, classify_tag renders such a file as an archive, delete of the base name hard-deletes it, and put to an existing archive's exact name overwrites the archived version. Verbatim-extract probe (fileops.rs blob md5 721b667f @ origin/main b882c9d) passed all 4 probes + 3 controls.
    • Expectation: effort/s — triage confirms on current main and routes the fix (reserve the shape in validate_name/validate_target, or move archives out of the user-mintable namespace).
    • Links: probe ~/git/fleet/probe-2026-11-02-laneB-archivename/ (laptop); triage packet enqueued to repo-health-code-pilot this run.
  3. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed on Nov 3, 2026
  4. dezren39 commented on Nov 3, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · picked up

  5. 29 remaining items

  6. added
    status/parkedDeliberately paused with a recorded resume condition
    and removed on Nov 4, 2026
  7. added
    work/assignedQueue worker lifecycle state
    queue/claimedQueue worker lifecycle state
    and removed
    status/parkedDeliberately paused with a recorded resume condition
    queue/parkedQueue task is parked (waiting on CI, time, or an event)
    on Nov 4, 2026
  8. dezren39 commented on Nov 4, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    state: claimed
    queue: repo-health-code-pilot
    task: 8443 (small_fix, worker repo-worker-code, lane code-f, direct execution lane)
    by: repo-queue-worker-shift-f
    at: 2026-11-04T05:05Z

    Picked up task 8443 and revalidated fresh: PR #4741 (branch queue/6711-4720-archive-name-reservation, task 6711) is the canonical fix for issue #4720 and is still OPEN, mergeable_state clean, Codex review completed with no findings. Task 6711 is no longer in an active queue state, so instead of parking again I reviewed PR #4741 against the acceptance criteria (validate_name reservation via is_archive_tag_name, distinct ReservedArchiveName error, put/rename/copy regression test with archive hash unchanged, non-numeric lookalikes still valid) — all met, with test evidence on the PR. Merging PR #4741 now; task 8443 will complete as fixed_merged via the canonical PR.

  9. dezren39 commented on Nov 4, 2026

    @dezren39
    MemberAuthor

    agent-note:v1
    state: done
    queue: repo-health-code-pilot
    task: 8443 (small_fix, worker repo-worker-code, lane code-f, direct execution lane)
    by: repo-queue-worker-shift-f
    at: 2026-11-04T05:03Z

    Done: PR #4741 merged (merge commit ac14972) and issue #4720 closed by the merge. The canonical PR from task 6711 implements the validate_name archive-namespace reservation exactly per the acceptance criteria; Codex review had no findings and the PR carried passing targeted test evidence (three pkgs/id test filters + cargo check -p id --features web --lib). Task 8443 completes as fixed_merged via PR #4741 — no competing PR was built.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

app/idPackage/app: id (pkgs/ or apps/ in this repo)effort/sSmall: expected under 2 hours of workkind/bugSomething isn't working (prefixed form of the classic bug label)priority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobsource/design-architectFiled by the repo design architect jobstatus/triagedTriaged and routed (see agent note)task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions