Skip to content

fix(cli): reconcile cannot prune stale entries without a prior lock file #113

@pentaxis93

Description

@pentaxis93

Problem

reconcile_manifest_to_doc only prunes dependency entries that were previously tracked in the lock file (.groundwork/installed.lock.toml). On a fresh init — or after a failed init that never wrote a lock file — stale entries from an earlier run persist in agents.toml indefinitely.

Observed behavior

  1. Ran groundwork init with a stale binary → wrote agents.toml with next_issue (stale) + other old entries
  2. sk sync failed (because skills/next-issue doesn't exist on GitHub) → no lock file written
  3. Rebuilt binary from current source, ran groundwork init again
  4. Reconcile added the correct begin entry but left the stale next_issue entry in place
  5. sk sync failed again — still trying to fetch the stale skills/next-issue path

Manual removal of the stale entry was required.

Root cause

read_previous_managed_aliases (main.rs:945) returns an empty set when no lock file exists. prune_stale_managed_dependencies (main.rs:956) only prunes entries where previously_managed.contains(k) && !desired_aliases.contains(k). With an empty previously_managed set, nothing qualifies for pruning — even entries pointing to pentaxis93/groundwork paths that are clearly managed by groundwork.

Structural gap

The pruning heuristic assumes that if an entry isn't in the lock file, it's user-owned and should not be touched. This is safe in the general case but breaks when a stale binary writes groundwork-managed entries that never make it into a lock file.

A possible distinguishing signal: entries with gh = "pentaxis93/groundwork" whose path matches skills/* are groundwork-managed by definition, regardless of lock file state. The reconcile could use repo + path pattern as an additional ownership signal.

Relevant code

  • main.rs:945-954read_previous_managed_aliases (empty set when no lock file)
  • main.rs:956-975prune_stale_managed_dependencies (only prunes previously-managed entries)
  • main.rs:903-942reconcile_manifest_to_doc (orchestrates prune + upsert)

Acceptance criteria

  • groundwork init cleans up stale groundwork-managed entries even without a prior lock file
  • External (non-groundwork) dependencies are never pruned without lock file evidence

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