@Override
    public ClusterStateBundle decode(EncodedClusterStateBundle encodedClusterStateBundle) {
        byte[] uncompressed = compressor.decompress(encodedClusterStateBundle.getCompression());
        Slime slime = BinaryFormat.decode(uncompressed);
        Inspector root = slime.get();
        Inspector states = root.field("states");
        ClusterState baseline = ClusterState.stateFromString(states.field("baseline").asString());

        Inspector spaces = states.field("spaces");
        Map<String, AnnotatedClusterState> derivedStates = new HashMap<>();
        spaces.traverse(((ObjectTraverser)(key, value) -> {
            derivedStates.put(key, AnnotatedClusterState.withoutAnnotations(ClusterState.stateFromString(value.asString())));
        }));
        boolean deferredActivation = root.field("deferred-activation").asBool(); // defaults to false if not present

        ClusterStateBundle.FeedBlock feedBlock = null;
        Inspector fb = root.field("feed-block");
        if (fb.valid() && fb.field("block-feed-in-cluster").asBool()) {
            feedBlock = ClusterStateBundle.FeedBlock.blockedWithDescription(fb.field("description").asString());
        }

        DistributionConfigBundle distributionConfig = null;
        Inspector dc = root.field("distribution-config");
        if (dc.valid()) {
            // ConfigPayload works on full Slime objects and not Inspectors, so we have to copy out
            // the subtree prior to decode. This is not code used in a hot path, so this should be fine.
            Slime cfgSlime = new Slime();
            SlimeUtils.copyObject(dc, cfgSlime.setObject());
            // TODO toInstance transitively invokes reflection which _mutates_ field access attributes,
            //  toggling `accessible` on and off. Sounds like an inherent latent race condition...
            distributionConfig = DistributionConfigBundle.of(
                    new ConfigPayload(cfgSlime).toInstance(StorDistributionConfig.class, null));
        }

        return ClusterStateBundle.of(AnnotatedClusterState.withoutAnnotations(baseline), derivedStates,
                                     feedBlock, distributionConfig, deferredActivation);
    }
Implementation of ClusterStateBundleCodec which uses structured Slime binary encoding
to implement (de-)serialization of ClusterStateBundle instances. Encoding format is
intentionally extensible so that we may add other information to it later.

LZ4 compression is transparently applied during encoding and decompression is
subsequently applied during decoding.

Implements optional Slime-based enveloping for *WithEnvelope methods, which removes
need to explicitly track compression metadata by the caller.
clustercontroller-core/src/main/java/com/yahoo/vespa/clustercontroller/core/rpc/SlimeClusterStateBundleCodec.java