[modular][fostr] Remove hand-written FIDL formatters

Also migrate some tests to component packages so they can load shared
libraries in their package.

Test: N/A
MF-34 #comment [modular][fostr] Remove hand-written FIDL formatters

Change-Id: If6b973c7d88af6e17a3b1d1a7b8d184dae4b81ce
diff --git a/bin/acquirers/story_info/BUILD.gn b/bin/acquirers/story_info/BUILD.gn
index d0a3e1a..c25f5c6 100644
--- a/bin/acquirers/story_info/BUILD.gn
+++ b/bin/acquirers/story_info/BUILD.gn
@@ -38,7 +38,6 @@
     "//peridot/public/fidl/fuchsia.modular",
     "//peridot/public/lib/app_driver/cpp:agent_driver",
     "//peridot/public/lib/context/cpp:context_metadata_builder",
-    "//peridot/public/lib/context/cpp:formatting",
     "//peridot/public/lib/entity/cpp",
     "//peridot/public/lib/entity/cpp:json",
     "//third_party/rapidjson",
diff --git a/bin/acquirers/story_info/link_watcher_impl.cc b/bin/acquirers/story_info/link_watcher_impl.cc
index 8f102d8..62b5f5c 100644
--- a/bin/acquirers/story_info/link_watcher_impl.cc
+++ b/bin/acquirers/story_info/link_watcher_impl.cc
@@ -8,7 +8,6 @@
 #include <sstream>
 
 #include <lib/context/cpp/context_metadata_builder.h>
-#include <lib/context/cpp/formatting.h>
 #include <lib/entity/cpp/json.h>
 #include <lib/fidl/cpp/clone.h>
 #include <lib/fidl/cpp/optional.h>
diff --git a/bin/acquirers/story_info/story_watcher_impl.cc b/bin/acquirers/story_info/story_watcher_impl.cc
index 6976b20..9a1b6d6 100644
--- a/bin/acquirers/story_info/story_watcher_impl.cc
+++ b/bin/acquirers/story_info/story_watcher_impl.cc
@@ -5,7 +5,6 @@
 #include "peridot/bin/acquirers/story_info/story_watcher_impl.h"
 
 #include <lib/context/cpp/context_metadata_builder.h>
-#include <lib/context/cpp/formatting.h>
 #include <lib/fidl/cpp/optional.h>
 #include <lib/fxl/functional/make_copyable.h>
 
diff --git a/bin/context_engine/BUILD.gn b/bin/context_engine/BUILD.gn
index 520cce6..2920653 100644
--- a/bin/context_engine/BUILD.gn
+++ b/bin/context_engine/BUILD.gn
@@ -28,7 +28,7 @@
   ]
 }
 
-tests_package("context_engine_unittests") {
+hermetic_tests_package("context_engine_unittests") {
   deps = [
     ":context_index_unittest",
     ":context_repository_unittest",
@@ -59,7 +59,6 @@
     "//garnet/public/lib/fsl",
     "//peridot/public/fidl/fuchsia.modular",
     "//peridot/public/lib/context/cpp:context_helper",
-    "//peridot/public/lib/context/cpp:formatting",
     "//third_party/googletest:gtest_main",
   ]
 }
@@ -73,7 +72,6 @@
   deps = [
     ":context_repository",
     "//peridot/public/fidl/fuchsia.modular",
-    "//peridot/public/lib/context/cpp:formatting",
   ]
 }
 
@@ -95,7 +93,7 @@
     "//peridot/lib/bound_set",
     "//peridot/lib/rapidjson",
     "//peridot/public/fidl/fuchsia.modular",
-    "//peridot/public/lib/context/cpp:formatting",
+    "//peridot/public/lib/fostr/fidl/fuchsia.modular",
     "//third_party/rapidjson",
   ]
 }
@@ -113,7 +111,6 @@
     "//peridot/public/fidl/fuchsia.modular",
     "//peridot/public/lib/context/cpp:context_helper",
     "//peridot/public/lib/context/cpp:context_metadata_builder",
-    "//peridot/public/lib/context/cpp:formatting",
     "//third_party/googletest:gtest_main",
   ]
 }
@@ -130,7 +127,6 @@
     "//peridot/lib/bound_set",
     "//peridot/public/fidl/fuchsia.modular",
     "//peridot/public/lib/async/cpp:future",
-    "//peridot/public/lib/context/cpp:formatting",
     "//peridot/public/lib/entity/cpp",
     "//peridot/public/lib/entity/cpp:json",
     "//third_party/rapidjson",
diff --git a/bin/context_engine/context_reader_impl.cc b/bin/context_engine/context_reader_impl.cc
index 8cdcff7..6056fe1 100644
--- a/bin/context_engine/context_reader_impl.cc
+++ b/bin/context_engine/context_reader_impl.cc
@@ -4,7 +4,6 @@
 
 #include "peridot/bin/context_engine/context_reader_impl.h"
 
