Migrate template alias nullability annotations to macros.

absl::Nonnull -> absl_nonnull, absl::Nullable -> absl_nullable, and absl::NullabilityUnknown -> absl_nullability_unknown. The new macros are positioned as a qualifier on the affected type, similar to const, rather than as a templated type wrapping the affected type.

See go/cxx-nullability-syntax-change and go/nullability-annotation-alias-to-macro-migration for more details.

Tested:
    Local presubmit tests passed.
PiperOrigin-RevId: 742936243
Change-Id: I2aeb14bd4dc4191ef03355e916320a29f42a85b2
diff --git a/action_context.cc b/action_context.cc
index e3c757e..1c9a6d9 100644
--- a/action_context.cc
+++ b/action_context.cc
@@ -167,7 +167,7 @@
 
 static void AssignConditions(ActionStateChange& change,
                              const Condition::MatchList& matches) {
-  for (absl::Nonnull<const safepower_agent_proto::Condition*> condition :
+  for (const safepower_agent_proto::Condition*  condition :
        matches) {
     *change.add_matching_conditions() = *condition;
   }
@@ -367,7 +367,7 @@
   return absl::OkStatus();
 }
 
-absl::StatusOr<absl::Nonnull<std::unique_ptr<ActionContext>>>
+absl::StatusOr< std::unique_ptr<ActionContext>>
 ActionContextManager::ReloadActionContext(
     std::string action_id,
     safepower_agent_persistence_proto::SavedAction saved_action) {
@@ -431,7 +431,7 @@
                          next_action_id_++);
 }
 
-absl::StatusOr<absl::Nonnull<ActionContext*>> ActionContextManager::StartAction(
+absl::StatusOr<ActionContext* > ActionContextManager::StartAction(
     safepower_agent_proto::StartActionRequest request) {
   absl::MutexLock lock(&actions_mutex_);
   ASSIGN_OR_RETURN(ActionContext::Action action_impl,
@@ -467,7 +467,7 @@
   found_action_impl->second = std::move(action_impl);
 }
 
-absl::Nullable<ActionContext*> ActionContextManager::GetActionContext(
+ActionContext*  ActionContextManager::GetActionContext(
     absl::string_view action_id) {
   absl::MutexLock lock(&actions_mutex_);
   auto found_action_context = running_actions_.find(action_id);
diff --git a/action_context.h b/action_context.h
index b4f43b4..5c23ef3 100644
--- a/action_context.h
+++ b/action_context.h
@@ -47,21 +47,21 @@
 
   absl::Status LoadSavedActions();
 
-  absl::StatusOr<absl::Nonnull<ActionContext*>> StartAction(
+  absl::StatusOr<ActionContext* > StartAction(
       safepower_agent_proto::StartActionRequest request)
       ABSL_LOCKS_EXCLUDED(actions_mutex_);
   void FinishAction(const safepower_agent_proto::Action& action,
                     Action action_impl) ABSL_LOCKS_EXCLUDED(actions_mutex_);
 
-  absl::Nullable<ActionContext*> GetActionContext(absl::string_view action_id)
+  ActionContext*  GetActionContext(absl::string_view action_id)
       ABSL_LOCKS_EXCLUDED(actions_mutex_);
 
   void GetSupportedActions(
       safepower_agent_proto::GetSupportedActionsResponse& response) const
       ABSL_LOCKS_EXCLUDED(actions_mutex_);
 
-  const absl::Nonnull<
-      std::shared_ptr<StateUpdater<safepower_agent_proto::SystemState>>>&
+  const 
+  std::shared_ptr<StateUpdater<safepower_agent_proto::SystemState>>&
   system_state_updater() const {
     return state_updater_;
   }
@@ -75,7 +75,7 @@
       const safepower_agent_proto::Action& action)
       ABSL_EXCLUSIVE_LOCKS_REQUIRED(actions_mutex_);
 
-  absl::StatusOr<absl::Nonnull<std::unique_ptr<ActionContext>>>
+  absl::StatusOr< std::unique_ptr<ActionContext>>
   ReloadActionContext(
       std::string action_id,
       safepower_agent_persistence_proto::SavedAction saved_action)
@@ -125,8 +125,8 @@
     return request_;
   }
 
-  absl::Nonnull<
-      std::shared_ptr<StateUpdater<safepower_agent_proto::ActionStateLog>>>
+  
+  std::shared_ptr<StateUpdater<safepower_agent_proto::ActionStateLog>>
   action_state_updater() const {
     return action_state_updater_;
   }
@@ -177,8 +177,8 @@
   Action action_impl_ ABSL_GUARDED_BY(mutex_);
   std::optional<Condition> precondition_;
   std::optional<Condition> validation_;
-  absl::Nonnull<
-      std::shared_ptr<StateUpdater<safepower_agent_proto::ActionStateLog>>>
+  
+  std::shared_ptr<StateUpdater<safepower_agent_proto::ActionStateLog>>
       action_state_updater_;
   static safepower_agent_proto::ActionStateLog NewInitialState();
 
diff --git a/condition.cc b/condition.cc
index 8a4e29b..18f8068 100644
--- a/condition.cc
+++ b/condition.cc
@@ -268,7 +268,7 @@
 
 absl::Status Condition::WaitForMatch(
     absl::string_view unique_id,
-    absl::Nonnull<std::shared_ptr<StateUpdater<SystemState>>> state_updater,
+     std::shared_ptr<StateUpdater<SystemState>> state_updater,
     absl::AnyInvocable<void(absl::Status, Condition::MatchList) &&> callback) {
   complete_job_name_ = absl::StrCat(unique_id, ".complete");
   state_updater_ = std::move(state_updater);
diff --git a/condition.h b/condition.h
index 7177ced..e1bee77 100644
--- a/condition.h
+++ b/condition.h
@@ -36,12 +36,12 @@
   ~Condition();
 
   using MatchList =
-      std::vector<absl::Nonnull<const safepower_agent_proto::Condition*>>;
+      std::vector<const safepower_agent_proto::Condition* >;
 
   absl::Status WaitForMatch(
       absl::string_view unique_id,
-      absl::Nonnull<
-          std::shared_ptr<StateUpdater<safepower_agent_proto::SystemState>>>
+      
+      std::shared_ptr<StateUpdater<safepower_agent_proto::SystemState>>
           state_updater,
       absl::AnyInvocable<void(absl::Status, MatchList matches) &&> callback);
   std::tuple<absl::Status, MatchList> CheckState(
diff --git a/daemon_context.cc b/daemon_context.cc
index 6c5ff77..3f71ac7 100644
--- a/daemon_context.cc
+++ b/daemon_context.cc
@@ -6,7 +6,7 @@
 
 namespace safepower_agent {
 
-absl::Nullable<DaemonContext*> DaemonContext::instance_ = nullptr;
+DaemonContext*  DaemonContext::instance_ = nullptr;
 
 DaemonContext::DaemonContext() {
   if (instance_ != nullptr) {
diff --git a/daemon_context.h b/daemon_context.h
index 55e71d3..9c89ca0 100644
--- a/daemon_context.h
+++ b/daemon_context.h
@@ -25,7 +25,7 @@
   virtual PersistentStorageManager& persistent_storage_manager() = 0;
 
  private:
-  static absl::Nullable<DaemonContext*> instance_;
+  static DaemonContext*  instance_;
 };
 }  // namespace safepower_agent
 
diff --git a/safepower_agent.cc b/safepower_agent.cc
index 8acf662..b76150e 100644
--- a/safepower_agent.cc
+++ b/safepower_agent.cc
@@ -24,7 +24,7 @@
     const safepower_agent_proto::StartActionRequest* request,
     safepower_agent_proto::StartActionResponse* response) {
   grpc::ServerUnaryReactor* reactor = context->DefaultReactor();
-  absl::StatusOr<absl::Nonnull<ActionContext*>> action_context =
+  absl::StatusOr<ActionContext* > action_context =
       action_context_manager_->StartAction(*request);
   if (!action_context.ok()) {
     LOG(ERROR) << "Failed to start action: " << action_context.status();
@@ -42,7 +42,7 @@
     grpc::CallbackServerContext* /*context*/,
     const safepower_agent_proto::MonitorActionRequest* request) {
   auto reactor = std::make_unique<StateChangeWriteReactor<ActionStateLog>>();
-  absl::Nullable<ActionContext*> action_context =
+  ActionContext*  action_context =
       action_context_manager_->GetActionContext(request->response_id());
   if (action_context == nullptr) {
     LOG(ERROR) << "Action " << request->response_id() << " not found";
diff --git a/safepower_agent.h b/safepower_agent.h
index ee50944..1956dd0 100644
--- a/safepower_agent.h
+++ b/safepower_agent.h
@@ -17,11 +17,10 @@
     : public safepower_agent_proto::SafepowerLocalAgent::CallbackService {
  public:
   explicit SafepowerLocalAgentImpl(
-      const absl::Nonnull<
-          std::shared_ptr<StateUpdater<safepower_agent_proto::SystemState>>>&
+      const 
+      std::shared_ptr<StateUpdater<safepower_agent_proto::SystemState>>&
           system_state_updater,
-      absl::Nonnull<std::unique_ptr<ActionContextManager>>
-          action_context_manager)
+       std::unique_ptr<ActionContextManager> action_context_manager)
       : system_state_updater_(system_state_updater),
         action_context_manager_(std::move(action_context_manager)) {}
 
@@ -45,10 +44,9 @@
       safepower_agent_proto::GetSupportedActionsResponse* response) override;
 
  private:
-  absl::Nonnull<
-      std::shared_ptr<StateUpdater<safepower_agent_proto::SystemState>>>
+   std::shared_ptr<StateUpdater<safepower_agent_proto::SystemState>>
       system_state_updater_;
-  absl::Nonnull<std::unique_ptr<ActionContextManager>> action_context_manager_;
+   std::unique_ptr<ActionContextManager> action_context_manager_;
 };
 
 }  // namespace safepower_agent
diff --git a/state_change_reactor.h b/state_change_reactor.h
index feb211d..636cb73 100644
--- a/state_change_reactor.h
+++ b/state_change_reactor.h
@@ -66,16 +66,16 @@
     StartWrite(&state_queue_.front(), grpc::WriteOptions());
   }
 
-  void Connect(
-      const absl::Nonnull<std::shared_ptr<StateUpdater<StateProto>>>& updater)
+  void Connect(const
+                std::shared_ptr<StateUpdater<StateProto>>& updater)
       ABSL_LOCKS_EXCLUDED(mutex_) {
     listener_.Listen(updater);
   }
 
-  static absl::Nullable<StateChangeWriteReactor*> Detach(
-      absl::Nullable<std::unique_ptr<StateChangeWriteReactor<StateProto>>>
+  static StateChangeWriteReactor*  Detach(
+       std::unique_ptr<StateChangeWriteReactor<StateProto>>
           reactor) {
-    absl::Nullable<StateChangeWriteReactor*> ptr = reactor.get();
+    StateChangeWriteReactor*  ptr = reactor.get();
     if (ptr == nullptr) return nullptr;
     ptr->self_ = std::move(reactor);
     return ptr;
diff --git a/state_updater.h b/state_updater.h
index c8477e5..197c738 100644
--- a/state_updater.h
+++ b/state_updater.h
@@ -23,7 +23,7 @@
       }
     }
 
-    void Listen(const absl::Nonnull<std::shared_ptr<StateUpdater>>& updater) {
+    void Listen(const  std::shared_ptr<StateUpdater>& updater) {
       if (!state_updater_.expired()) {
         LOG(DFATAL) << "Listener already connected";
         return;
@@ -38,7 +38,7 @@
 
    private:
     std::weak_ptr<StateUpdater> state_updater_;
-    std::list<absl::Nonnull<Listener*>>::iterator itr_;
+    std::list<Listener* >::iterator itr_;
   };
   friend class Listener;
 
@@ -80,7 +80,7 @@
   }
 
  private:
-  std::list<absl::Nonnull<Listener*>>::iterator AddListener(Listener& listener)
+  std::list<Listener* >::iterator AddListener(Listener& listener)
       ABSL_LOCKS_EXCLUDED(state_mutex_, listeners_mutex_) {
     bool final;
     {
@@ -99,7 +99,7 @@
     return listeners_.begin();
   }
 
-  void RemoveListener(std::list<absl::Nonnull<Listener*>>::iterator handle)
+  void RemoveListener(std::list<Listener* >::iterator handle)
       ABSL_LOCKS_EXCLUDED(listeners_mutex_) {
     absl::MutexLock lock(&listeners_mutex_);
     if (handle == listeners_.end()) return;
@@ -109,7 +109,7 @@
   mutable absl::Mutex state_mutex_ ABSL_ACQUIRED_BEFORE(listeners_mutex_);
   absl::Mutex listeners_mutex_;
   // This is a std::list so that we have stable iterators
-  std::list<absl::Nonnull<Listener*>> listeners_
+  std::list<Listener* > listeners_
       ABSL_GUARDED_BY(listeners_mutex_);
   StateProto state_ ABSL_GUARDED_BY(state_mutex_);
   bool final_ ABSL_GUARDED_BY(state_mutex_);