Files
multica/server/cmd
rongchenzheng c6c3be5935 fix(autopilot): invalidate empty cache for scheduled tasks (MUL-5747) (#6410)
* fix(autopilot): invalidate empty cache for scheduled tasks

* test(autopilot): pin the wiring the empty-claim fix depends on

TestBackgroundServicesReuseRouterServices asserted that backgroundServices
returns h.TaskService / h.AutopilotService — which is the helper's entire
implementation — so it stayed green even when main() ignored the helper and
constructed its own services again. That is the exact regression it was named
for: reintroducing the duplicate-service wiring left the test passing.

Replace it with an AST guard over main.go that fails when main() calls
service.NewTaskService / service.NewAutopilotService or stops calling
backgroundServices(h), plus an anti-vacuity check that the schedule-job
registration still lives in main() so the guard cannot pass on a walk that
matched nothing.

Add a service-level test for the underlying hazard: EmptyClaimCache is
nil-safe, so a TaskService that never had EmptyClaim assigned fails silently —
the daemon wakeup still fires while the claim path's cached empty verdict
survives until the TTL expires.

Verified by mutation: reintroducing the original duplicate-service wiring
fails the guard, and refactoring the schedule-job registration out of main()
fails it too.

Co-authored-by: multica-agent <github@multica.ai>

* test(autopilot): match the router handler argument, not just the callee name

The previous guard only checked that main() called backgroundServices, so
backgroundServices(nil) satisfied it — a call that compiles, reuses none of
the router's wiring, and nil-derefs at startup.

Resolve the variable holding NewRouterWithOptions' *handler.Handler result and
require that exact ident as the argument. Reading the name off the assignment
instead of hardcoding "h" keeps a rename of that variable from silently
weakening the check, and an unrecognizable router assignment now fails loudly
rather than leaving the argument check with nothing to compare against.

Mutation-verified: backgroundServices(nil) fails, the original duplicate-service
wiring fails, moving the schedule-job registration out of main() fails, an
unresolvable router assignment fails, and renaming h to routerHandler still
passes.

Co-authored-by: multica-agent <github@multica.ai>

---------

Co-authored-by: Bohan-J <bohan@devv.ai>
Co-authored-by: multica-agent <github@multica.ai>
2026-08-05 14:34:23 +08:00
..