Skip to content

init overwrites project-layer state unconditionally — not a safe upgrade path #40

Description

@mmilanez

Summary

lead-protocol init (with or without -y) unconditionally regenerates every file under .agents/, including files the protocol's own three-layer state model (CORE_RULES.md / PROTOCOL_RULES.md §P3) documents as project-owned and "never overwritten by framework upgrades":

  • .agents/PROJECT_RULES.md — reverted to the generic [Project Name] placeholder template, discarding all real project identity/context.
  • .agents/JOURNAL.md — entries truncated.
  • .agents/decisions.jsonl — entries removed.
  • .agents/AGENTS_MAP.md — reset to template.
  • .agents/sessions/active_sessions.md — reset to template.

Repro

  1. Have an existing project with a populated .agents/ scaffold (real PROJECT_RULES.md content, non-trivial JOURNAL.md/decisions.jsonl).
  2. Install/upgrade the CLI to a newer version (in this case v2.1.4).
  3. Run lead-protocol init -y intending an in-place framework upgrade (there is currently no separate upgrade command).
  4. Observe git diff / git status — project-layer files are rewritten from generic templates, not merged.

Impact

In our case the working tree was clean, so the change was fully revertible via git restore plus removing the newly-created untracked files (manifest.json, two new test files). On a dirty tree, or without git as a safety net, this would silently destroy project-specific state with no warning and no diff shown first.

Suggested fix

One or both of:

  1. A dedicated lead-protocol upgrade command that only touches genuine framework-layer files (CORE_RULES.md, PROTOCOL_RULES.md, modules/, schemas/, scripts/, manifest.json), diffing against the installed CLI version and leaving project-layer files (PROJECT_RULES.md, JOURNAL.md, decisions.jsonl, AGENTS_MAP.md, sessions/active_sessions.md, local/) completely untouched.
  2. At minimum, init should refuse to run (or require an explicit --force/confirmation beyond -y) when it detects an existing .agents/PROJECT_RULES.md that doesn't match the fresh-template placeholder content — i.e., detect "this looks like a real project, not a fresh scaffold" and treat it differently from a first-time init.

Workaround used

Manually cloned the target release tag, diffed each file under .agents/ against the local copy, and hand-applied only the files that genuinely differed at the framework layer. Confirmed via lead-protocol validate (same pre-existing errors before/after) and lead-protocol status (correct Product/Kernel version reported afterward) that the result matches what a real upgrade should produce.


Filed from an agent session in mmilanez/leaddocs, companion PR: mmilanez/leaddocs#191

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions