← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:schema-circular-imports-decentralize-soyuz into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:schema-circular-imports-decentralize-soyuz into launchpad:master.

Commit message:
Move circular import workarounds to lp.soyuz.interfaces.webservice

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)
Related bugs:
  Bug #673083 in Launchpad itself: "Break _schema_circular_imports into per-package import fixes"
  https://bugs.launchpad.net/launchpad/+bug/673083

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/426812

A few patches that were entirely within `lp.soyuz.interfaces.livefsbuild` and `lp.soyuz.interfaces.packageset` also move to those modules.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:schema-circular-imports-decentralize-soyuz into launchpad:master.
diff --git a/lib/lp/_schema_circular_imports.py b/lib/lp/_schema_circular_imports.py
index e0bd33a..ba34be6 100644
--- a/lib/lp/_schema_circular_imports.py
+++ b/lib/lp/_schema_circular_imports.py
@@ -20,12 +20,8 @@ from lp.buildmaster.interfaces.builder import IBuilder
 from lp.buildmaster.interfaces.buildfarmjob import IBuildFarmJob
 from lp.buildmaster.interfaces.buildqueue import IBuildQueue
 from lp.code.interfaces.branch import IBranch
-from lp.code.interfaces.cibuild import ICIBuild
 from lp.code.interfaces.gitrepository import IGitRepository
 from lp.code.interfaces.sourcepackagerecipe import ISourcePackageRecipe
-from lp.code.interfaces.sourcepackagerecipebuild import (
-    ISourcePackageRecipeBuild,
-    )
 from lp.registry.interfaces.commercialsubscription import (
     ICommercialSubscription,
     )
@@ -71,30 +67,10 @@ from lp.services.webservice.apihelpers import (
     patch_plain_parameter_type,
     patch_reference_property,
     )
-from lp.snappy.interfaces.snapbase import ISnapBase
 from lp.soyuz.interfaces.archive import IArchive
-from lp.soyuz.interfaces.archivedependency import IArchiveDependency
-from lp.soyuz.interfaces.archivepermission import IArchivePermission
 from lp.soyuz.interfaces.archivesubscriber import IArchiveSubscriber
-from lp.soyuz.interfaces.binarypackagebuild import IBinaryPackageBuild
-from lp.soyuz.interfaces.buildrecords import IHasBuildRecords
 from lp.soyuz.interfaces.distroarchseries import IDistroArchSeries
-from lp.soyuz.interfaces.distroarchseriesfilter import IDistroArchSeriesFilter
-from lp.soyuz.interfaces.livefs import ILiveFSView
-from lp.soyuz.interfaces.livefsbuild import (
-    ILiveFSBuild,
-    ILiveFSFile,
-    )
-from lp.soyuz.interfaces.packageset import IPackageset
-from lp.soyuz.interfaces.publishing import (
-    IBinaryPackagePublishingHistory,
-    IBinaryPackagePublishingHistoryEdit,
-    ISourcePackagePublishingHistory,
-    ISourcePackagePublishingHistoryEdit,
-    ISourcePackagePublishingHistoryPublic,
-    )
 from lp.soyuz.interfaces.queue import IPackageUpload
-from lp.soyuz.interfaces.sourcepackagerelease import ISourcePackageRelease
 
 
 # IBuilder
@@ -109,9 +85,6 @@ patch_plain_parameter_type(
     IPersonEditRestricted, 'createPPA', 'distribution', IDistribution)
 patch_entry_return_type(IPersonEditRestricted, 'createPPA', IArchive)
 
-patch_collection_return_type(
-    IHasBuildRecords, 'getBuildRecords', IBinaryPackageBuild)
-
 patch_reference_property(ISourcePackagePublic, 'distroseries', IDistroSeries)
 patch_reference_property(ISourcePackagePublic, 'productseries', IProductSeries)
 patch_entry_return_type(ISourcePackagePublic, 'getBranch', IBranch)
@@ -131,106 +104,6 @@ patch_collection_return_type(
 patch_entry_return_type(IPerson, 'getRecipe', ISourcePackageRecipe)
 patch_collection_return_type(IPerson, 'getOwnedProjects', IProduct)
 
-# publishing.py
-patch_collection_return_type(
-    ISourcePackagePublishingHistoryPublic, 'getBuilds', IBinaryPackageBuild)
-patch_collection_return_type(
-    ISourcePackagePublishingHistoryPublic, 'getPublishedBinaries',
-    IBinaryPackagePublishingHistory)
-patch_reference_property(
-    IBinaryPackagePublishingHistory, 'distroarchseries',
-    IDistroArchSeries)
-patch_reference_property(
-    IBinaryPackagePublishingHistory, 'build', IBinaryPackageBuild)
-patch_reference_property(
-    IBinaryPackagePublishingHistory, 'archive', IArchive)
-patch_reference_property(
-    ISourcePackagePublishingHistory, 'archive', IArchive)
-patch_reference_property(
-    IBinaryPackagePublishingHistory, 'copied_from_archive', IArchive)
-patch_reference_property(
-    ISourcePackagePublishingHistory, 'copied_from_archive', IArchive)
-patch_reference_property(
-    ISourcePackagePublishingHistory, 'ancestor',
-    ISourcePackagePublishingHistory)
-patch_reference_property(
-    ISourcePackagePublishingHistory, 'packageupload', IPackageUpload)
-patch_entry_return_type(
-    ISourcePackagePublishingHistoryEdit, 'changeOverride',
-    ISourcePackagePublishingHistory)
-patch_entry_return_type(
-    IBinaryPackagePublishingHistoryEdit, 'changeOverride',
-    IBinaryPackagePublishingHistory)
-
-# IArchive apocalypse.
-patch_reference_property(IArchive, 'distribution', IDistribution)
-patch_collection_property(IArchive, 'dependencies', IArchiveDependency)
-patch_collection_return_type(IArchive, 'getAllPermissions', IArchivePermission)
-patch_collection_return_type(
-    IArchive, 'getPermissionsForPerson', IArchivePermission)
-patch_collection_return_type(
-    IArchive, 'getUploadersForPackage', IArchivePermission)
-patch_collection_return_type(
-    IArchive, 'getUploadersForPackageset', IArchivePermission)
-patch_collection_return_type(
-    IArchive, 'getPackagesetsForUploader', IArchivePermission)
-patch_collection_return_type(
-    IArchive, 'getPackagesetsForSourceUploader', IArchivePermission)
-patch_collection_return_type(
-    IArchive, 'getPackagesetsForSource', IArchivePermission)
-patch_collection_return_type(
-    IArchive, 'getUploadersForComponent', IArchivePermission)
-patch_collection_return_type(
-    IArchive, 'getQueueAdminsForComponent', IArchivePermission)
-patch_collection_return_type(
-    IArchive, 'getComponentsForQueueAdmin', IArchivePermission)
-patch_collection_return_type(
-    IArchive, 'getQueueAdminsForPocket', IArchivePermission)
-patch_collection_return_type(
-    IArchive, 'getPocketsForQueueAdmin', IArchivePermission)
-patch_collection_return_type(
-    IArchive, 'getPocketsForUploader', IArchivePermission)
-patch_collection_return_type(
-    IArchive, 'getUploadersForPocket', IArchivePermission)
-patch_entry_return_type(IArchive, 'newPackageUploader', IArchivePermission)
-patch_entry_return_type(IArchive, 'newPackagesetUploader', IArchivePermission)
-patch_entry_return_type(IArchive, 'newComponentUploader', IArchivePermission)
-patch_entry_return_type(IArchive, 'newPocketUploader', IArchivePermission)
-patch_entry_return_type(IArchive, 'newQueueAdmin', IArchivePermission)
-patch_entry_return_type(IArchive, 'newPocketQueueAdmin', IArchivePermission)
-patch_plain_parameter_type(IArchive, 'syncSources', 'from_archive', IArchive)
-patch_plain_parameter_type(IArchive, 'syncSource', 'from_archive', IArchive)
-patch_plain_parameter_type(IArchive, 'copyPackage', 'from_archive', IArchive)
-patch_plain_parameter_type(
-    IArchive, 'copyPackages', 'from_archive', IArchive)
-patch_plain_parameter_type(IArchive, 'uploadCIBuild', 'ci_build', ICIBuild)
-patch_entry_return_type(IArchive, 'newSubscription', IArchiveSubscriber)
-patch_plain_parameter_type(
-    IArchive, 'getArchiveDependency', 'dependency', IArchive)
-patch_entry_return_type(IArchive, 'getArchiveDependency', IArchiveDependency)
-patch_collection_return_type(
-    IArchive, 'api_getPublishedSources', ISourcePackagePublishingHistory)
-patch_plain_parameter_type(
-    IArchive, 'getAllPublishedBinaries', 'distroarchseries',
-    IDistroArchSeries)
-patch_collection_return_type(
-    IArchive, 'getAllPublishedBinaries', IBinaryPackagePublishingHistory)
-patch_plain_parameter_type(
-    IArchive, 'newPackagesetUploader', 'packageset', IPackageset)
-patch_plain_parameter_type(
-    IArchive, 'getUploadersForPackageset', 'packageset', IPackageset)
-patch_plain_parameter_type(
-    IArchive, 'deletePackagesetUploader', 'packageset', IPackageset)
-patch_plain_parameter_type(
-    IArchive, 'removeArchiveDependency', 'dependency', IArchive)
-patch_plain_parameter_type(
-    IArchive, '_addArchiveDependency', 'dependency', IArchive)
-patch_entry_return_type(
-    IArchive, '_addArchiveDependency', IArchiveDependency)
-
-# IArchiveDependency
-patch_reference_property(IArchiveDependency, 'snap_base', ISnapBase)
-
 # IBuildFarmJob
 patch_reference_property(IBuildFarmJob, 'buildqueue_record', IBuildQueue)
 
@@ -299,43 +172,6 @@ patch_reference_property(
 patch_reference_property(
     IDistroSeriesDifferenceComment, 'comment_author', IPerson)
 
-# IDistroArchSeries
-patch_reference_property(IDistroArchSeries, 'main_archive', IArchive)
-patch_plain_parameter_type(
-    IDistroArchSeries, 'setChrootFromBuild', 'livefsbuild', ILiveFSBuild)
-patch_entry_return_type(
-    IDistroArchSeries, 'getSourceFilter', IDistroArchSeriesFilter)
-patch_plain_parameter_type(
-    IDistroArchSeries, 'setSourceFilter', 'packageset', IPackageset)
-
-# ILiveFSFile
-patch_reference_property(ILiveFSFile, 'livefsbuild', ILiveFSBuild)
-
-# ILiveFSView
-patch_entry_return_type(ILiveFSView, 'requestBuild', ILiveFSBuild)
-patch_collection_property(ILiveFSView, 'builds', ILiveFSBuild)
-patch_collection_property(ILiveFSView, 'completed_builds', ILiveFSBuild)
-patch_collection_property(ILiveFSView, 'pending_builds', ILiveFSBuild)
-
-# IPackageset
-patch_collection_return_type(IPackageset, 'setsIncluded', IPackageset)
-patch_collection_return_type(IPackageset, 'setsIncludedBy', IPackageset)
-patch_plain_parameter_type(
-    IPackageset, 'getSourcesSharedBy', 'other_package_set', IPackageset)
-patch_plain_parameter_type(
-    IPackageset, 'getSourcesNotSharedBy', 'other_package_set', IPackageset)
-patch_collection_return_type(IPackageset, 'relatedSets', IPackageset)
-
-# IPackageUpload
-patch_reference_property(IPackageUpload, 'distroseries', IDistroSeries)
-patch_reference_property(IPackageUpload, 'archive', IArchive)
-patch_reference_property(IPackageUpload, 'copy_source_archive', IArchive)
-
-# ISourcePackageRelease
-patch_reference_property(
-    ISourcePackageRelease, 'source_package_recipe_build',
-    ISourcePackageRecipeBuild)
-
 # IIndexedMessage
 patch_reference_property(IIndexedMessage, 'inside', IBugTask)
 
diff --git a/lib/lp/soyuz/interfaces/archive.py b/lib/lp/soyuz/interfaces/archive.py
index d474335..c431bad 100644
--- a/lib/lp/soyuz/interfaces/archive.py
+++ b/lib/lp/soyuz/interfaces/archive.py
@@ -374,7 +374,8 @@ class IArchivePublic(IPrivacy, IHasOwner):
 
     distribution = exported(
         Reference(
-            Interface,  # Redefined to IDistribution later.
+            # Really IDistribution, patched in lp.soyuz.interfaces.webservice.
+            Interface,
             title=_("The distribution that uses or is used by this "
                     "archive.")))
 
@@ -434,8 +435,9 @@ class IArchiveSubscriberView(Interface):
     dependencies = exported(
         CollectionField(
             title=_("Archive dependencies recorded for this archive."),
+            # Really IArchiveDependency, patched in
+            # lp.soyuz.interfaces.webservice.
             value_type=Reference(schema=Interface),
-            # Really IArchiveDependency
             readonly=True))
     description = exported(
         Text(
@@ -528,8 +530,8 @@ class IArchiveSubscriberView(Interface):
                           "descending version and then descending ID."),
             required=False),
         )
-    # Really returns ISourcePackagePublishingHistory, see below for
-    # patch to avoid circular import.
+    # Really ISourcePackagePublishingHistory, patched in
+    # lp.soyuz.interfaces.webservice.
     @operation_returns_collection_of(Interface)
     @export_read_operation()
     @operation_for_version("beta")
@@ -602,7 +604,8 @@ class IArchiveSubscriberView(Interface):
             vocabulary=PackagePublishingStatus,
             required=False),
         distroarchseries=Reference(
-            # Really IDistroArchSeries, circular import fixed below.
+            # Really IDistroArchSeries, patched in
+            # lp.soyuz.interfaces.webservice.
             Interface,
             title=_("Distro Arch Series"), required=False),
         pocket=Choice(
@@ -632,8 +635,8 @@ class IArchiveSubscriberView(Interface):
             required=False),
         component_name=TextLine(title=_("Component name"), required=False),
     )
-    # Really returns IBinaryPackagePublishingHistory, see below for
-    # patch to avoid circular import.
+    # Really IBinaryPackagePublishingHistory, patched in
+    # lp.soyuz.interfaces.webservice.
     @operation_returns_collection_of(Interface)
     @export_operation_as("getPublishedBinaries")
     @export_read_operation()