-#include <lib/context/cpp/formatting.h>
 #include <lib/fidl/cpp/clone.h>
 
 #include "peridot/bin/context_engine/context_repository.h"
diff --git a/bin/context_engine/context_repository.cc b/bin/context_engine/context_repository.cc
index bcb74fe..fb524f1 100644
--- a/bin/context_engine/context_repository.cc
+++ b/bin/context_engine/context_repository.cc
@@ -8,9 +8,9 @@
 #include <memory>
 #include <set>
 
-#include <lib/context/cpp/formatting.h>
 #include <lib/fidl/cpp/clone.h>
 #include <lib/fidl/cpp/optional.h>
+#include <lib/fostr/fidl/fuchsia/modular/formatting.h>
 
 #include "peridot/bin/context_engine/debug.h"
 #include "peridot/lib/rapidjson/rapidjson.h"
diff --git a/bin/context_engine/context_repository_unittest.cc b/bin/context_engine/context_repository_unittest.cc
index 4fe5434..df3b463 100644
--- a/bin/context_engine/context_repository_unittest.cc
+++ b/bin/context_engine/context_repository_unittest.cc
@@ -7,7 +7,6 @@
 #include <fuchsia/modular/cpp/fidl.h>
 #include <lib/context/cpp/context_helper.h>
 #include <lib/context/cpp/context_metadata_builder.h>
-#include <lib/context/cpp/formatting.h>
 #include <lib/fidl/cpp/clone.h>
 #include <lib/fidl/cpp/optional.h>
 
diff --git a/bin/context_engine/context_writer_impl.cc b/bin/context_engine/context_writer_impl.cc
index 8efd0ba..e8d3044 100644
--- a/bin/context_engine/context_writer_impl.cc
+++ b/bin/context_engine/context_writer_impl.cc
@@ -7,7 +7,6 @@
 #include <memory>
 
 #include <fuchsia/modular/cpp/fidl.h>
-#include <lib/context/cpp/formatting.h>
 #include <lib/entity/cpp/json.h>
 #include <lib/fidl/cpp/clone.h>
 #include <lib/fit/defer.h>
diff --git a/bin/context_engine/index_unittest.cc b/bin/context_engine/index_unittest.cc
index 314ad5a..6a14523 100644
--- a/bin/context_engine/index_unittest.cc
+++ b/bin/context_engine/index_unittest.cc
@@ -5,7 +5,6 @@
 #include "peridot/bin/context_engine/index.h"
 
 #include <fuchsia/modular/cpp/fidl.h>
-#include <lib/context/cpp/formatting.h>
 #include <lib/fidl/cpp/clone.h>
 
 #include "gtest/gtest.h"
diff --git a/bin/context_engine/meta/context_index_unittest.cmx b/bin/context_engine/meta/context_index_unittest.cmx
new file mode 100644
index 0000000..a77ae85
--- /dev/null
+++ b/bin/context_engine/meta/context_index_unittest.cmx
@@ -0,0 +1,8 @@
+{
+  "program": {
+    "binary": "test/context_index_unittest"
+  },
+  "sandbox": {
+    "services": []
+  }
+}
diff --git a/bin/context_engine/meta/context_repository_unittest.cmx b/bin/context_engine/meta/context_repository_unittest.cmx
new file mode 100644
index 0000000..8b35548
--- /dev/null
+++ b/bin/context_engine/meta/context_repository_unittest.cmx
@@ -0,0 +1,8 @@
+{
+  "program": {
+    "binary": "test/context_repository_unittest"
+  },
+  "sandbox": {
+    "services": []
+  }
+}
diff --git a/bin/module_resolver/BUILD.gn b/bin/module_resolver/BUILD.gn
index 5a6cd41..3c7d24a 100644
--- a/bin/module_resolver/BUILD.gn
+++ b/bin/module_resolver/BUILD.gn
@@ -72,7 +72,6 @@
     "//peridot/lib/fidl:clone",
     "//peridot/lib/testing:entity_resolver_fake",
     "//peridot/public/lib/entity/cpp:json",
-    "//peridot/public/lib/module_resolver/cpp:formatting",
     "//third_party/googletest:gtest_main",
   ]
 }
diff --git a/bin/module_resolver/local_module_resolver_unittest.cc b/bin/module_resolver/local_module_resolver_unittest.cc
index 5072342..dcf08c7 100644
--- a/bin/module_resolver/local_module_resolver_unittest.cc
+++ b/bin/module_resolver/local_module_resolver_unittest.cc
@@ -8,7 +8,6 @@
 #include <lib/fsl/types/type_converters.h>
 #include <lib/fxl/files/file.h>
 #include <lib/gtest/test_loop_fixture.h>
