Problem
When using --git in CI, fleet-plan compares the MR branch YAML against the live Fleet API state. In environments with staged/delayed deployments, main can be days ahead of production. This means every MR that touches a team file or global config gets a fleet-plan comment showing all pending undeployed changes, not just the changes introduced by the current MR.
This trains users to ignore fleet-plan comments because the findings appear unrelated to their changes.
Example (team scope)
- MR A removes a policy from
teams/foo.yml, merges to main
- Staged release hasn't deployed yet, so the policy still exists in Fleet
- MR B adds a query to
teams/foo.yml
- fleet-plan on MR B reports:
REMOVED: policy + ADDED: query
- The policy removal is noise for MR B's author
Example (global scope)
- Prior commits removed global queries from
base.yml, merged to main
- Staged release hasn't deployed, so the queries still exist in Fleet
- MR C adds a single global query to
base.yml
- fleet-plan on MR C reports:
ADDED: query + 17 REMOVED queries + 2 config changes
- Only the 1 added query is from MR C
Root cause
filterResourceDiff() builds a source map from proposed (MR branch) YAML only. Deleted resources have no proposed entry, so sourceNames[name] returns \!ok, and the filter defaults to return true (keep). The global diff block had no filtering or subtraction at all.
Fix
Base-branch subtraction: parse the base branch YAML as a second "proposed" state, diff it against the same live Fleet state, and subtract those pre-existing deltas from the MR's diff. Only the incremental changes introduced by the current MR are reported.
Applies to both per-team and global (default.yml/base.yml) diffs.
Additional fixes discovered during implementation
resolveDefaultFile placed merged base.yml+env in /tmp, breaking path resolution for global queries
ResolveScope didn't include base.yml in changedFiles, preventing baseline extraction for global changes
buildSourceMap didn't register team source file for policies, queries, scripts, profiles (resources added via new path: refs in team YAML were filtered out)
- Global diff was skipped when both global and team files changed (team filter suppressed global block)
--verbose flag added for baseline subtraction debugging
Ref #15
Problem
When using
--gitin CI, fleet-plan compares the MR branch YAML against the live Fleet API state. In environments with staged/delayed deployments,maincan be days ahead of production. This means every MR that touches a team file or global config gets a fleet-plan comment showing all pending undeployed changes, not just the changes introduced by the current MR.This trains users to ignore fleet-plan comments because the findings appear unrelated to their changes.
Example (team scope)
teams/foo.yml, merges tomainteams/foo.ymlREMOVED: policy+ADDED: queryExample (global scope)
base.yml, merged tomainbase.ymlADDED: query+ 17REMOVEDqueries + 2 config changesRoot cause
filterResourceDiff()builds a source map from proposed (MR branch) YAML only. Deleted resources have no proposed entry, sosourceNames[name]returns\!ok, and the filter defaults toreturn true(keep). The global diff block had no filtering or subtraction at all.Fix
Base-branch subtraction: parse the base branch YAML as a second "proposed" state, diff it against the same live Fleet state, and subtract those pre-existing deltas from the MR's diff. Only the incremental changes introduced by the current MR are reported.
Applies to both per-team and global (default.yml/base.yml) diffs.
Additional fixes discovered during implementation
resolveDefaultFileplaced merged base.yml+env in/tmp, breaking path resolution for global queriesResolveScopedidn't includebase.ymlinchangedFiles, preventing baseline extraction for global changesbuildSourceMapdidn't register team source file for policies, queries, scripts, profiles (resources added via newpath:refs in team YAML were filtered out)--verboseflag added for baseline subtraction debuggingRef #15