host: a scoped pass's route and policy predicates share one moved-app set
movedApps repeated movedRoutes' scope parsing, so the scoped pass's route legs and its policy reads (ReconcileConfig.PolicyScope) could drift apart. movedApps now builds one movedAppSet, with a route predicate and a policy predicate; scoped derives both from it and movedRoutes returns its route predicate (Astra review).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+17
−12
internal/host/changeindex.go+17 −12
diff --git a/internal/host/changeindex.go b/internal/host/changeindex.go| index 696411d71..32cc3d896 100644 |
| --- a/internal/host/changeindex.go |
| +++ b/internal/host/changeindex.go |
| @@ -202,19 +202,24 @@ func indexScopes(acted, obs map[string]uint64) []string { |
| // moved. Account scopes keep nothing here: their effect on a box (an |
| // account soft-deleted) is Reconcile's, which runs whole. |
| func movedRoutes(moved []string) func(registry.Route) bool { |
| - apps := map[[2]string]bool{} |
| - for _, scope := range moved { |
| - if a, b, ok := provision.ScopeApp(scope); ok { |
| - apps[[2]string{a, b}] = true |
| - } |
| - } |
| - return func(rt registry.Route) bool { return apps[[2]string{release.RouteAccount(rt), rt.App}] } |
| + return movedApps(moved).route |
| } |
| -// movedApps is the (account, app) pairs of moved's app scopes, for the |
| -// scoped pass's policy reads (ReconcileConfig.PolicyScope). |
| -func movedApps(moved []string) map[[2]string]bool { |
| - apps := map[[2]string]bool{} |
| +// movedAppSet is the (account, app) pairs of a scoped pass's moved app |
| +// scopes: the one set both the route legs (route) and the policy reads |
| +// (policy, ReconcileConfig.PolicyScope) are restricted to, so they cannot |
| +// drift apart. |
| +type movedAppSet map[[2]string]bool |
| + |
| +func (m movedAppSet) route(rt registry.Route) bool { |
| + return m[[2]string{release.RouteAccount(rt), rt.App}] |
| +} |
| + |
| +func (m movedAppSet) policy(acct, app string) bool { return m[[2]string{acct, app}] } |
| + |
| +// movedApps is the moved app set of moved's app scopes. |
| +func movedApps(moved []string) movedAppSet { |
| + apps := movedAppSet{} |
| for _, scope := range moved { |
| if a, b, ok := provision.ScopeApp(scope); ok { |
| apps[[2]string{a, b}] = true |
| @@ -262,7 +267,7 @@ func (l *passLegs) full(ctx context.Context) { l.run(ctx, "serial pass stages", |
| // app's, which the next full pass runs. |
| func (l *passLegs) scoped(ctx context.Context, moved []string) { |
| apps := movedApps(moved) |
| - l.run(ctx, "scoped pass stages", movedRoutes(moved), func(acct, app string) bool { return apps[[2]string{acct, app}] }) |
| + l.run(ctx, "scoped pass stages", apps.route, apps.policy) |
| } |
| // run is one pass set; keep nil is the unrestricted full pass, and |