@@ -1120,14 +1123,12 @@ class IArchiveView(IHasBuildRecords):
         """
 
     @operation_parameters(
-        # Really IPackageset, corrected in _schema_circular_imports to avoid
-        # circular import.
+        # Really IPackageset, patched in lp.soyuz.interfaces.webservice.
         packageset=Reference(
             Interface, title=_("Package set"), required=True),
         direct_permissions=Bool(
             title=_("Ignore package set hierarchy"), required=False))
-    # Really IArchivePermission, set in _schema_circular_imports to avoid
-    # circular import.
+    # Really IArchivePermission, patched in lp.soyuz.interfaces.webservice.
     @operation_returns_collection_of(Interface)
     @export_read_operation()
     @operation_for_version("beta")
@@ -1145,8 +1146,7 @@ class IArchiveView(IHasBuildRecords):
 
     @operation_parameters(
         person=Reference(schema=IPerson))
-    # Really IArchivePermission, set in _schema_circular_imports to avoid
-    # circular import.
+    # Really IArchivePermission, patched in lp.soyuz.interfaces.webservice.
     @operation_returns_collection_of(Interface)
     @export_read_operation()
     @operation_for_version("beta")
@@ -1169,8 +1169,7 @@ class IArchiveView(IHasBuildRecords):
 
     @operation_parameters(
         person=Reference(schema=IPerson))
-    # Really IArchivePermission, set in _schema_circular_imports to avoid
-    # circular import.
+    # Really IArchivePermission, patched in lp.soyuz.interfaces.webservice.
     @operation_returns_collection_of(Interface)
     @export_read_operation()
     @operation_for_version("devel")
@@ -1186,8 +1185,7 @@ class IArchiveView(IHasBuildRecords):
         sourcepackagename=TextLine(
             title=_("Source package name"), required=True),
         person=Reference(schema=IPerson))
-    # Really IArchivePermission, set in _schema_circular_imports to avoid
-    # circular import.
+    # Really IArchivePermission, patched in lp.soyuz.interfaces.webservice.
     @operation_returns_collection_of(Interface)
     @export_read_operation()
     @operation_for_version("beta")
@@ -1217,8 +1215,7 @@ class IArchiveView(IHasBuildRecords):
             title=_("Source package name"), required=True),
         direct_permissions=Bool(
             title=_("Ignore package set hierarchy"), required=False))
-    # Really IArchivePermission, set in _schema_circular_imports to avoid
-    # circular import.
+    # Really IArchivePermission, patched in lp.soyuz.interfaces.webservice.
     @operation_returns_collection_of(Interface)
     @export_read_operation()
     @operation_for_version("beta")
@@ -1348,8 +1345,10 @@ class IArchiveView(IHasBuildRecords):
         """
 
     @operation_parameters(
-        dependency=Reference(schema=Interface))  # Really IArchive. See below.
-    @operation_returns_entry(schema=Interface)  # Really IArchiveDependency.
+        # Really IArchive, patched in lp.soyuz.interfaces.webservice.
+        dependency=Reference(schema=Interface))
+    # Really IArchiveDependency, patched in lp.soyuz.interfaces.webservice.
+    @operation_returns_entry(schema=Interface)
     @export_read_operation()
     @operation_for_version("beta")
     def getArchiveDependency(dependency):
@@ -1361,7 +1360,7 @@ class IArchiveView(IHasBuildRecords):
             could not be found.
         """
 
-    # Really IArchivePermission, set below to avoid circular import.
+    # Really IArchivePermission, patched in lp.soyuz.interfaces.webservice.
     @operation_returns_collection_of(Interface)
     @export_read_operation()
     @operation_for_version("devel")
@@ -1372,7 +1371,7 @@ class IArchiveView(IHasBuildRecords):
         """
 
     @operation_parameters(person=Reference(schema=IPerson))
-    # Really IArchivePermission, set below to avoid circular import.
+    # Really IArchivePermission, patched in lp.soyuz.interfaces.webservice.
     @operation_returns_collection_of(Interface)
     @export_read_operation()
     @operation_for_version("beta")
@@ -1386,7 +1385,7 @@ class IArchiveView(IHasBuildRecords):
     @operation_parameters(
         source_package_name=TextLine(
             title=_("Source Package Name"), required=True))
-    # Really IArchivePermission, set below to avoid circular import.
+    # Really IArchivePermission, patched in lp.soyuz.interfaces.webservice.
     @operation_returns_collection_of(Interface)
     @export_read_operation()
     @operation_for_version("beta")
@@ -1400,7 +1399,7 @@ class IArchiveView(IHasBuildRecords):
 
     @operation_parameters(
         component_name=TextLine(title=_("Component Name"), required=False))
-    # Really IArchivePermission, set below to avoid circular import.
+    # Really IArchivePermission, patched in lp.soyuz.interfaces.webservice.
     @operation_returns_collection_of(Interface)
     @export_read_operation()
     @operation_for_version("beta")
@@ -1414,7 +1413,7 @@ class IArchiveView(IHasBuildRecords):
 
     @operation_parameters(
         component_name=TextLine(title=_("Component Name"), required=True))
-    # Really IArchivePermission, set below to avoid circular import.
+    # Really IArchivePermission, patched in lp.soyuz.interfaces.webservice.
     @operation_returns_collection_of(Interface)
     @export_read_operation()
     @operation_for_version("beta")
@@ -1427,7 +1426,7 @@ class IArchiveView(IHasBuildRecords):
         """
 
     @operation_parameters(person=Reference(schema=IPerson))
-    # Really IArchivePermission, set below to avoid circular import.
+    # Really IArchivePermission, patched in lp.soyuz.interfaces.webservice.
     @operation_returns_collection_of(Interface)
     @export_read_operation()
     @operation_for_version("beta")
@@ -1445,7 +1444,7 @@ class IArchiveView(IHasBuildRecords):
             vocabulary=PackagePublishingPocket,
             required=True),
         )
-    # Really IArchivePermission, set below to avoid circular import.
+    # Really IArchivePermission, patched in lp.soyuz.interfaces.webservice.
     @operation_returns_collection_of(Interface)
     @export_read_operation()
     @operation_for_version("devel")
@@ -1464,7 +1463,7 @@ class IArchiveView(IHasBuildRecords):
         distroseries=Reference(
             IDistroSeries, title=_("Distro series"), required=False),
         )
-    # Really IArchivePermission, set below to avoid circular import.
+    # Really IArchivePermission, patched in lp.soyuz.interfaces.webservice.
     @operation_returns_collection_of(Interface)
     @export_read_operation()
     @operation_for_version("devel")
@@ -1477,7 +1476,7 @@ class IArchiveView(IHasBuildRecords):
         """
 
     @operation_parameters(person=Reference(schema=IPerson))
-    # Really IArchivePermission, set below to avoid circular import.
+    # Really IArchivePermission, patched in lp.soyuz.interfaces.webservice.
     @operation_returns_collection_of(Interface)
     @export_read_operation()
     @operation_for_version("devel")