-#include <lib/module_resolver/cpp/formatting.h>
 
 #include "peridot/lib/fidl/clone.h"
 #include "peridot/lib/testing/entity_resolver_fake.h"
diff --git a/bin/sessionmgr/puppet_master/BUILD.gn b/bin/sessionmgr/puppet_master/BUILD.gn
index 96beba8..7398df0 100644
--- a/bin/sessionmgr/puppet_master/BUILD.gn
+++ b/bin/sessionmgr/puppet_master/BUILD.gn
@@ -4,7 +4,7 @@
 
 import("//peridot/build/tests_package.gni")
 
-tests_package("puppet_master_unittests") {
+hermetic_tests_package("puppet_master_unittests") {
   deps = [
     ":dispatch_story_command_executor_unittest",
     ":puppet_master_impl_unittest",
diff --git a/bin/sessionmgr/puppet_master/command_runners/operation_calls/BUILD.gn b/bin/sessionmgr/puppet_master/command_runners/operation_calls/BUILD.gn
index 5023e37..99a0dd1 100644
--- a/bin/sessionmgr/puppet_master/command_runners/operation_calls/BUILD.gn
+++ b/bin/sessionmgr/puppet_master/command_runners/operation_calls/BUILD.gn
@@ -53,6 +53,7 @@
     "//peridot/public/fidl/fuchsia.modular",
     "//peridot/public/lib/async/cpp:operation",
     "//peridot/public/lib/entity/cpp:json",
+    "//peridot/public/lib/fostr/fidl/fuchsia.modular",
   ]
 }
 
diff --git a/bin/sessionmgr/puppet_master/command_runners/operation_calls/find_modules_call.cc b/bin/sessionmgr/puppet_master/command_runners/operation_calls/find_modules_call.cc
index 4bcb1e3..53c24f3 100644
--- a/bin/sessionmgr/puppet_master/command_runners/operation_calls/find_modules_call.cc
+++ b/bin/sessionmgr/puppet_master/command_runners/operation_calls/find_modules_call.cc
@@ -4,6 +4,7 @@
 #include "peridot/bin/sessionmgr/puppet_master/command_runners/operation_calls/find_modules_call.h"
 
 #include <lib/entity/cpp/json.h>
+#include <lib/fostr/fidl/fuchsia/modular/formatting.h>
 #include <lib/fsl/types/type_converters.h>
 #include <lib/fsl/vmo/strings.h>
 #include <lib/fxl/functional/make_copyable.h>
@@ -17,14 +18,6 @@
 
 namespace {
 
-std::ostream& operator<<(std::ostream& os,
-                         const fuchsia::modular::IntentPtr& value) {
-  os << "Intent{"
-     << "action: " << value->action << ", handler: " << value->handler
-     << ", parameters.size: " << value->parameters->size() << "}";
-  return os;
-}
-
 class FindModulesCall
     : public Operation<fuchsia::modular::ExecuteResult,
                        fuchsia::modular::FindModulesResponse> {
diff --git a/bin/sessionmgr/puppet_master/meta/add_mod_command_runner_unittest.cmx b/bin/sessionmgr/puppet_master/meta/add_mod_command_runner_unittest.cmx
new file mode 100644
index 0000000..d462cf7
--- /dev/null
+++ b/bin/sessionmgr/puppet_master/meta/add_mod_command_runner_unittest.cmx
@@ -0,0 +1,10 @@
+{
+  "program": {
+    "binary": "test/add_mod_command_runner_unittest"
+  },
+  "sandbox": {
+    "services": [
+      "fuchsia.sys.Launcher"
+    ]
+  }
+}
diff --git a/bin/sessionmgr/puppet_master/meta/dispatch_story_command_executor_unittest.cmx b/bin/sessionmgr/puppet_master/meta/dispatch_story_command_executor_unittest.cmx
new file mode 100644
index 0000000..cc547a3
--- /dev/null
+++ b/bin/sessionmgr/puppet_master/meta/dispatch_story_command_executor_unittest.cmx
@@ -0,0 +1,10 @@
+{
+  "program": {
+    "binary": "test/dispatch_story_command_executor_unittest"
+  },
+  "sandbox": {
+    "services": [
+      "fuchsia.sys.Launcher"
+    ]
+  }
+}
diff --git a/bin/sessionmgr/puppet_master/meta/focus_mod_command_runner_unittest.cmx b/bin/sessionmgr/puppet_master/meta/focus_mod_command_runner_unittest.cmx
new file mode 100644
index 0000000..9379c10
--- /dev/null
+++ b/bin/sessionmgr/puppet_master/meta/focus_mod_command_runner_unittest.cmx
@@ -0,0 +1,8 @@
+{
+  "program": {
+    "binary": "test/focus_mod_command_runner_unittest"
+  },
+  "sandbox": {
+    "services": []
+  }
+}
diff --git a/bin/sessionmgr/puppet_master/meta/puppet_master_impl_unittest.cmx b/bin/sessionmgr/puppet_master/meta/puppet_master_impl_unittest.cmx
new file mode 100644
index 0000000..c2b6989
--- /dev/null
+++ b/bin/sessionmgr/puppet_master/meta/puppet_master_impl_unittest.cmx
@@ -0,0 +1,10 @@
+{
+  "program": {
+    "binary": "test/puppet_master_impl_unittest"
+  },
+  "sandbox": {
+    "services": [
+      "fuchsia.sys.Launcher"
+    ]
+  }
+}
diff --git a/bin/sessionmgr/puppet_master/meta/remove_mod_command_runner_unittest.cmx b/bin/sessionmgr/puppet_master/meta/remove_mod_command_runner_unittest.cmx
new file mode 100644
index 0000000..81e7baf
--- /dev/null
+++ b/bin/sessionmgr/puppet_master/meta/remove_mod_command_runner_unittest.cmx
@@ -0,0 +1,10 @@
+{
+  "program": {
+    "binary": "test/remove_mod_command_runner_unittest"
+  },
+  "sandbox": {
+    "services": [
+      "fuchsia.sys.Launcher"
+    ]
+  }
+}
diff --git a/bin/sessionmgr/puppet_master/meta/set_focus_state_command_runner_unittest.cmx b/bin/sessionmgr/puppet_master/meta/set_focus_state_command_runner_unittest.cmx
new file mode 100644
index 0000000..e12dc99
--- /dev/null
+++ b/bin/sessionmgr/puppet_master/meta/set_focus_state_command_runner_unittest.cmx
@@ -0,0 +1,8 @@
+{
+  "program": {
+    "binary": "test/set_focus_state_command_runner_unittest"
+  },
+  "sandbox": {
+    "services": []
+  }
+}
diff --git a/bin/sessionmgr/puppet_master/meta/set_kind_of_proto_story_option_command_runner_unittest.cmx b/bin/sessionmgr/puppet_master/meta/set_kind_of_proto_story_option_command_runner_unittest.cmx
new file mode 100644
index 0000000..31d38c7
--- /dev/null
+++ b/bin/sessionmgr/puppet_master/meta/set_kind_of_proto_story_option_command_runner_unittest.cmx
@@ -0,0 +1,10 @@
+{
+  "program": {
+    "binary": "test/set_kind_of_proto_story_option_command_runner_unittest"
+  },
+  "sandbox": {
+    "services": [
+      "fuchsia.sys.Launcher"
+    ]
+  }
+}
diff --git a/bin/sessionmgr/puppet_master/meta/set_link_value_command_runner_unittest.cmx b/bin/sessionmgr/puppet_master/meta/set_link_value_command_runner_unittest.cmx
new file mode 100644
index 0000000..aa605eb
--- /dev/null
+++ b/bin/sessionmgr/puppet_master/meta/set_link_value_command_runner_unittest.cmx
@@ -0,0 +1,10 @@
+{
+  "program": {
+    "binary": "test/set_link_value_command_runner_unittest"
+  },
+  "sandbox": {
+    "services": [
+      "fuchsia.sys.Launcher"
+    ]
+  }
+}
diff --git a/bin/sessionmgr/puppet_master/meta/story_command_executor_unittest.cmx b/bin/sessionmgr/puppet_master/meta/story_command_executor_unittest.cmx
new file mode 100644
index 0000000..a3c5f6e
--- /dev/null
+++ b/bin/sessionmgr/puppet_master/meta/story_command_executor_unittest.cmx
@@ -0,0 +1,8 @@
+{
+  "program": {
+    "binary": "test/story_command_executor_unittest"
+  },
+  "sandbox": {
+    "services": []
+  }
+}
diff --git a/bin/sessionmgr/story_runner/BUILD.gn b/bin/sessionmgr/story_runner/BUILD.gn
index d119481..1b0b888 100644
--- a/bin/sessionmgr/story_runner/BUILD.gn
+++ b/bin/sessionmgr/story_runner/BUILD.gn
@@ -76,6 +76,7 @@
     "//peridot/public/lib/async/cpp:operation",
     "//peridot/public/lib/context/cpp:context_helper",
     "//peridot/public/lib/entity/cpp:json",
+    "//peridot/public/lib/fostr/fidl/fuchsia.modular",
   ]
 
   deps = [
diff --git a/bin/sessionmgr/story_runner/link_impl.cc b/bin/sessionmgr/story_runner/link_impl.cc
index 55d04a1..b81780d 100644
--- a/bin/sessionmgr/story_runner/link_impl.cc
+++ b/bin/sessionmgr/story_runner/link_impl.cc
@@ -11,6 +11,7 @@
 #include <lib/fidl/cpp/interface_handle.h>
 #include <lib/fidl/cpp/interface_request.h>
 #include <lib/fidl/cpp/optional.h>
+#include <lib/fostr/fidl/fuchsia/modular/formatting.h>
 #include <lib/fsl/vmo/strings.h>
 #include <lib/fxl/functional/make_copyable.h>
 #include <lib/fxl/logging.h>
@@ -23,13 +24,6 @@
 namespace modular {
 
 namespace {
-std::ostream& operator<<(std::ostream& o, const LinkPath& link_path) {
-  for (const auto& part : link_path.module_path) {
-    o << part << ":";
-  }
-  o << link_path.link_name;
-  return o;
-}
 
 // Applies a JSON mutation operation using |apply_fn|. Its parameters are
 // references because we treat |apply_fn| as part of ApplyOp's body.
diff --git a/public/lib/context/cpp/BUILD.gn b/public/lib/context/cpp/BUILD.gn
index 199ed03..de9d96a 100644
--- a/public/lib/context/cpp/BUILD.gn
+++ b/public/lib/context/cpp/BUILD.gn
@@ -24,14 +24,3 @@
     "//peridot/public/fidl/fuchsia.modular",
   ]
 }
-
-source_set("formatting") {
-  sources = [
-    "formatting.cc",
-    "formatting.h",
-  ]
-
-  deps = [
-    "//peridot/public/fidl/fuchsia.modular",
-  ]
-}
diff --git a/public/lib/context/cpp/formatting.cc b/public/lib/context/cpp/formatting.cc
deleted file mode 100644
index 0633903..0000000
--- a/public/lib/context/cpp/formatting.cc
+++ /dev/null
@@ -1,86 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <lib/context/cpp/formatting.h>
-
-#include <fuchsia/modular/cpp/fidl.h>
-#include <lib/fidl/cpp/vector.h>
-
-namespace fuchsia {
-namespace modular {
-
-template <typename T>
-std::ostream& operator<<(std::ostream& os, const fidl::VectorPtr<T>& value) {
-  os << "[ ";
-  for (const T& element : *value) {
-    os << element << " ";
-  }
-  return os << "]";
-}
-
-std::ostream& operator<<(std::ostream& os, const FocusedState& state) {
-  return os << (state.state == FocusedStateState::FOCUSED ? "yes" : "no");
-}
-
-std::ostream& operator<<(std::ostream& os, const StoryMetadata& meta) {
-  return os << "{ id: " << meta.id << ", focused: " << *meta.focused << " }";
-}
-
-std::ostream& operator<<(std::ostream& os, const ModuleMetadata& meta) {
-  return os << "{ url: " << meta.url << ", path: " << meta.path << " }";
-}
-
-std::ostream& operator<<(std::ostream& os, const EntityMetadata& meta) {
-  return os << "{ topic: " << meta.topic << ", type: " << meta.type << " }";
-}
-
-std::ostream& operator<<(std::ostream& os, const LinkMetadata& meta) {
-  return os << "{ module_path: " << meta.module_path << ", name: " << meta.name
-            << " }";
-}
-
-std::ostream& operator<<(std::ostream& os, const ContextMetadata& meta) {
-  os << "{" << std::endl;
-  os << "  story: " << meta.story << std::endl;
-  os << "  link: " << meta.link << std::endl;
-  os << "  mod: " << meta.mod << std::endl;
-  os << "  entity: " << meta.entity << std::endl;
-  return os << "}";
-}
-
-std::ostream& operator<<(std::ostream& os, const ContextValue& value) {
-  return os << "{ type: " << fidl::ToUnderlying(value.type)
-            << ", content: " << value.content << ", meta: " << value.meta
-            << " }";
-}
-
-std::ostream& operator<<(std::ostream& os, const ContextSelector& selector) {
-  return os << "{ type: " << fidl::ToUnderlying(selector.type)
-            << ", meta: " << *selector.meta << " }";
-}
-
-std::ostream& operator<<(std::ostream& os, const ContextUpdate& update) {
-  os << "{" << std::endl;
-  for (auto it = update.values.begin(); it != update.values.end(); ++it) {
-    os << "  " << (*it).key << ":" << std::endl;
-    int i = 0;
-    for (const auto& v : (*it).value) {
-      os << "    [" << i++ << "]: " << v;
-    }
-  }
-  os << "}";
-  return os;
-}
-
-std::ostream& operator<<(std::ostream& os, const ContextQuery& query) {
-  os << "{" << std::endl;
-  for (auto it = query.selector.begin(); it != query.selector.end(); ++it) {
-    os << "  " << (*it).key << ": " << (*it).value;
-  }
-  os << "}";
-  return os;
-}
-
-}  // namespace modular
-}  // namespace fuchsia
diff --git a/public/lib/context/cpp/formatting.h b/public/lib/context/cpp/formatting.h
deleted file mode 100644
index 81db332..0000000
--- a/public/lib/context/cpp/formatting.h
+++ /dev/null
@@ -1,29 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_CONTEXT_CPP_FORMATTING_H_
-#define LIB_CONTEXT_CPP_FORMATTING_H_
-
-#include <fuchsia/modular/cpp/fidl.h>
-
-namespace fuchsia {
-namespace modular {
-
-std::ostream& operator<<(std::ostream& os, const FocusedState& state);
-std::ostream& operator<<(std::ostream& os, const StoryMetadata& meta);
-std::ostream& operator<<(std::ostream& os, const ModuleMetadata& meta);
-std::ostream& operator<<(std::ostream& os, const EntityMetadata& meta);
-std::ostream& operator<<(std::ostream& os, const LinkMetadata& meta);
-std::ostream& operator<<(std::ostream& os, const ContextMetadata& meta);
-
-std::ostream& operator<<(std::ostream& os, const ContextValue& value);
-std::ostream& operator<<(std::ostream& os, const ContextSelector& selector);
-
-std::ostream& operator<<(std::ostream& os, const ContextUpdate& update);
-std::ostream& operator<<(std::ostream& os, const ContextQuery& query);
-
-}  // namespace modular
-}  // namespace fuchsia
-
-#endif  // LIB_CONTEXT_CPP_FORMATTING_H_
diff --git a/public/lib/module_resolver/cpp/BUILD.gn b/public/lib/module_resolver/cpp/BUILD.gn
deleted file mode 100644
index 399afe5..0000000
--- a/public/lib/module_resolver/cpp/BUILD.gn
+++ /dev/null
@@ -1,14 +0,0 @@
-# Copyright 2017 The Fuchsia Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-source_set("formatting") {
-  sources = [
-    "formatting.cc",
-    "formatting.h",
-  ]
-
-  deps = [
-    "//peridot/public/fidl/fuchsia.modular",
-  ]
-}
diff --git a/public/lib/module_resolver/cpp/formatting.cc b/public/lib/module_resolver/cpp/formatting.cc
deleted file mode 100644
index 87e1184..0000000
--- a/public/lib/module_resolver/cpp/formatting.cc
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <lib/fsl/vmo/strings.h>
-#include <lib/module_resolver/cpp/formatting.h>
-
-namespace modular {
-
-std::ostream& operator<<(std::ostream& os,
-                         const fuchsia::modular::Intent& intent) {
-  os << "{ action: " << intent.action << ", parameters: [" << std::endl;
-  for (auto it = intent.parameters->begin(); it != intent.parameters->end();
-       ++it) {
-    os << "    " << it->name << ": " << it->data << "," << std::endl;
-  }
-  os << "  ] }";
-  return os;
-}
-
-std::ostream& operator<<(
-    std::ostream& os,
-    const fuchsia::modular::IntentParameterData& parameter_data) {
-  if (parameter_data.is_json()) {
-    std::string json;
-    FXL_CHECK(fsl::StringFromVmo(parameter_data.json(), &json));
-    os << json;
-  } else if (parameter_data.is_entity_reference()) {
-    os << "[ref: " << parameter_data.entity_reference() << "]";
-  } else if (parameter_data.is_entity_type()) {
-    for (const auto& type : parameter_data.entity_type()) {
-      os << type << ", ";
-    }
-  }
-  return os;
-}
-
-}  // namespace modular
diff --git a/public/lib/module_resolver/cpp/formatting.h b/public/lib/module_resolver/cpp/formatting.h
deleted file mode 100644
index 20c7f27..0000000
--- a/public/lib/module_resolver/cpp/formatting.h
+++ /dev/null
@@ -1,20 +0,0 @@
-// Copyright 2017 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_MODULE_RESOLVER_CPP_FORMATTING_H_
-#define LIB_MODULE_RESOLVER_CPP_FORMATTING_H_
-
-#include <fuchsia/modular/cpp/fidl.h>
-
-namespace modular {
-
-std::ostream& operator<<(std::ostream& os,
-                         const fuchsia::modular::Intent& intent);
-std::ostream& operator<<(
-    std::ostream& os,
-    const fuchsia::modular::IntentParameterData& parameter_data);
-
-}  // namespace modular
-
-#endif  // LIB_MODULE_RESOLVER_CPP_FORMATTING_H_
diff --git a/public/lib/suggestion/cpp/BUILD.gn b/public/lib/suggestion/cpp/BUILD.gn
deleted file mode 100644
index ac4c0ec..0000000
--- a/public/lib/suggestion/cpp/BUILD.gn
+++ /dev/null
@@ -1,15 +0,0 @@
-# Copyright 2016 The Fuchsia Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-source_set("formatting") {
-  sources = [
-    "formatting.cc",
-    "formatting.h",
-  ]
-
-  deps = [
-    "//garnet/public/lib/fidl/cpp",
-    "//peridot/public/fidl/fuchsia.modular",
-  ]
-}
diff --git a/public/lib/suggestion/cpp/formatting.cc b/public/lib/suggestion/cpp/formatting.cc
deleted file mode 100644
index b56aabf..0000000
--- a/public/lib/suggestion/cpp/formatting.cc
+++ /dev/null
@@ -1,22 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <lib/suggestion/cpp/formatting.h>
-
-namespace modular {
-
-std::ostream& operator<<(std::ostream& os,
-                         const fuchsia::modular::SuggestionDisplay& o) {
-  return os << "{ headline: " << o.headline
-            << ", subheadline: " << o.subheadline << ", details: " << o.details
-            << "}";
-}
-
-std::ostream& operator<<(std::ostream& os,
-                         const fuchsia::modular::Suggestion& o) {
-  return os << "{ uuid: " << o.uuid << ", confidence: " << o.confidence
-            << ", display: " << o.display << "}";
-}
-
-}  // namespace modular
diff --git a/public/lib/suggestion/cpp/formatting.h b/public/lib/suggestion/cpp/formatting.h
deleted file mode 100644
index e40d3ef..0000000
--- a/public/lib/suggestion/cpp/formatting.h
+++ /dev/null
@@ -1,19 +0,0 @@
-// Copyright 2016 The Fuchsia Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef LIB_SUGGESTION_CPP_FORMATTING_H_
-#define LIB_SUGGESTION_CPP_FORMATTING_H_
-
-#include <fuchsia/modular/cpp/fidl.h>
-
-namespace modular {
-
-std::ostream& operator<<(std::ostream& os,
-                         const fuchsia::modular::SuggestionDisplay& o);
-std::ostream& operator<<(std::ostream& os,
-                         const fuchsia::modular::Suggestion& o);
-
-}  // namespace modular
-
-#endif  // LIB_SUGGESTION_CPP_FORMATTING_H_
diff --git a/tests/embed_shell/BUILD.gn b/tests/embed_shell/BUILD.gn
index 6f7caf2..7404b6f 100644
--- a/tests/embed_shell/BUILD.gn
+++ b/tests/embed_shell/BUILD.gn
@@ -95,7 +95,6 @@
     "//peridot/lib/testing:component_base",
     "//peridot/public/fidl/fuchsia.modular",
     "//peridot/public/lib/app_driver/cpp",
-    "//peridot/public/lib/context/cpp:formatting",
     "//peridot/tests/common:defs",
     "//zircon/public/lib/async-loop-cpp",
   ]
