-
Notifications
You must be signed in to change notification settings - Fork 0
fix(cli): reconcile cannot prune stale entries without a prior lock file #113
Description
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
- Ran
groundwork initwith a stale binary → wroteagents.tomlwithnext_issue(stale) + other old entries sk syncfailed (becauseskills/next-issuedoesn't exist on GitHub) → no lock file written- Rebuilt binary from current source, ran
groundwork initagain - Reconcile added the correct
beginentry but left the stalenext_issueentry in place sk syncfailed again — still trying to fetch the staleskills/next-issuepath
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-954—read_previous_managed_aliases(empty set when no lock file)main.rs:956-975—prune_stale_managed_dependencies(only prunes previously-managed entries)main.rs:903-942—reconcile_manifest_to_doc(orchestrates prune + upsert)
Acceptance criteria
-
groundwork initcleans up stale groundwork-managed entries even without a prior lock file - External (non-groundwork) dependencies are never pruned without lock file evidence