@@ -1512,8 +1511,8 @@ class IArchiveView(IHasBuildRecords):
     @operation_parameters(
         source_name=TextLine(title=_("Source package name")),
         version=TextLine(title=_("Version")),
+        # Really IArchive, patched in lp.soyuz.interfaces.webservice.
         from_archive=Reference(schema=Interface),
-        # Really IArchive, see below
         to_pocket=TextLine(title=_("Target pocket name")),
         to_series=TextLine(
             title=_("Target distroseries name"), required=False),
@@ -1615,8 +1614,8 @@ class IArchiveView(IHasBuildRecords):
         source_names=List(
             title=_("Source package names"),
             value_type=TextLine()),
+        # Really IArchive, patched in lp.soyuz.interfaces.webservice.
         from_archive=Reference(schema=Interface),
-        #Really IArchive, see below
         to_pocket=TextLine(title=_("Pocket name")),
         to_series=TextLine(
             title=_("Distroseries name"),
@@ -1700,7 +1699,7 @@ class IArchiveView(IHasBuildRecords):
 
     @call_with(person=REQUEST_USER)
     @operation_parameters(
-        # Really ICIBuild, patched in _schema_circular_imports.
+        # Really ICIBuild, patched in lp.soyuz.interfaces.webservice.
         ci_build=Reference(schema=Interface),
         to_series=TextLine(title=_("Target distroseries name")),
         to_pocket=TextLine(title=_("Target pocket name")),
@@ -1719,8 +1718,8 @@ class IArchiveAppend(Interface):
         source_names=List(
             title=_("Source package names"),
             value_type=TextLine()),
+        # Really IArchive, patched in lp.soyuz.interfaces.webservice.
         from_archive=Reference(schema=Interface),
-        #Really IArchive, see below
         to_pocket=TextLine(title=_("Pocket name")),
         to_series=TextLine(
             title=_("Distroseries name"),
@@ -1782,8 +1781,8 @@ class IArchiveAppend(Interface):
     @operation_parameters(
         source_name=TextLine(title=_("Source package name")),
         version=TextLine(title=_("Version")),
+        # Really IArchive, patched in lp.soyuz.interfaces.webservice.
         from_archive=Reference(schema=Interface),
-        # Really IArchive, see below
         to_pocket=TextLine(title=_("Pocket name")),
         to_series=TextLine(title=_("Distroseries name"), required=False),
         include_binaries=Bool(
@@ -1844,7 +1843,7 @@ class IArchiveAppend(Interface):
                 "expire.")),
         description=Text(title=_("Description"), required=False,
             description=_("Free text describing this subscription.")))
-    # Really IArchiveSubscriber, set below to avoid circular import.
+    # Really IArchiveSubscriber, patched in lp.soyuz.interfaces.webservice.
     @export_factory_operation(Interface, [])
     @operation_for_version("beta")
     def newSubscription(subscriber, registrant, date_expires=None,
@@ -1909,7 +1908,7 @@ class IArchiveEdit(Interface):
         person=Reference(schema=IPerson),
         source_package_name=TextLine(
             title=_("Source Package Name"), required=True))
-    # Really IArchivePermission, set below to avoid circular import.
+    # Really IArchivePermission, patched in lp.soyuz.interfaces.webservice.
     @export_factory_operation(Interface, [])
     @operation_for_version("beta")
     def newPackageUploader(person, source_package_name):
@@ -1926,7 +1925,7 @@ class IArchiveEdit(Interface):
         person=Reference(schema=IPerson),
         component_name=TextLine(
             title=_("Component Name"), required=True))
-    # Really IArchivePermission, set below to avoid circular import.
+    # Really IArchivePermission, patched in lp.soyuz.interfaces.webservice.
     @export_factory_operation(Interface, [])
     @operation_for_version("beta")
     def newComponentUploader(person, component_name):
@@ -1947,7 +1946,7 @@ class IArchiveEdit(Interface):
             vocabulary=PackagePublishingPocket,
             required=True),
         )
-    # Really IArchivePermission, set below to avoid circular import.
+    # Really IArchivePermission, patched in lp.soyuz.interfaces.webservice.
     @export_factory_operation(Interface, [])
     @operation_for_version("devel")
     def newPocketUploader(person, pocket):
@@ -1967,7 +1966,7 @@ class IArchiveEdit(Interface):
         person=Reference(schema=IPerson),
         component_name=TextLine(
             title=_("Component Name"), required=True))
-    # Really IArchivePermission, set below to avoid circular import.
+    # Really IArchivePermission, patched in lp.soyuz.interfaces.webservice.
     @export_factory_operation(Interface, [])
     @operation_for_version("beta")
     def newQueueAdmin(person, component_name):
@@ -1991,7 +1990,7 @@ class IArchiveEdit(Interface):
         distroseries=Reference(
             IDistroSeries, title=_("Distro series"), required=True),
         )
-    # Really IArchivePermission, set below to avoid circular import.
+    # Really IArchivePermission, patched in lp.soyuz.interfaces.webservice.
     @export_factory_operation(Interface, [])
     @operation_for_version("devel")
     def newPocketQueueAdmin(person, pocket, distroseries=None):
@@ -2009,14 +2008,12 @@ class IArchiveEdit(Interface):
 
     @operation_parameters(
         person=Reference(schema=IPerson),
-        # Really IPackageset, corrected in _schema_circular_imports to avoid
-        # circular import.
+        # Really IPackageset, patched in lp.soyuz.interfaces.webservice.
         packageset=Reference(
             Interface, title=_("Package set"), required=True),
         explicit=Bool(
             title=_("Explicit"), required=False))
-    # Really IArchivePermission, set in _schema_circular_imports to avoid
-    # circular import.
+    # Really IArchivePermission, patched in lp.soyuz.interfaces.webservice.
     @export_factory_operation(Interface, [])
     @operation_for_version("beta")
     def newPackagesetUploader(person, packageset, explicit=False):
@@ -2115,8 +2112,7 @@ class IArchiveEdit(Interface):
 
     @operation_parameters(
         person=Reference(schema=IPerson),
-        # Really IPackageset, corrected in _schema_circular_imports to avoid
-        # circular import.
+        # Really IPackageset, patched in lp.soyuz.interfaces.webservice.
         packageset=Reference(
             Interface, title=_("Package set"), required=True),
         explicit=Bool(
@@ -2155,7 +2151,7 @@ class IArchiveEdit(Interface):
 
     @operation_parameters(
         dependency=Reference(schema=Interface, required=True),
-        #  Really IArchive
+        # Really IArchive, patched in lp.soyuz.interfaces.webservice.
         pocket=Choice(
             title=_("Pocket"),
             description=_("The pocket into which this entry is published"),
@@ -2164,7 +2160,8 @@ class IArchiveEdit(Interface):
         component=TextLine(title=_("Component"), required=False),
         )
     @export_operation_as('addArchiveDependency')
-    @export_factory_operation(Interface, [])  # Really IArchiveDependency
+    # Really IArchive, patched in lp.soyuz.interfaces.webservice.
+    @export_factory_operation(Interface, [])
     @operation_for_version('devel')
     def _addArchiveDependency(dependency, pocket, component=None):
         """Record an archive dependency record for the context archive.
@@ -2182,8 +2179,8 @@ class IArchiveEdit(Interface):
         """
 
     @operation_parameters(
+        # Really IArchive, patched in lp.soyuz.interfaces.webservice.
         dependency=Reference(schema=Interface, required=True),
-        # Really IArchive
     )
     @export_write_operation()
     @operation_for_version('devel')
@@ -2593,8 +2590,6 @@ FULL_COMPONENT_SUPPORT = (
     ArchivePurpose.COPY,
     )
 
-# Circular dependency issues fixed in _schema_circular_imports.py
-
 
 def validate_external_dependencies(ext_deps):
     """Validate the external_dependencies field.
diff --git a/lib/lp/soyuz/interfaces/archivedependency.py b/lib/lp/soyuz/interfaces/archivedependency.py
index a6653cc..919b57d 100644
--- a/lib/lp/soyuz/interfaces/archivedependency.py
+++ b/lib/lp/soyuz/interfaces/archivedependency.py
@@ -50,7 +50,7 @@ class IArchiveDependency(Interface):
 
     snap_base = exported(
         Reference(
-            # Really ISnapBase, patched in _schema_circular_imports.py.
+            # Really ISnapBase, patched in lp.soyuz.interfaces.webservice.
             schema=Interface, required=False, readonly=True,
             title=_('Target snap base'),
             description=_("The snap base that has this dependency.")))
diff --git a/lib/lp/soyuz/interfaces/buildrecords.py b/lib/lp/soyuz/interfaces/buildrecords.py
index 5c2927a..f21babe 100644
--- a/lib/lp/soyuz/interfaces/buildrecords.py
+++ b/lib/lp/soyuz/interfaces/buildrecords.py
@@ -45,7 +45,7 @@ class IHasBuildRecords(Interface):
             description=_("The pocket into which this entry is published"),
             vocabulary=PackagePublishingPocket))
     @call_with(user=REQUEST_USER, binary_only=True)
-    # Really a IBuild see _schema_circular_imports.
+    # Really IBinaryPackageBuild, patched in lp.soyuz.interfaces.webservice.
     @operation_returns_collection_of(Interface)
     @export_read_operation()
     @operation_for_version('beta')
diff --git a/lib/lp/soyuz/interfaces/distroarchseries.py b/lib/lp/soyuz/interfaces/distroarchseries.py
index 1c3d0f6..b9bc9a3 100644
--- a/lib/lp/soyuz/interfaces/distroarchseries.py
+++ b/lib/lp/soyuz/interfaces/distroarchseries.py
@@ -163,7 +163,8 @@ class IDistroArchSeriesPublic(IHasBuildRecords, IHasOwner):
         exported_as="is_nominated_arch_indep")
     main_archive = exported(
         Reference(
-            Interface,  # Really IArchive, circular import fixed below.
+            # Really IArchive, patched in lp.soyuz.interfaces.webservice.
+            Interface,
             title=_('Main Archive'),
             description=_("The main archive of the distroarchseries.")))
     chroot_url = exported(
@@ -239,7 +240,8 @@ class IDistroArchSeriesPublic(IHasBuildRecords, IHasOwner):
         this distro arch series.
         """
 
-    # Really IDistroArchSeriesFilter, patched in _schema_circular_imports.py.
+    # Really IDistroArchSeriesFilter, patched in
+    # lp.soyuz.interfaces.webservice.
     @operation_returns_entry(Interface)
     @export_read_operation()
     @operation_for_version("devel")
@@ -277,7 +279,7 @@ class IDistroArchSeriesModerate(Interface):
         """
 
     @operation_parameters(
-        # Really ILiveFSBuild, patched in _schema_circular_imports.py.
+        # Really ILiveFSBuild, patched in lp.soyuz.interfaces.webservice.
         livefsbuild=Reference(
             Interface, title=_("Live filesystem build"), required=True),
         filename=TextLine(title=_("Filename"), required=True),
@@ -306,7 +308,7 @@ class IDistroArchSeriesModerate(Interface):
         """
 
     @operation_parameters(
-        # Really IPackageset, patched in _schema_circular_imports.py.
+        # Really IPackageset, patched in lp.soyuz.interfaces.webservice.
         packageset=Reference(Interface, title=_("Package set"), required=True),
         sense=Choice(
             vocabulary=DistroArchSeriesFilterSense,
diff --git a/lib/lp/soyuz/interfaces/livefs.py b/lib/lp/soyuz/interfaces/livefs.py
index db7f795..60e0c3b 100644
--- a/lib/lp/soyuz/interfaces/livefs.py
+++ b/lib/lp/soyuz/interfaces/livefs.py
@@ -167,7 +167,7 @@ class ILiveFSView(IPrivacy):
             title=_("A dict of data about the image."),
             key_type=TextLine(), required=False),
         version=TextLine(title=_("A version string for this build.")))
-    # Really ILiveFSBuild, patched in _schema_circular_imports.py.
+    # Really ILiveFSBuild, patched in lp.soyuz.interfaces.webservice.
     @export_factory_operation(Interface, [])
     @operation_for_version("devel")
     def requestBuild(requester, archive, distro_arch_series, pocket,
@@ -194,7 +194,7 @@ class ILiveFSView(IPrivacy):
         description=_(
             "All builds of this live filesystem, sorted in descending order "
             "of finishing (or starting if not completed successfully)."),
-        # Really ILiveFSBuild, patched in _schema_circular_imports.py.
+        # Really ILiveFSBuild, patched in lp.soyuz.interfaces.webservice.
         value_type=Reference(schema=Interface), readonly=True)))
 
     completed_builds = exported(doNotSnapshot(CollectionField(
@@ -202,7 +202,7 @@ class ILiveFSView(IPrivacy):
         description=_(
             "Completed builds of this live filesystem, sorted in descending "
             "order of finishing."),
-        # Really ILiveFSBuild, patched in _schema_circular_imports.py.
+        # Really ILiveFSBuild, patched in lp.soyuz.interfaces.webservice.
         value_type=Reference(schema=Interface), readonly=True)))
 
     pending_builds = exported(doNotSnapshot(CollectionField(
@@ -210,7 +210,7 @@ class ILiveFSView(IPrivacy):
         description=_(
             "Pending builds of this live filesystem, sorted in descending "
             "order of creation."),
-        # Really ILiveFSBuild, patched in _schema_circular_imports.py.
+        # Really ILiveFSBuild, patched in lp.soyuz.interfaces.webservice.
         value_type=Reference(schema=Interface), readonly=True)))
 
 
diff --git a/lib/lp/soyuz/interfaces/livefsbuild.py b/lib/lp/soyuz/interfaces/livefsbuild.py
index 5ed7098..fbfeb5b 100644
--- a/lib/lp/soyuz/interfaces/livefsbuild.py
+++ b/lib/lp/soyuz/interfaces/livefsbuild.py
@@ -40,6 +40,7 @@ from lp.registry.interfaces.person import IPerson
 from lp.registry.interfaces.pocket import PackagePublishingPocket
 from lp.services.database.constants import DEFAULT
 from lp.services.librarian.interfaces import ILibraryFileAlias
+from lp.services.webservice.apihelpers import patch_reference_property
 from lp.soyuz.interfaces.archive import IArchive
 from lp.soyuz.interfaces.distroarchseries import IDistroArchSeries
 from lp.soyuz.interfaces.livefs import ILiveFS
@@ -49,7 +50,7 @@ class ILiveFSFile(Interface):
     """A file produced by a live filesystem build."""
 
     livefsbuild = Reference(
-        # Really ILiveFSBuild, patched in _schema_circular_imports.py.
+        # Really ILiveFSBuild, patched below.
         Interface,
         title=_("The live filesystem build producing this file."),
         required=True, readonly=True)
@@ -170,3 +171,6 @@ class ILiveFSBuildSet(ISpecificBuildFarmJobSource):
             unique_key=None, metadata_override=None, version=None,
             date_created=DEFAULT):
         """Create an `ILiveFSBuild`."""