diff --git a/tests/link_context_entities/BUILD.gn b/tests/link_context_entities/BUILD.gn
index ef9018c..6b8838a 100644
--- a/tests/link_context_entities/BUILD.gn
+++ b/tests/link_context_entities/BUILD.gn
@@ -42,7 +42,7 @@
     "//peridot/lib/testing:session_shell_base",
     "//peridot/public/fidl/fuchsia.modular",
     "//peridot/public/lib/context/cpp:context_helper",
-    "//peridot/public/lib/context/cpp:formatting",
+    "//peridot/public/lib/fostr/fidl/fuchsia.modular",
     "//peridot/tests/common:defs",
     "//zircon/public/lib/async-loop-cpp",
   ]
diff --git a/tests/link_context_entities/link_context_entities_test_session_shell.cc b/tests/link_context_entities/link_context_entities_test_session_shell.cc
index bd9223e..918d37f 100644
--- a/tests/link_context_entities/link_context_entities_test_session_shell.cc
+++ b/tests/link_context_entities/link_context_entities_test_session_shell.cc
@@ -10,8 +10,8 @@
 #include <fuchsia/ui/viewsv1token/cpp/fidl.h>
 #include <lib/component/cpp/startup_context.h>
 #include <lib/context/cpp/context_helper.h>
-#include <lib/context/cpp/formatting.h>
 #include <lib/fidl/cpp/binding.h>
+#include <lib/fostr/fidl/fuchsia/modular/formatting.h>
 #include <lib/fxl/logging.h>
 #include <lib/fxl/macros.h>
 
diff --git a/tests/maxwell_integration/BUILD.gn b/tests/maxwell_integration/BUILD.gn
index d65ff69..b8da28c 100644
--- a/tests/maxwell_integration/BUILD.gn
+++ b/tests/maxwell_integration/BUILD.gn
@@ -4,7 +4,7 @@
 
 import("//peridot/build/tests_package.gni")
 
-tests_package("maxwell_integration_tests") {
+hermetic_tests_package("maxwell_integration_tests") {
   deps = [
     ":context_engine_test",
     ":suggestion_engine_test",
@@ -27,7 +27,6 @@
     "//peridot/public/fidl/fuchsia.modular",
     "//peridot/public/lib/context/cpp:context_helper",
     "//peridot/public/lib/context/cpp:context_metadata_builder",
-    "//peridot/public/lib/context/cpp:formatting",
     "//third_party/googletest:gtest_main",
   ]
 }
@@ -108,7 +107,7 @@
   deps = [
     "//garnet/public/lib/fxl",
     "//peridot/public/fidl/fuchsia.modular",
-    "//peridot/public/lib/suggestion/cpp:formatting",
+    "//peridot/public/lib/fostr/fidl/fuchsia.modular",
   ]
 
   public_deps = [
diff --git a/tests/maxwell_integration/context_engine_test.cc b/tests/maxwell_integration/context_engine_test.cc
index 37da031..9c3cb4a 100644
--- a/tests/maxwell_integration/context_engine_test.cc
+++ b/tests/maxwell_integration/context_engine_test.cc
@@ -5,7 +5,6 @@
 #include <fuchsia/modular/cpp/fidl.h>
 #include <lib/context/cpp/context_helper.h>
 #include <lib/context/cpp/context_metadata_builder.h>
-#include <lib/context/cpp/formatting.h>
 #include <lib/fidl/cpp/binding.h>
 #include <lib/fidl/cpp/clone.h>
 #include <lib/fidl/cpp/optional.h>
diff --git a/tests/maxwell_integration/meta/context_engine_test.cmx b/tests/maxwell_integration/meta/context_engine_test.cmx
new file mode 100644
index 0000000..dd44b6c
--- /dev/null
+++ b/tests/maxwell_integration/meta/context_engine_test.cmx
@@ -0,0 +1,11 @@
+{
+  "program": {
+    "binary": "test/context_engine_test"
+  },
+  "sandbox": {
+    "services": [
+      "fuchsia.sys.Launcher",
+      "fuchsia.sys.Environment"
+    ]
+  }
+}
diff --git a/tests/maxwell_integration/meta/suggestion_engine_test.cmx b/tests/maxwell_integration/meta/suggestion_engine_test.cmx
new file mode 100644
index 0000000..80566e2
--- /dev/null
+++ b/tests/maxwell_integration/meta/suggestion_engine_test.cmx
@@ -0,0 +1,11 @@
+{
+  "program": {
+    "binary": "test/suggestion_engine_test"
+  },
+  "sandbox": {
+    "services": [
+      "fuchsia.sys.Launcher",
+      "fuchsia.sys.Environment"
+    ]
+  }
+}
diff --git a/tests/maxwell_integration/test_suggestion_listener.cc b/tests/maxwell_integration/test_suggestion_listener.cc
index e07350f..534ba5c 100644
--- a/tests/maxwell_integration/test_suggestion_listener.cc
+++ b/tests/maxwell_integration/test_suggestion_listener.cc
@@ -4,7 +4,7 @@
 
 #include "peridot/tests/maxwell_integration/test_suggestion_listener.h"
 
-#include <lib/suggestion/cpp/formatting.h>
+#include <lib/fostr/fidl/fuchsia/modular/formatting.h>
 
 bool suggestion_less(const fuchsia::modular::Suggestion* a,
                      const fuchsia::modular::Suggestion* b) {
diff --git a/tests/module_context/BUILD.gn b/tests/module_context/BUILD.gn
index 133fe82..6eff94d 100644
--- a/tests/module_context/BUILD.gn
+++ b/tests/module_context/BUILD.gn
@@ -34,7 +34,6 @@
     "//peridot/lib/testing:component_main",
     "//peridot/lib/testing:session_shell_base",
     "//peridot/public/fidl/fuchsia.modular",
-    "//peridot/public/lib/context/cpp:formatting",
     "//peridot/tests/common:defs",
   ]
 }
diff --git a/tests/story_shell/BUILD.gn b/tests/story_shell/BUILD.gn
index 443161c..b777f8f 100644
--- a/tests/story_shell/BUILD.gn
+++ b/tests/story_shell/BUILD.gn
@@ -44,7 +44,6 @@
     "//peridot/lib/testing:component_base",
     "//peridot/public/fidl/fuchsia.modular",
     "//peridot/public/lib/app_driver/cpp",
-    "//peridot/public/lib/context/cpp:formatting",
     "//peridot/tests/common:defs",
   ]
 }
@@ -82,7 +81,6 @@
     "//peridot/lib/testing:session_shell_base",
     "//peridot/public/fidl/fuchsia.modular",
     "//peridot/public/lib/app_driver/cpp",
-    "//peridot/public/lib/context/cpp:formatting",
     "//peridot/tests/common:defs",
   ]
 }