1*9e94795aSAndroid Build Coastguard Worker// Copyright 2021 Google LLC 2*9e94795aSAndroid Build Coastguard Worker// 3*9e94795aSAndroid Build Coastguard Worker// Licensed under the Apache License, Version 2.0 (the "License"); 4*9e94795aSAndroid Build Coastguard Worker// you may not use this file except in compliance with the License. 5*9e94795aSAndroid Build Coastguard Worker// You may obtain a copy of the License at 6*9e94795aSAndroid Build Coastguard Worker// 7*9e94795aSAndroid Build Coastguard Worker// http://www.apache.org/licenses/LICENSE-2.0 8*9e94795aSAndroid Build Coastguard Worker// 9*9e94795aSAndroid Build Coastguard Worker// Unless required by applicable law or agreed to in writing, software 10*9e94795aSAndroid Build Coastguard Worker// distributed under the License is distributed on an "AS IS" BASIS, 11*9e94795aSAndroid Build Coastguard Worker// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12*9e94795aSAndroid Build Coastguard Worker// See the License for the specific language governing permissions and 13*9e94795aSAndroid Build Coastguard Worker// limitations under the License. 14*9e94795aSAndroid Build Coastguard Worker 15*9e94795aSAndroid Build Coastguard Worker// Much of this content appears too in README.md 16*9e94795aSAndroid Build Coastguard Worker// When changing this file consider whether the change also applies to README.md 17*9e94795aSAndroid Build Coastguard Worker 18*9e94795aSAndroid Build Coastguard Worker/* 19*9e94795aSAndroid Build Coastguard Worker 20*9e94795aSAndroid Build Coastguard WorkerPackage compliance provides an approved means for reading, consuming, and 21*9e94795aSAndroid Build Coastguard Workeranalyzing license metadata graphs. 22*9e94795aSAndroid Build Coastguard Worker 23*9e94795aSAndroid Build Coastguard WorkerAssuming the license metadata and dependencies are fully and accurately 24*9e94795aSAndroid Build Coastguard Workerrecorded in the build system, any discrepancy between the official policy for 25*9e94795aSAndroid Build Coastguard Workeropen source license compliance and this code is a bug in this code. 26*9e94795aSAndroid Build Coastguard Worker 27*9e94795aSAndroid Build Coastguard WorkerA few principal types to understand are LicenseGraph, LicenseCondition, and 28*9e94795aSAndroid Build Coastguard WorkerResolutionSet. 29*9e94795aSAndroid Build Coastguard Worker 30*9e94795aSAndroid Build Coastguard WorkerLicenseGraph 31*9e94795aSAndroid Build Coastguard Worker------------ 32*9e94795aSAndroid Build Coastguard Worker 33*9e94795aSAndroid Build Coastguard WorkerA LicenseGraph is an immutable graph of the targets and dependencies reachable 34*9e94795aSAndroid Build Coastguard Workerfrom a specific set of root targets. In general, the root targets will be the 35*9e94795aSAndroid Build Coastguard Workerartifacts in a release or distribution. While conceptually immutable, parts of 36*9e94795aSAndroid Build Coastguard Workerthe graph may be loaded or evaluated lazily. 37*9e94795aSAndroid Build Coastguard Worker 38*9e94795aSAndroid Build Coastguard WorkerConceptually, the graph itself will always be a directed acyclic graph. One 39*9e94795aSAndroid Build Coastguard Workerrepresentation is a set of directed edges. Another is a set of nodes with 40*9e94795aSAndroid Build Coastguard Workerdirected edges to their dependencies. 41*9e94795aSAndroid Build Coastguard Worker 42*9e94795aSAndroid Build Coastguard WorkerThe edges have annotations, which can distinguish between build tools, runtime 43*9e94795aSAndroid Build Coastguard Workerdependencies, and dependencies like 'contains' that make a derivative work. 44*9e94795aSAndroid Build Coastguard Worker 45*9e94795aSAndroid Build Coastguard WorkerLicenseCondition 46*9e94795aSAndroid Build Coastguard Worker---------------- 47*9e94795aSAndroid Build Coastguard Worker 48*9e94795aSAndroid Build Coastguard WorkerA LicenseCondition is an immutable tuple pairing a condition name with an 49*9e94795aSAndroid Build Coastguard Workeroriginating target. e.g. Per current policy, a static library licensed under an 50*9e94795aSAndroid Build Coastguard WorkerMIT license would pair a "notice" condition with the static library target, and 51*9e94795aSAndroid Build Coastguard Workera dynamic license licensed under GPL would pair a "restricted" condition with 52*9e94795aSAndroid Build Coastguard Workerthe dynamic library target. 53*9e94795aSAndroid Build Coastguard Worker 54*9e94795aSAndroid Build Coastguard WorkerResolutionSet 55*9e94795aSAndroid Build Coastguard Worker------------- 56*9e94795aSAndroid Build Coastguard Worker 57*9e94795aSAndroid Build Coastguard WorkerA ResolutionSet is an immutable set of `AttachesTo`, `ActsOn`, `Resolves` 58*9e94795aSAndroid Build Coastguard Workertuples describing how license conditions apply to targets. 59*9e94795aSAndroid Build Coastguard Worker 60*9e94795aSAndroid Build Coastguard Worker`AttachesTo` is the trigger for acting. Distribution of the target invokes 61*9e94795aSAndroid Build Coastguard Workerthe policy. 62*9e94795aSAndroid Build Coastguard Worker 63*9e94795aSAndroid Build Coastguard Worker`ActsOn` is the target to share, give notice for, hide etc. 64*9e94795aSAndroid Build Coastguard Worker 65*9e94795aSAndroid Build Coastguard Worker`Resolves` is the set of condition types that the action resolves. 66*9e94795aSAndroid Build Coastguard Worker 67*9e94795aSAndroid Build Coastguard WorkerFor most condition types, `ActsOn` will be the target where the condition 68*9e94795aSAndroid Build Coastguard Workeroriginated. For example, a notice condition policy means attribution or notice 69*9e94795aSAndroid Build Coastguard Workermust be given for the target where the condition originates. Likewise, a 70*9e94795aSAndroid Build Coastguard Workerproprietary condition policy means the privacy of the target where the 71*9e94795aSAndroid Build Coastguard Workercondition originates must be respected. i.e. The thing acted on is the origin. 72*9e94795aSAndroid Build Coastguard Worker 73*9e94795aSAndroid Build Coastguard WorkerRestricted conditions are different. The infectious nature of restricted often 74*9e94795aSAndroid Build Coastguard Workermeans sharing code that is not the target where the restricted condition 75*9e94795aSAndroid Build Coastguard Workeroriginates. Linking an MIT library to a GPL library implies a policy to share 76*9e94795aSAndroid Build Coastguard Workerthe MIT library despite the MIT license having no source sharing requirement. 77*9e94795aSAndroid Build Coastguard Worker 78*9e94795aSAndroid Build Coastguard WorkerIn this case, one or more resolution tuples will have the MIT license module in 79*9e94795aSAndroid Build Coastguard Worker`ActsOn` and the restricted condition originating at the GPL library module in 80*9e94795aSAndroid Build Coastguard Worker`Resolves`. These tuples will `AttachTo` every target that depends on the GPL 81*9e94795aSAndroid Build Coastguard Workerlibrary because shipping any of those targets trigger the policy to share the 82*9e94795aSAndroid Build Coastguard Workercode. 83*9e94795aSAndroid Build Coastguard Worker*/ 84*9e94795aSAndroid Build Coastguard Workerpackage compliance 85