+
+
+patch_reference_property(ILiveFSFile, "livefsbuild", ILiveFSBuild)
diff --git a/lib/lp/soyuz/interfaces/packageset.py b/lib/lp/soyuz/interfaces/packageset.py
index 61ec541..74f796c 100644
--- a/lib/lp/soyuz/interfaces/packageset.py
+++ b/lib/lp/soyuz/interfaces/packageset.py
@@ -44,6 +44,10 @@ from lp.app.validators.name import name_validator
 from lp.registry.interfaces.distroseries import IDistroSeries
 from lp.registry.interfaces.person import IPerson
 from lp.registry.interfaces.role import IHasOwner
+from lp.services.webservice.apihelpers import (
+    patch_collection_return_type,
+    patch_plain_parameter_type,
+    )
 from lp.soyuz.interfaces.packagesetgroup import IPackagesetGroup
 
 
@@ -105,6 +109,7 @@ class IPackagesetViewOnly(IHasOwner):
 
     @operation_parameters(
         direct_inclusion=Bool(required=False))
+    # Really IPackageset, patched below.
     @operation_returns_collection_of(Interface)
     @export_read_operation()
     @operation_for_version("beta")
@@ -120,6 +125,7 @@ class IPackagesetViewOnly(IHasOwner):
 
     @operation_parameters(
         direct_inclusion=Bool(required=False))
+    # Really IPackageset, patched below.
     @operation_returns_collection_of(Interface)
     @export_read_operation()
     @operation_for_version("beta")
@@ -194,6 +200,7 @@ class IPackagesetViewOnly(IHasOwner):
 
     @operation_parameters(
         other_package_set=Reference(
+            # Really IPackageset, patched below.
             Interface,
             title=_('The package set we are comparing to.'), required=True),
         direct_inclusion=Bool(required=False))
@@ -219,6 +226,7 @@ class IPackagesetViewOnly(IHasOwner):
 
     @operation_parameters(
         other_package_set=Reference(
+            # Really IPackageset, patched below.
             Interface,
             title=_('The package set we are comparing to.'), required=True),
         direct_inclusion=Bool(required=False))
@@ -242,6 +250,7 @@ class IPackagesetViewOnly(IHasOwner):
             names.
         """
 
+    # Really IPackageset, patched below.
     @operation_returns_collection_of(Interface)
     @export_read_operation()
     @operation_for_version("beta")
@@ -511,3 +520,12 @@ class IPackagesetSet(IPackagesetSetEdit):
             name cannot be found.
         :return: A (potentially empty) sequence of `IPackageset` instances.
         """
