Skip to content

[refactor] archive-mail Step 2.1 read-only invariant has no structural enforcement (sister concern from #49) #56

Description

@kiki830621

Problem

From verification of #49:
「Read-only invariant for sibling-archive scan has no structural enforcement (just code comment). Future maintainer adding mv/rm to Step 2.1 won't be caught by any guard.」
— Source: idd-verify #49 (DA new finding, INFO level)

archive-mail.md Step 2.1 (added in #49) claims:

"Read-only:never mv / rm / > against symlink target;find + head + awk only。"

But this is enforced only by:

  1. The current bash pseudocode happens to use only read operations
  2. A code comment saying "read-only"

Future maintainer editing Step 2.1 to "extend the dedup with metadata sync" or "rebuild the symlinked archive index" could add mv / >> operations, breaking the invariant silently — no test, no lint, no scan-time check.

Type

refactor (defensive guardrail)

Why this matters

archive-mail.md is a skill markdown. AI executor reads the bash blocks as instructions. If a future commit adds destructive ops to Step 2.1, AI will execute them. The read-only claim becomes a lie. Symlinked archives (which point to applications archives, project completions, sealed historical records) get unintended writes.

Priority

LOW / INFO — no current break, but invariant decay risk.

Strategy sketch

Three mitigation options:

Option A: explicit invariant marker comment

Add at top of Step 2.1 bash block:

# === INVARIANT: this block is READ-ONLY w.r.t. $symlink_dir ===
# Allowed: find / head / awk / cat / grep
# FORBIDDEN: mv / rm / cp / > / >> / tee / chmod (against $symlink_dir or its target)
# If you need to write, do it OUTSIDE this block.

Self-documenting; relies on future maintainer reading.

Option B: bash trap-based check (in real shell impl)

If archive-mail.md ever gets a real bash implementation file:

# Set readonly flag for entire scan, fail-fast on any write attempt
set -o noclobber  # or other guards

But this is hard for skill-as-AI-instructions paradigm.

Option C: pre-commit hook scanning Step 2.1 region for forbidden tokens

Pre-commit hook checks git diff plugins/.../archive-mail.md for mv|rm|cp|>|tee within the Step 2.1 block boundaries. Heavy but most reliable.

Recommendation

Option A (comment marker) — cheapest, future-proof for AI executors that read instructions literally.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions