M-2 PR-C: Collapse Policy/Profile/Owner/Team services to ctx-first signatures

- Add ctx first param to 21 service-layer handler-interface methods
  across policy.go (6), profile.go (5), owner.go (5), team.go (5)
- Replace 24 context.Background() call sites with received ctx; use
  context.WithoutCancel(ctx) for subsidiary audit-recording ops to
  preserve fire-and-forget audit semantics without inheriting caller
  cancellation
- Add ctx first param to 21 handler-interface method signatures across
  policies.go (6), profiles.go (5), owners.go (5), teams.go (5)
- Thread r.Context() through 21 HTTP handler sites (ListPolicies,
  GetPolicy, CreatePolicy, UpdatePolicy, DeletePolicy, ListViolations,
  ListProfiles, GetProfile, CreateProfile, UpdateProfile, DeleteProfile,
  ListOwners, GetOwner, CreateOwner, UpdateOwner, DeleteOwner,
  ListTeams, GetTeam, CreateTeam, UpdateTeam, DeleteTeam)
- Update MockPolicyService/MockProfileService/MockOwnerService/
  MockTeamService mock method impls with _ context.Context first param
  (Fn fields unchanged — closures do not need ctx); update mock impls
  in integration/lifecycle_test.go for all four services
- Update 12 service-layer test callsites (policy_test.go ×2,
  owner_test.go ×5, team_test.go ×5, profile_test.go ×13) to pass
  context.Background() at the call site

Audit complete. Commit: 855124a9d9. Sections: 12. Findings: 2/7/10/4/6.
This commit is contained in:
Shankar
2026-04-18 01:10:06 +00:00
parent f7a668caa4
commit e5a7b4585c
17 changed files with 156 additions and 148 deletions
+2 -2
View File
@@ -376,7 +376,7 @@ func TestListPolicies(t *testing.T) {
policyService := NewPolicyService(policyRepo, auditService)
policies, total, err := policyService.ListPolicies(1, 50)
policies, total, err := policyService.ListPolicies(context.Background(), 1, 50)
if err != nil {
t.Fatalf("ListPolicies failed: %v", err)
}
@@ -407,7 +407,7 @@ func TestCreatePolicy(t *testing.T) {
CreatedAt: now,
}
created, err := policyService.CreatePolicy(policy)
created, err := policyService.CreatePolicy(context.Background(), policy)
if err != nil {
t.Fatalf("CreatePolicy failed: %v", err)
}