+
+
+patch_collection_return_type(IPackageset, 'setsIncluded', IPackageset)
+patch_collection_return_type(IPackageset, 'setsIncludedBy', IPackageset)
+patch_plain_parameter_type(
+    IPackageset, 'getSourcesSharedBy', 'other_package_set', IPackageset)
+patch_plain_parameter_type(
+    IPackageset, 'getSourcesNotSharedBy', 'other_package_set', IPackageset)
+patch_collection_return_type(IPackageset, 'relatedSets', IPackageset)
diff --git a/lib/lp/soyuz/interfaces/publishing.py b/lib/lp/soyuz/interfaces/publishing.py
index 9561f6b..0597a6c 100644
--- a/lib/lp/soyuz/interfaces/publishing.py
+++ b/lib/lp/soyuz/interfaces/publishing.py
@@ -281,13 +281,13 @@ class ISourcePackagePublishingHistoryPublic(IPublishingView):
             "(only for archives published using Artifactory)"))
     archive = exported(
         Reference(
-            # Really IArchive (fixed in _schema_circular_imports.py).
+            # Really IArchive, patched in lp.soyuz.interfaces.webservice.
             Interface,
             title=_('Archive ID'), required=True, readonly=True,
             ))
     copied_from_archive = exported(
         Reference(
-            # Really IArchive (fixed in _schema_circular_imports.py).
+            # Really IArchive, patched in lp.soyuz.interfaces.webservice.
             Interface,
             title=_('Original archive ID where this package was copied from.'),
             required=False, readonly=True,
@@ -380,8 +380,8 @@ class ISourcePackagePublishingHistoryPublic(IPublishingView):
         "if one exists, or None.")
 
     ancestor = Reference(
-         # Really ISourcePackagePublishingHistory (fixed in
-         # _schema_circular_imports.py).
+         # Really ISourcePackagePublishingHistory, patched in
+         # lp.soyuz.interfaces.webservice.
         Interface,
         title=_('Ancestor'),
         description=_('The previous release of this source package.'),
@@ -408,7 +408,7 @@ class ISourcePackagePublishingHistoryPublic(IPublishingView):
 
     packageupload = exported(
         Reference(
-            # Really IPackageUpload, fixed in _schema_circular_imports.
+            # Really IPackageUpload, patched in lp.soyuz.interfaces.webservice.
             Interface,
             title=_('Package upload'),
             description=_('The Package Upload that caused the creation of '
@@ -419,7 +419,8 @@ class ISourcePackagePublishingHistoryPublic(IPublishingView):
     @operation_parameters(
         active_binaries_only=Bool(
             title=_("Only return active publications"), required=False))
-    # Really IBinaryPackagePublishingHistory, see below.
+    # Really IBinaryPackagePublishingHistory, patched in
+    # lp.soyuz.interfaces.webservice.
     @operation_returns_collection_of(Interface)
     @export_read_operation()
     @operation_for_version("beta")
@@ -456,7 +457,7 @@ class ISourcePackagePublishingHistoryPublic(IPublishingView):
     def hasRestrictedFiles():
         """Return whether or not a given source files has restricted files."""
 
-    # Really IBuild (fixed in _schema_circular_imports.py)
+    # Really IBinaryPackageBuild, patched in lp.soyuz.interfaces.webservice.
     @operation_returns_collection_of(Interface)
     @export_read_operation()
     @operation_for_version("beta")
@@ -595,7 +596,7 @@ class ISourcePackagePublishingHistoryEdit(IPublishingEdit):
     """A writeable source package publishing history record."""
 
     # Really ISourcePackagePublishingHistory, patched in
-    # _schema_circular_imports.py.
+    # lp.soyuz.interfaces.webservice.
     @operation_returns_entry(Interface)
     @operation_parameters(
         new_component=TextLine(title="The new component name."),
@@ -660,8 +661,8 @@ class IBinaryPackagePublishingHistoryPublic(IPublishingView):
         required=False, readonly=False)
     distroarchseries = exported(
         Reference(
-            # Really IDistroArchSeries (fixed in
-            #_schema_circular_imports.py).
+            # Really IDistroArchSeries, patched in
+            # lp.soyuz.interfaces.webservice.
             Interface,
             title=_("Distro Arch Series"),
             description=_('The distroarchseries being published into'),
@@ -766,7 +767,7 @@ class IBinaryPackagePublishingHistoryPublic(IPublishingView):
         exported_as="date_removed")
     archive = exported(
         Reference(
-            # Really IArchive (fixed in _schema_circular_imports.py).
+            # Really IArchive, patched in lp.soyuz.interfaces.webservice.
             Interface,
             title=_('Archive'),
             description=_("The context archive for this publication."),
@@ -774,7 +775,7 @@ class IBinaryPackagePublishingHistoryPublic(IPublishingView):
             ))
     copied_from_archive = exported(
         Reference(
-            # Really IArchive (fixed in _schema_circular_imports.py).
+            # Really IArchive, patched in lp.soyuz.interfaces.webservice.
             Interface,
             title=_('Original archive ID where this package was copied from.'),
             required=False, readonly=True,
@@ -806,7 +807,8 @@ class IBinaryPackagePublishingHistoryPublic(IPublishingView):
             required=False, readonly=True))
     build = exported(
         Reference(
-            # Really IBinaryPackageBuild, fixed in _schema_circular_imports.
+            # Really IBinaryPackageBuild, fixed in
+            # lp.soyuz.interfaces.webservice.
             Interface,
             title=_("Build"),
             description=_("The build that produced this binary package."),
@@ -906,7 +908,7 @@ class IBinaryPackagePublishingHistoryEdit(IPublishingEdit):
     """A writeable binary package publishing record."""
 
     # Really IBinaryPackagePublishingHistory, patched in
-    # _schema_circular_imports.py.
+    # lp.soyuz.interfaces.webservice.
     @operation_returns_entry(Interface)
     @operation_parameters(
         new_component=TextLine(title="The new component name."),
@@ -1304,6 +1306,3 @@ inactive_publishing_status = (
     PackagePublishingStatus.DELETED,
     PackagePublishingStatus.OBSOLETE,
     )
-
-
-# Circular import problems fixed in _schema_circular_imports.py
diff --git a/lib/lp/soyuz/interfaces/queue.py b/lib/lp/soyuz/interfaces/queue.py
index 6f81095..87fbc35 100644
--- a/lib/lp/soyuz/interfaces/queue.py
+++ b/lib/lp/soyuz/interfaces/queue.py
@@ -171,8 +171,7 @@ class IPackageUpload(Interface):
 
     distroseries = exported(
         Reference(
-            # Really IDistroSeries, patched in
-            # _schema_circular_imports.py
+            # Really IDistroSeries, patched in lp.soyuz.interfaces.webservice.
             schema=Interface,
             description=_("The distroseries targeted by this upload."),
             title=_("Series"), required=True, readonly=False,
@@ -215,7 +214,7 @@ class IPackageUpload(Interface):
 
     archive = exported(
         Reference(
-            # Really IArchive, patched in _schema_circular_imports.py
+            # Really IArchive, patched in lp.soyuz.interfaces.webservice.
             schema=Interface,
             description=_("The archive for this upload."),
             title=_("Archive"), required=True, readonly=True))
@@ -244,7 +243,7 @@ class IPackageUpload(Interface):
 
     copy_source_archive = exported(
         Reference(
-            # Really IArchive, patched in _schema_circular_imports.py
+            # Really IArchive, patched in lp.soyuz.interfaces.webservice.
             schema=Interface,
             description=_("The archive from which this package was copied, if "
                           "any."),
diff --git a/lib/lp/soyuz/interfaces/sourcepackagerelease.py b/lib/lp/soyuz/interfaces/sourcepackagerelease.py
index 8e6cee9..5ede861 100644
--- a/lib/lp/soyuz/interfaces/sourcepackagerelease.py
+++ b/lib/lp/soyuz/interfaces/sourcepackagerelease.py
@@ -142,7 +142,8 @@ class ISourcePackageRelease(Interface):
     uploader = Attribute(
         "The user who uploaded the package.")
 
-    # Really ISourcePackageRecipeBuild -- see _schema_circular_imports.
+    # Really ISourcePackageRecipeBuild, patched in
+    # lp.soyuz.interfaces.webservice.
     source_package_recipe_build = Reference(
         schema=Interface,
         description=_("The `SourcePackageRecipeBuild` which produced this "
diff --git a/lib/lp/soyuz/interfaces/webservice.py b/lib/lp/soyuz/interfaces/webservice.py
index b8ecec2..4e893db 100644
--- a/lib/lp/soyuz/interfaces/webservice.py
+++ b/lib/lp/soyuz/interfaces/webservice.py
@@ -51,9 +51,20 @@ __all__ = [
     'VersionRequiresName',
     ]
 
-# XXX: JonathanLange 2010-11-09 bug=673083: Legacy work-around for circular
-# import bugs.  Break this up into a per-package thing.
-from lp import _schema_circular_imports
+from lp.code.interfaces.cibuild import ICIBuild
+from lp.code.interfaces.sourcepackagerecipebuild import (
+    ISourcePackageRecipeBuild,
+    )
+from lp.registry.interfaces.distribution import IDistribution
+from lp.registry.interfaces.distroseries import IDistroSeries
+from lp.services.webservice.apihelpers import (
+    patch_collection_property,
+    patch_collection_return_type,
+    patch_entry_return_type,
+    patch_plain_parameter_type,
+    patch_reference_property,
+    )
+from lp.snappy.interfaces.snapbase import ISnapBase
 from lp.soyuz.interfaces.archive import (
     AlreadySubscribed,
     ArchiveDisabled,
@@ -84,11 +95,13 @@ from lp.soyuz.interfaces.binarypackagebuild import IBinaryPackageBuild
 from lp.soyuz.interfaces.binarypackagerelease import (
     IBinaryPackageReleaseDownloadCount,
     )
+from lp.soyuz.interfaces.buildrecords import IHasBuildRecords
 from lp.soyuz.interfaces.distroarchseries import IDistroArchSeries
 from lp.soyuz.interfaces.distroarchseriesfilter import IDistroArchSeriesFilter
 from lp.soyuz.interfaces.livefs import (
     ILiveFS,
     ILiveFSSet,
+    ILiveFSView,
     )
 from lp.soyuz.interfaces.livefsbuild import ILiveFSBuild
 from lp.soyuz.interfaces.packageset import (
@@ -99,12 +112,145 @@ from lp.soyuz.interfaces.packageset import (
     )
 from lp.soyuz.interfaces.publishing import (
     IBinaryPackagePublishingHistory,
+    IBinaryPackagePublishingHistoryEdit,
     ISourcePackagePublishingHistory,
+    ISourcePackagePublishingHistoryEdit,
+    ISourcePackagePublishingHistoryPublic,
     )
 from lp.soyuz.interfaces.queue import (
     IPackageUpload,
     IPackageUploadLog,
     )
+from lp.soyuz.interfaces.sourcepackagerelease import ISourcePackageRelease
+
+
+# IArchive
+patch_reference_property(IArchive, 'distribution', IDistribution)
+patch_collection_property(IArchive, 'dependencies', IArchiveDependency)
+patch_collection_return_type(IArchive, 'getAllPermissions', IArchivePermission)
+patch_collection_return_type(
+    IArchive, 'getPermissionsForPerson', IArchivePermission)
+patch_collection_return_type(
+    IArchive, 'getUploadersForPackage', IArchivePermission)
+patch_collection_return_type(
+    IArchive, 'getUploadersForPackageset', IArchivePermission)
+patch_collection_return_type(
+    IArchive, 'getPackagesetsForUploader', IArchivePermission)
+patch_collection_return_type(
+    IArchive, 'getPackagesetsForSourceUploader', IArchivePermission)
+patch_collection_return_type(
+    IArchive, 'getPackagesetsForSource', IArchivePermission)
+patch_collection_return_type(
+    IArchive, 'getUploadersForComponent', IArchivePermission)
+patch_collection_return_type(
+    IArchive, 'getQueueAdminsForComponent', IArchivePermission)
+patch_collection_return_type(
+    IArchive, 'getComponentsForQueueAdmin', IArchivePermission)
+patch_collection_return_type(
+    IArchive, 'getQueueAdminsForPocket', IArchivePermission)
+patch_collection_return_type(
+    IArchive, 'getPocketsForQueueAdmin', IArchivePermission)
+patch_collection_return_type(
+    IArchive, 'getPocketsForUploader', IArchivePermission)
+patch_collection_return_type(
+    IArchive, 'getUploadersForPocket', IArchivePermission)
+patch_entry_return_type(IArchive, 'newPackageUploader', IArchivePermission)
+patch_entry_return_type(IArchive, 'newPackagesetUploader', IArchivePermission)
+patch_entry_return_type(IArchive, 'newComponentUploader', IArchivePermission)
+patch_entry_return_type(IArchive, 'newPocketUploader', IArchivePermission)
+patch_entry_return_type(IArchive, 'newQueueAdmin', IArchivePermission)
+patch_entry_return_type(IArchive, 'newPocketQueueAdmin', IArchivePermission)
+patch_plain_parameter_type(IArchive, 'syncSources', 'from_archive', IArchive)
+patch_plain_parameter_type(IArchive, 'syncSource', 'from_archive', IArchive)
+patch_plain_parameter_type(IArchive, 'copyPackage', 'from_archive', IArchive)
+patch_plain_parameter_type(
+    IArchive, 'copyPackages', 'from_archive', IArchive)
+patch_plain_parameter_type(IArchive, 'uploadCIBuild', 'ci_build', ICIBuild)
+patch_entry_return_type(IArchive, 'newSubscription', IArchiveSubscriber)
+patch_plain_parameter_type(
+    IArchive, 'getArchiveDependency', 'dependency', IArchive)
+patch_entry_return_type(IArchive, 'getArchiveDependency', IArchiveDependency)
+patch_collection_return_type(
+    IArchive, 'api_getPublishedSources', ISourcePackagePublishingHistory)
+patch_plain_parameter_type(
+    IArchive, 'getAllPublishedBinaries', 'distroarchseries',
+    IDistroArchSeries)
+patch_collection_return_type(
+    IArchive, 'getAllPublishedBinaries', IBinaryPackagePublishingHistory)
+patch_plain_parameter_type(
+    IArchive, 'newPackagesetUploader', 'packageset', IPackageset)
+patch_plain_parameter_type(
+    IArchive, 'getUploadersForPackageset', 'packageset', IPackageset)
+patch_plain_parameter_type(
+    IArchive, 'deletePackagesetUploader', 'packageset', IPackageset)
+patch_plain_parameter_type(
+    IArchive, 'removeArchiveDependency', 'dependency', IArchive)
+patch_plain_parameter_type(
+    IArchive, '_addArchiveDependency', 'dependency', IArchive)
+patch_entry_return_type(
+    IArchive, '_addArchiveDependency', IArchiveDependency)
+
+# IArchiveDependency
+patch_reference_property(IArchiveDependency, 'snap_base', ISnapBase)
+
+# IBinaryPackagePublishingHistory
+patch_reference_property(
+    IBinaryPackagePublishingHistory, 'distroarchseries',
+    IDistroArchSeries)
+patch_reference_property(
+    IBinaryPackagePublishingHistory, 'build', IBinaryPackageBuild)
+patch_reference_property(
+    IBinaryPackagePublishingHistory, 'archive', IArchive)
+patch_reference_property(
+    IBinaryPackagePublishingHistory, 'copied_from_archive', IArchive)
+patch_entry_return_type(
+    IBinaryPackagePublishingHistoryEdit, 'changeOverride',
+    IBinaryPackagePublishingHistory)
+
+# IDistroArchSeries
+patch_reference_property(IDistroArchSeries, 'main_archive', IArchive)
+patch_plain_parameter_type(
+    IDistroArchSeries, 'setChrootFromBuild', 'livefsbuild', ILiveFSBuild)
+patch_entry_return_type(
+    IDistroArchSeries, 'getSourceFilter', IDistroArchSeriesFilter)
+patch_plain_parameter_type(
+    IDistroArchSeries, 'setSourceFilter', 'packageset', IPackageset)
+
+# IHasBuildRecords
+patch_collection_return_type(
+    IHasBuildRecords, 'getBuildRecords', IBinaryPackageBuild)
+
+# ILiveFSView
+patch_entry_return_type(ILiveFSView, 'requestBuild', ILiveFSBuild)
+patch_collection_property(ILiveFSView, 'builds', ILiveFSBuild)
+patch_collection_property(ILiveFSView, 'completed_builds', ILiveFSBuild)
+patch_collection_property(ILiveFSView, 'pending_builds', ILiveFSBuild)
+
+# IPackageUpload
+patch_reference_property(IPackageUpload, 'distroseries', IDistroSeries)
+patch_reference_property(IPackageUpload, 'archive', IArchive)
+patch_reference_property(IPackageUpload, 'copy_source_archive', IArchive)
 
+# ISourcePackagePublishingHistory
+patch_collection_return_type(
+    ISourcePackagePublishingHistoryPublic, 'getBuilds', IBinaryPackageBuild)
+patch_collection_return_type(
+    ISourcePackagePublishingHistoryPublic, 'getPublishedBinaries',
+    IBinaryPackagePublishingHistory)
+patch_reference_property(
+    ISourcePackagePublishingHistory, 'archive', IArchive)
+patch_reference_property(
+    ISourcePackagePublishingHistory, 'copied_from_archive', IArchive)
+patch_reference_property(
+    ISourcePackagePublishingHistory, 'ancestor',
+    ISourcePackagePublishingHistory)
+patch_reference_property(
+    ISourcePackagePublishingHistory, 'packageupload', IPackageUpload)
+patch_entry_return_type(
+    ISourcePackagePublishingHistoryEdit, 'changeOverride',
+    ISourcePackagePublishingHistory)
 
-_schema_circular_imports
+# ISourcePackageRelease
+patch_reference_property(
+    ISourcePackageRelease, 'source_package_recipe_build',
+    ISourcePackageRecipeBuild)

Follow ups