foley.licensing#
License policy for foley: the license_id -> flag-set SSOT, flag derivation
(with per-source overrides), and the fail-closed candidate keep() gate.
Stdlib-only (imports only foley.base). The dependency direction is one-way:
licensing -> base.
The two operational vs copyright flags are DISTINCT and must not be conflated:
redistribute_standalone_okis a COPYRIGHT question (may the raw file be re-exposed standalone?).
cache_bytes_okis a TOS/OPERATIONAL question (may foley persist the bytes at all?).
E.g. Freesound CC0 is legally redistributable yet its API TOS forbids caching,
so the Freesound adapter passes overrides={'cache_bytes_ok': False} — the
item is redistributable but stored by-reference.
Module Attributes
The ONE rights intent every verb and surface defaults to (#63, maintainer decision 2026-10-03): commercial publishing, attributable. |
|
Fail-closed fallback for unknown / |
|
|
|
The CC versions foley has rows for (Freesound, FSD50K, Clotho and Wikimedia use these). |
|
it may keep the bytes, and must credit them; nothing else. |
|
The share-alike licence ids foley can name -> |
|
Licence ids that can never be asserted as verified (on ingest, restamp or in a folder sidecar): |
|
The ids a user may assert ( |
|
The version assumed when a source gives a CC family with no version at all (Freesound's search labels: |
|
Fail-closed display fallback for unknown / |
|
|
|
|
|
The |
|
Freesound |
|
the model's own licence (its weights), the vendor's terms of service, or a label an aggregator put on it (fal's |
|
How sure foley is that the basis applies to the route the sound came by. |
|
Who stated a vendor's watermark ( |
|
The |
|
The EU's member states (ISO 3166-1 alpha-2), for a licence that excludes "EU", with the EU territories that carry their own codes: France's outermost regions (Réunion, French Guiana, Guadeloupe, Martinique, Mayotte, Saint-Martin) and Finland's Åland. |
|
|
|
The usage restrictions an export states beside its licence code, as |
|
Whose terms a provider-terms |
|
foley licence ids whose consumer code is not the id in lowercase. |
|
the public CC ones. |
|
A licence's class for a consumer, from the least to the most restrictive (the classes |
|
The fields that say a stored licence and a fresh one differ besides their rights ( |
|
The credit fields a re-made sound's fresh record corrects besides |
|
The reason a placed sound with no record (nothing to read a licence from) is refused. |
Functions
|
Map a Freesound |
|
Whether AI use of the sound (CLAP-embedding it counts) is allowed here. |
|
Populate |
|
Whether |
|
Whether a work made from |
|
Copy |
|
The NoDerivatives / ShareAlike terms of a CC licence URL or label. |
|
The one rights gate for placed sounds (a plan's, a weave's): raise, warn, or pass. |
|
|
|
Whether exporting |
|
The |
|
foley's |
|
Why a sound with rights |
|
Look up the flag set for a |
|
The licence ids of every sound |
|
Where |
|
Why the bytes of a sound with rights |
|
What the licence |
|
What |
|
The rights intent a verb runs under — every verb and surface resolves it here (#63). |
|
Whether |
|
Whether |
|
Fail-closed candidate license gate (report 07 §8.2). |
|
Convenience: apply |
Map a Creative-Commons license URL or label to |
|
|
Return the display |
|
What |
|
Narrow |
|
|
|
Why |
|
|
|
What a stored sound's licence becomes when its source now states |
|
The licence id a consumer should read |
|
The share-alike licence a work made of |
|
Write what a source |
|
Whether |
|
Why the bytes of a sound with rights |
|
Why a sound with rights |
|
The licence ids a |
|
What |
Classes
|
The eight derivable flags for one |
|
Human-facing display metadata for one |
Exceptions
|
A plan or a weave refused because a placed sound's licence does not serve the intent. |
- foley.licensing.AI_TRAINING_SCOPES: tuple[str, ...] = ('none', 'open_source_only', 'nc_open_source_only')#
The
ai_training_scopevalues (None= no narrowing beyondai_training_ok).
- foley.licensing.ASSERTABLE_LICENSE_IDS = frozenset({'CC-BY-2.0', 'CC-BY-2.5', 'CC-BY-3.0', 'CC-BY-4.0', 'CC-BY-NC-2.0', 'CC-BY-NC-2.5', 'CC-BY-NC-3.0', 'CC-BY-NC-4.0', 'CC-Sampling+-1.0', 'CC0-1.0', 'MIT', 'Pixabay-Content', 'RemArc', 'Sonniss-GDC', 'Stability-Community', 'Tencent-Hunyuan-Community', 'elevenlabs-free-plan', 'elevenlabs-paid-plan', 'fal-partner-unverified', 'owned-pack', 'procedural-free', 'research-only', 'user-owned'})#
The ids a user may assert (
foley ingest --license, afoley-license.toml).
- foley.licensing.CC_VERSIONS: tuple[str, ...] = ('2.0', '2.5', '3.0', '4.0')#
The CC versions foley has rows for (Freesound, FSD50K, Clotho and Wikimedia use these).
- foley.licensing.CONSUMER_LICENSE_CLASSES: tuple[str, ...] = ('free', 'attribution', 'noncommercial', 'unknown')#
A licence’s class for a consumer, from the least to the most restrictive (the classes
an’slicense_classgives).
- foley.licensing.CONSUMER_LICENSE_CODES: dict[str, Optional[str]] = {'unknown': None}#
foley licence ids whose consumer code is not the id in lowercase.
Noneis UNKNOWN (lacing.Rights.license is None), never unencumbered. Consumers (an’s music library and its foley fetcher) importconsumer_license_code()rather than keep a copy of this table.
- foley.licensing.DEFAULT_CC_VERSION = '4.0'#
The version assumed when a source gives a CC family with no version at all (Freesound’s search labels:
"Attribution"). Rights are the same across versions; only the credit’s version is a guess, so the record keeps the label it was given.
- foley.licensing.DEFAULT_INTENDED_USE = IntendedUse(commercial=True, publish=True, redistribute_standalone=False, will_train=False, can_attribute=True, revenue_usd=0, allow_voice_or_trademark=False, territory=None)#
The ONE rights intent every verb and surface defaults to (#63, maintainer decision 2026-10-03): commercial publishing, attributable. NC and SA material is refused unless a caller explicitly passes a different
IntendedUse(orcommercial_ok=False). Treat it as read-only; copy withdataclasses.replace.
- foley.licensing.EU_MEMBER_STATES: frozenset = frozenset({'AT', 'AX', 'BE', 'BG', 'CY', 'CZ', 'DE', 'DK', 'EE', 'ES', 'FI', 'FR', 'GF', 'GP', 'GR', 'HR', 'HU', 'IE', 'IT', 'LT', 'LU', 'LV', 'MF', 'MQ', 'MT', 'NL', 'PL', 'PT', 'RE', 'RO', 'SE', 'SI', 'SK', 'YT'})#
The EU’s member states (ISO 3166-1 alpha-2), for a licence that excludes “EU”, with the EU territories that carry their own codes: France’s outermost regions (Réunion, French Guiana, Guadeloupe, Martinique, Mayotte, Saint-Martin) and Finland’s Åland. (The Canaries, Azores, Madeira, Ceuta and Melilla have none.)
- foley.licensing.GENERATION_FIELDS = ('generator_model', 'generator_version', 'generation_prompt', 'generation_prompt_used', 'generation_seed', 'generation_params', 'watermark', 'c2pa_manifest_ref')#
carry_lineage()keeps the stored record’s.- Type:
How a clip’s bytes were made
- foley.licensing.GEN_AI_PREFERENCE_SCOPES: dict[str, tuple[Optional[bool], Optional[str]]] = {'no-additional-preferences': (None, None), 'no-gen-ai': (False, 'none'), 'noncommercial-open-source-models': (None, 'nc_open_source_only'), 'open-source-models': (None, 'open_source_only')}#
Freesound
gen_ai_preference->(ai_training_ok override, ai_training_scope).Noneas the override leaves the CC row’s flag alone. An unlisted value fails closed (seeai_scope_from_gen_ai_preference()).
- foley.licensing.LICENSE_BASES: tuple[str, ...] = ('model-licence', 'vendor-tos', 'aggregator-label')#
the model’s own licence (its weights), the vendor’s terms of service, or a label an aggregator put on it (fal’s
commercial, an Openverse row), which is a claim about another party’s licence and never that licence itself.- Type:
What a record’s rights rest on (
LicenseRecord.license_basis)
- foley.licensing.LICENSE_BASIS_CONFIDENCES: tuple[str, ...] = ('confirmed', 'unverified')#
How sure foley is that the basis applies to the route the sound came by.
- foley.licensing.LICENSE_EXCLUDED_TERRITORIES: dict[str, frozenset] = {'Tencent-Hunyuan-Community': frozenset({'EU', 'GB', 'GG', 'GI', 'IM', 'JE', 'KR'})}#
license_id-> the territories where it grants nothing (ISO 3166-1 alpha-2 codes, plus"EU"for every member state). A row here makes the territory part of the use:keep()refuses when it is excluded, and when it is not stated.
- foley.licensing.LICENSE_FLAGS: dict[str, LicenseFlags] = {'CC-BY-2.0': LicenseFlags(commercial_ok=True, embed_in_derivative_ok=True, redistribute_standalone_ok=True, cache_bytes_ok=True, modification_ok=True, ai_training_ok=True, requires_attribution=True, revenue_cap_usd=None), 'CC-BY-2.5': LicenseFlags(commercial_ok=True, embed_in_derivative_ok=True, redistribute_standalone_ok=True, cache_bytes_ok=True, modification_ok=True, ai_training_ok=True, requires_attribution=True, revenue_cap_usd=None), 'CC-BY-3.0': LicenseFlags(commercial_ok=True, embed_in_derivative_ok=True, redistribute_standalone_ok=True, cache_bytes_ok=True, modification_ok=True, ai_training_ok=True, requires_attribution=True, revenue_cap_usd=None), 'CC-BY-4.0': LicenseFlags(commercial_ok=True, embed_in_derivative_ok=True, redistribute_standalone_ok=True, cache_bytes_ok=True, modification_ok=True, ai_training_ok=True, requires_attribution=True, revenue_cap_usd=None), 'CC-BY-NC-2.0': LicenseFlags(commercial_ok=False, embed_in_derivative_ok=True, redistribute_standalone_ok=True, cache_bytes_ok=True, modification_ok=True, ai_training_ok=False, requires_attribution=True, revenue_cap_usd=None), 'CC-BY-NC-2.5': LicenseFlags(commercial_ok=False, embed_in_derivative_ok=True, redistribute_standalone_ok=True, cache_bytes_ok=True, modification_ok=True, ai_training_ok=False, requires_attribution=True, revenue_cap_usd=None), 'CC-BY-NC-3.0': LicenseFlags(commercial_ok=False, embed_in_derivative_ok=True, redistribute_standalone_ok=True, cache_bytes_ok=True, modification_ok=True, ai_training_ok=False, requires_attribution=True, revenue_cap_usd=None), 'CC-BY-NC-4.0': LicenseFlags(commercial_ok=False, embed_in_derivative_ok=True, redistribute_standalone_ok=True, cache_bytes_ok=True, modification_ok=True, ai_training_ok=False, requires_attribution=True, revenue_cap_usd=None), 'CC-Sampling+-1.0': LicenseFlags(commercial_ok=False, embed_in_derivative_ok=True, redistribute_standalone_ok=False, cache_bytes_ok=True, modification_ok=True, ai_training_ok=False, requires_attribution=True, revenue_cap_usd=None), 'CC0-1.0': LicenseFlags(commercial_ok=True, embed_in_derivative_ok=True, redistribute_standalone_ok=True, cache_bytes_ok=True, modification_ok=True, ai_training_ok=True, requires_attribution=False, revenue_cap_usd=None), 'ElevenLabs-SFX': LicenseFlags(commercial_ok=True, embed_in_derivative_ok=True, redistribute_standalone_ok=False, cache_bytes_ok=True, modification_ok=True, ai_training_ok=False, requires_attribution=False, revenue_cap_usd=None), 'MIT': LicenseFlags(commercial_ok=True, embed_in_derivative_ok=True, redistribute_standalone_ok=True, cache_bytes_ok=True, modification_ok=True, ai_training_ok=True, requires_attribution=True, revenue_cap_usd=None), 'PDM-1.0': LicenseFlags(commercial_ok=True, embed_in_derivative_ok=True, redistribute_standalone_ok=True, cache_bytes_ok=True, modification_ok=True, ai_training_ok=True, requires_attribution=False, revenue_cap_usd=None), 'Pixabay-Content': LicenseFlags(commercial_ok=True, embed_in_derivative_ok=True, redistribute_standalone_ok=False, cache_bytes_ok=True, modification_ok=True, ai_training_ok=False, requires_attribution=False, revenue_cap_usd=None), 'RemArc': LicenseFlags(commercial_ok=False, embed_in_derivative_ok=True, redistribute_standalone_ok=False, cache_bytes_ok=True, modification_ok=True, ai_training_ok=False, requires_attribution=True, revenue_cap_usd=None), 'Sonniss-GDC': LicenseFlags(commercial_ok=True, embed_in_derivative_ok=True, redistribute_standalone_ok=False, cache_bytes_ok=True, modification_ok=True, ai_training_ok=False, requires_attribution=False, revenue_cap_usd=None), 'Stability-Community': LicenseFlags(commercial_ok=True, embed_in_derivative_ok=True, redistribute_standalone_ok=False, cache_bytes_ok=True, modification_ok=True, ai_training_ok=False, requires_attribution=False, revenue_cap_usd=1000000), 'Tencent-Hunyuan-Community': LicenseFlags(commercial_ok=False, embed_in_derivative_ok=True, redistribute_standalone_ok=False, cache_bytes_ok=True, modification_ok=True, ai_training_ok=False, requires_attribution=False, revenue_cap_usd=None), 'elevenlabs-free-plan': LicenseFlags(commercial_ok=False, embed_in_derivative_ok=True, redistribute_standalone_ok=False, cache_bytes_ok=True, modification_ok=True, ai_training_ok=False, requires_attribution=True, revenue_cap_usd=None), 'elevenlabs-paid-plan': LicenseFlags(commercial_ok=True, embed_in_derivative_ok=True, redistribute_standalone_ok=False, cache_bytes_ok=True, modification_ok=True, ai_training_ok=False, requires_attribution=False, revenue_cap_usd=None), 'fal-partner-unverified': LicenseFlags(commercial_ok=False, embed_in_derivative_ok=True, redistribute_standalone_ok=False, cache_bytes_ok=True, modification_ok=True, ai_training_ok=False, requires_attribution=False, revenue_cap_usd=None), 'owned-pack': LicenseFlags(commercial_ok=True, embed_in_derivative_ok=True, redistribute_standalone_ok=False, cache_bytes_ok=True, modification_ok=True, ai_training_ok=False, requires_attribution=False, revenue_cap_usd=None), 'procedural-free': LicenseFlags(commercial_ok=True, embed_in_derivative_ok=True, redistribute_standalone_ok=True, cache_bytes_ok=True, modification_ok=True, ai_training_ok=True, requires_attribution=False, revenue_cap_usd=None), 'research-only': LicenseFlags(commercial_ok=False, embed_in_derivative_ok=False, redistribute_standalone_ok=False, cache_bytes_ok=True, modification_ok=False, ai_training_ok=False, requires_attribution=False, revenue_cap_usd=None), 'unknown': LicenseFlags(commercial_ok=False, embed_in_derivative_ok=False, redistribute_standalone_ok=False, cache_bytes_ok=False, modification_ok=False, ai_training_ok=False, requires_attribution=False, revenue_cap_usd=None), 'user-owned': LicenseFlags(commercial_ok=True, embed_in_derivative_ok=True, redistribute_standalone_ok=True, cache_bytes_ok=True, modification_ok=True, ai_training_ok=True, requires_attribution=False, revenue_cap_usd=None)}#
license_id-> default flag set (report 07 §8.1 seed table).Order of
LicenseFlagspositional args:commercial, embed, redistribute_standalone, cache_bytes, modification, ai_training, requires_attribution, revenue_cap_usd
- Type:
SSOT
- foley.licensing.LICENSE_META: dict[str, LicenseMeta] = {'CC-BY-2.0': LicenseMeta(display_name='CC BY 2.0', url='https://creativecommons.org/licenses/by/2.0/'), 'CC-BY-2.5': LicenseMeta(display_name='CC BY 2.5', url='https://creativecommons.org/licenses/by/2.5/'), 'CC-BY-3.0': LicenseMeta(display_name='CC BY 3.0', url='https://creativecommons.org/licenses/by/3.0/'), 'CC-BY-4.0': LicenseMeta(display_name='CC BY 4.0', url='https://creativecommons.org/licenses/by/4.0/'), 'CC-BY-NC-2.0': LicenseMeta(display_name='CC BY-NC 2.0', url='https://creativecommons.org/licenses/by-nc/2.0/'), 'CC-BY-NC-2.5': LicenseMeta(display_name='CC BY-NC 2.5', url='https://creativecommons.org/licenses/by-nc/2.5/'), 'CC-BY-NC-3.0': LicenseMeta(display_name='CC BY-NC 3.0', url='https://creativecommons.org/licenses/by-nc/3.0/'), 'CC-BY-NC-4.0': LicenseMeta(display_name='CC BY-NC 4.0', url='https://creativecommons.org/licenses/by-nc/4.0/'), 'CC-BY-NC-SA-2.0': LicenseMeta(display_name='CC BY-NC-SA 2.0', url='https://creativecommons.org/licenses/by-nc-sa/2.0/'), 'CC-BY-NC-SA-2.5': LicenseMeta(display_name='CC BY-NC-SA 2.5', url='https://creativecommons.org/licenses/by-nc-sa/2.5/'), 'CC-BY-NC-SA-3.0': LicenseMeta(display_name='CC BY-NC-SA 3.0', url='https://creativecommons.org/licenses/by-nc-sa/3.0/'), 'CC-BY-NC-SA-4.0': LicenseMeta(display_name='CC BY-NC-SA 4.0', url='https://creativecommons.org/licenses/by-nc-sa/4.0/'), 'CC-BY-SA-2.0': LicenseMeta(display_name='CC BY-SA 2.0', url='https://creativecommons.org/licenses/by-sa/2.0/'), 'CC-BY-SA-2.5': LicenseMeta(display_name='CC BY-SA 2.5', url='https://creativecommons.org/licenses/by-sa/2.5/'), 'CC-BY-SA-3.0': LicenseMeta(display_name='CC BY-SA 3.0', url='https://creativecommons.org/licenses/by-sa/3.0/'), 'CC-BY-SA-4.0': LicenseMeta(display_name='CC BY-SA 4.0', url='https://creativecommons.org/licenses/by-sa/4.0/'), 'CC-Sampling+-1.0': LicenseMeta(display_name='CC Sampling+ 1.0', url='https://creativecommons.org/licenses/sampling+/1.0/'), 'CC0-1.0': LicenseMeta(display_name='CC0 1.0 Universal (Public Domain Dedication)', url='https://creativecommons.org/publicdomain/zero/1.0/'), 'ElevenLabs-SFX': LicenseMeta(display_name='ElevenLabs Sound Effects Terms (legacy: paid plan assumed)', url='https://elevenlabs.io/terms-of-use'), 'MIT': LicenseMeta(display_name='MIT License', url='https://opensource.org/license/mit'), 'PDM-1.0': LicenseMeta(display_name='Public Domain Mark 1.0 (unverified claim)', url='https://creativecommons.org/publicdomain/mark/1.0/'), 'Pixabay-Content': LicenseMeta(display_name='Pixabay Content License', url='https://pixabay.com/service/license-summary/'), 'RemArc': LicenseMeta(display_name='BBC RemArc Licence', url='https://sound-effects.bbcrewind.co.uk/licensing'), 'Sonniss-GDC': LicenseMeta(display_name='Sonniss GDC Game Audio Bundle License', url='https://sonniss.com/gdc-bundle-license'), 'Stability-Community': LicenseMeta(display_name='Stability AI Community License', url='https://stability.ai/community-license-agreement'), 'Tencent-Hunyuan-Community': LicenseMeta(display_name='Tencent Hunyuan Community License (not valid in the EU, the UK or South Korea)', url='https://huggingface.co/tencent/HunyuanVideo-Foley/blob/main/LICENSE'), 'elevenlabs-free-plan': LicenseMeta(display_name='ElevenLabs Terms (free plan: non-commercial, attribution required)', url='https://elevenlabs.io/terms-of-use'), 'elevenlabs-paid-plan': LicenseMeta(display_name='ElevenLabs Terms (paid plan)', url='https://elevenlabs.io/terms-of-use'), 'fal-partner-unverified': LicenseMeta(display_name='fal.ai partner model (vendor terms for fal-routed calls unverified: treated as non-commercial)', url='https://fal.ai/legal/terms-of-service'), 'owned-pack': LicenseMeta(display_name='Purchased sound-effects library (its EULA: use in productions, no redistribution of the raw files)', url=None), 'procedural-free': LicenseMeta(display_name='Procedural synthesis output (no licence attaches)', url=None), 'research-only': LicenseMeta(display_name='Research use only (no commercial or public use)', url=None), 'unknown': LicenseMeta(display_name='Unknown / unverified license', url=None), 'user-owned': LicenseMeta(display_name='User-owned / original work', url=None)}#
license_id-> display name + canonical URL (one row perLICENSE_FLAGSkey). Used only for human-readable credits; never for permission decisions (those come fromLICENSE_FLAGS).- Type:
SSOT
- foley.licensing.LICENSE_TERMS_PROVIDER: dict[str, str] = {'ElevenLabs-SFX': 'elevenlabs', 'Stability-Community': 'stability-ai', 'elevenlabs-free-plan': 'elevenlabs', 'elevenlabs-paid-plan': 'elevenlabs'}#
Whose terms a provider-terms
license_idis, under the provider names a consumer classifies them by (an’sPROVIDER_TERMS: a code counts only on a source whose provider is that provider). Used asRights.provideron export (#66), so a Stable Audio clip reads as Stability’s Community License, with its revenue cap, whichever foley source (local, fal) made it. Ids not listed are their source’s own.
- class foley.licensing.LicenseFlags(commercial_ok=False, embed_in_derivative_ok=False, redistribute_standalone_ok=False, cache_bytes_ok=False, modification_ok=False, ai_training_ok=False, requires_attribution=False, revenue_cap_usd=None)[source]#
Bases:
objectThe eight derivable flags for one
license_id(the table row type).
- class foley.licensing.LicenseMeta(display_name, url=None)[source]#
Bases:
objectHuman-facing display metadata for one
license_id(name + canonical URL).The presentation sibling of
LicenseFlags: whereLicenseFlagsholds the permission row consulted bykeep(),LicenseMetaholds the display row consulted by the credits/attribution layer (foley.provenance.credits). Kept here solicensingstays the single license authority; a record’s ownlicense_name/license_url(when a source populated them) take precedence over this default.
- exception foley.licensing.LicenseRefusal(refused)[source]#
Bases:
ValueErrorA plan or a weave refused because a placed sound’s licence does not serve the intent.
Raised by
foley.plan()andfoley.weave()when they are given an explicitintended_use=(#208).refusedis{sound id: reason}for every refused sound (refusals()); the message names each of them.>>> err = LicenseRefusal({"a": "no grant in EU"}) >>> err.refused, str(err) ({'a': 'no grant in EU'}, 'not licensed for this use: a: no grant in EU')
- foley.licensing.NO_RECORD_REASON = 'it has no record in the library, so its licence cannot be checked'#
The reason a placed sound with no record (nothing to read a licence from) is refused.
- foley.licensing.PUBLIC_LICENSE_IDS: frozenset = frozenset({'CC-BY-2.0', 'CC-BY-2.5', 'CC-BY-3.0', 'CC-BY-4.0', 'CC-BY-NC-2.0', 'CC-BY-NC-2.5', 'CC-BY-NC-3.0', 'CC-BY-NC-4.0', 'CC0-1.0'})#
the public CC ones. A provider-terms or private code (
stability-community,user-owned,owned-pack) is classifiable only on its own provider’s record, so in an edit’s lineage, where that provider is gone, it reads as UNKNOWN.MITis left out until consumers agree it owes a credit (foley’s row says it does;anreadsmitas free with nothing owed), so an MIT link fails closed.- Type:
Licences whose code means the same to any consumer, whoever the provider
- foley.licensing.REMADE_CREDIT_FIELDS = ('source', 'source_id', 'source_url', 'creator_name', 'creator_url')#
The credit fields a re-made sound’s fresh record corrects besides
RESTAMP_FIELDS(restamped_license(remade=True)): who made it, from where.
- foley.licensing.RESTAMP_FIELDS = ('license_id', 'rights_verified', 'license_url', 'license_name', 'rights_holder', 'attribution_text')#
The fields that say a stored licence and a fresh one differ besides their rights (
wider_rights(), either way);verified_atdoes not.
- foley.licensing.REVENUE_CAP = 'revenue_cap'#
The usage restrictions an export states beside its licence code, as
lacing.Restrictionkinds (lacing#106; a test pins them to lacing’s names).
- foley.licensing.SHARE_ALIKE_FLAGS: dict[str, LicenseFlags] = {'CC-BY-NC-SA-2.0': LicenseFlags(commercial_ok=False, embed_in_derivative_ok=False, redistribute_standalone_ok=False, cache_bytes_ok=True, modification_ok=False, ai_training_ok=False, requires_attribution=True, revenue_cap_usd=None), 'CC-BY-NC-SA-2.5': LicenseFlags(commercial_ok=False, embed_in_derivative_ok=False, redistribute_standalone_ok=False, cache_bytes_ok=True, modification_ok=False, ai_training_ok=False, requires_attribution=True, revenue_cap_usd=None), 'CC-BY-NC-SA-3.0': LicenseFlags(commercial_ok=False, embed_in_derivative_ok=False, redistribute_standalone_ok=False, cache_bytes_ok=True, modification_ok=False, ai_training_ok=False, requires_attribution=True, revenue_cap_usd=None), 'CC-BY-NC-SA-4.0': LicenseFlags(commercial_ok=False, embed_in_derivative_ok=False, redistribute_standalone_ok=False, cache_bytes_ok=True, modification_ok=False, ai_training_ok=False, requires_attribution=True, revenue_cap_usd=None), 'CC-BY-SA-2.0': LicenseFlags(commercial_ok=False, embed_in_derivative_ok=False, redistribute_standalone_ok=False, cache_bytes_ok=True, modification_ok=False, ai_training_ok=False, requires_attribution=True, revenue_cap_usd=None), 'CC-BY-SA-2.5': LicenseFlags(commercial_ok=False, embed_in_derivative_ok=False, redistribute_standalone_ok=False, cache_bytes_ok=True, modification_ok=False, ai_training_ok=False, requires_attribution=True, revenue_cap_usd=None), 'CC-BY-SA-3.0': LicenseFlags(commercial_ok=False, embed_in_derivative_ok=False, redistribute_standalone_ok=False, cache_bytes_ok=True, modification_ok=False, ai_training_ok=False, requires_attribution=True, revenue_cap_usd=None), 'CC-BY-SA-4.0': LicenseFlags(commercial_ok=False, embed_in_derivative_ok=False, redistribute_standalone_ok=False, cache_bytes_ok=True, modification_ok=False, ai_training_ok=False, requires_attribution=True, revenue_cap_usd=None)}#
The share-alike licence ids foley can name ->
SHARE_ALIKE_LICENSE_FLAGS. Deliberately notLICENSE_FLAGSrows: they are never assertable on ingest, and every gate that needs a licence row (an edit, a mix) still refuses them, except the identical-licence mix.derive_license_flags()reads them afterLICENSE_FLAGS, so a record under one is bounded by this row (and credited).
- foley.licensing.SHARE_ALIKE_LICENSE_FLAGS = LicenseFlags(commercial_ok=False, embed_in_derivative_ok=False, redistribute_standalone_ok=False, cache_bytes_ok=True, modification_ok=False, ai_training_ok=False, requires_attribution=True, revenue_cap_usd=None)#
it may keep the bytes, and must credit them; nothing else. Every other use foley makes (publishing in a derivative, an edit, training) makes an adaptation that must carry the licence, which foley’s gates cannot express, so
keep()and the edit gate refuse it. The licence itself travels as the record’slicense_id(an export’s consumer code). The one work foley does make from it is a mix of sources all under the identical licence (shared_share_alike()), released under that licence.- Type:
What foley grants itself under a share-alike licence
- foley.licensing.SOURCE_STATED_FIELDS: tuple[str, ...] = ('license_basis', 'license_basis_confidence', 'vendor_trains_on_output', 'terms_notes', 'vendor_watermark')#
The
LicenseRecordfields a source states (in its config’slicenseblock, or per clip): none is derived from alicense_idrow and none is a permission, so stamping them never widens a record.
- foley.licensing.UNASSERTABLE_LICENSE_IDS = frozenset({'ElevenLabs-SFX', 'PDM-1.0', 'unknown'})#
Licence ids that can never be asserted as verified (on ingest, restamp or in a folder sidecar):
unknownby definition,PDM-1.0(a claim about the work, not a grant — verify it by building theLicenseRecordyourself), and the legacyElevenLabs-SFXrow (say the plan).
- foley.licensing.UNKNOWN_LICENSE_FLAGS = LicenseFlags(commercial_ok=False, embed_in_derivative_ok=False, redistribute_standalone_ok=False, cache_bytes_ok=False, modification_ok=False, ai_training_ok=False, requires_attribution=False, revenue_cap_usd=None)#
Fail-closed fallback for unknown /
Proprietary-*license ids (all False, cap None).
- foley.licensing.UNKNOWN_LICENSE_META = LicenseMeta(display_name='Unknown / unverified license', url=None)#
Fail-closed display fallback for unknown /
Proprietary-*license ids.
- foley.licensing.VENDOR_WATERMARK_REPORTERS: tuple[str, ...] = ('config', 'response')#
Who stated a vendor’s watermark (
LicenseRecord.vendor_watermark['reported_by']): the source’s config (its terms), or the vendor’s response for this clip.
- foley.licensing.ai_scope_from_gen_ai_preference(preference)[source]#
Map a Freesound
gen_ai_preferenceto(ai_training_ok override, scope).All four published values are honoured (only
no-gen-aiwas before #69). A missing value means no stated preference; an unrecognised one fails closed.
- foley.licensing.ai_use_permitted(record, *, open_source_model, commercial)[source]#
Whether AI use of the sound (CLAP-embedding it counts) is allowed here.
ai_training_okmust hold, and the record’sai_training_scopemust admit this use:open_source_onlyneeds an open-source model,nc_open_source_onlyalso needs a non-commercial purpose,noneadmits nothing.- Parameters:
record (
LicenseRecord) – The rights record.open_source_model (
bool) – Whether the model using the audio is open source (the embedder’sopen_sourceattribute; LAION-CLAP is).commercial (
bool) – Whether the purpose is commercial (foley’s default intent).
- Return type:
- foley.licensing.apply_license_flags(record, *, overrides=None)[source]#
Populate
record’s eight derived flags from itslicense_id(+ overrides), in place, and return it.A derivative (an edit, #162) stays bounded by every licence it derives from (
derived_license_ids()): each one’s row is ANDed in after the overrides, so re-deriving its flags (a restamp to the generator’s licence, a reload) never widens them back (#214). A record that derives from nothing is unaffected.Does NOT touch
rights_verified— verification is a separate concern.- Parameters:
record (
LicenseRecord) – TheLicenseRecordto populate.overrides (
Optional[dict]) – Optional per-source flag overrides (seederive_license_flags()).
- Return type:
- Returns:
The same (mutated)
record.
>>> from foley.base import LicenseRecord >>> edit = LicenseRecord(source="g", license_id="Stability-Community", ... derived_from_license_ids=["CC-BY-NC-4.0"]) >>> apply_license_flags(edit, overrides={"commercial_ok": True}).commercial_ok False
- foley.licensing.carries_own_restriction(license_id)[source]#
Whether
license_idrestricts beyond what its class says, so that no other licence’s code can stand in for it: a revenue cap, or a provider’s own terms (LICENSE_TERMS_PROVIDER, which a consumer attaches restrictions to).>>> carries_own_restriction("Stability-Community"), carries_own_restriction("CC-BY-4.0") (True, False)
- Return type:
Whether a work made from
recordmay be released under the share-alikelicense_id.It may when
license_idis a share-alike licence foley can name (SHARE_ALIKE_FLAGS),recordis under it, and every licencerecordderives from (derived_license_ids()) is that same one: its obligations are then exactly the licence’s. Another version, another family (BY-NC-SA is not BY-SA) or anything else in the lineage fails closed.>>> sa = LicenseRecord(source="s", license_id="CC-BY-SA-4.0") >>> carries_share_alike(sa, "CC-BY-SA-4.0"), carries_share_alike(sa, "CC-BY-SA-3.0") (True, False) >>> carries_share_alike(LicenseRecord(source="s", license_id="CC-BY-SA-4.0", ... derived_from_license_ids=["CC0-1.0"]), "CC-BY-SA-4.0") False
- Return type:
- foley.licensing.carry_lineage(new, old)[source]#
Copy
old’s lineage ontonew, in place, and returnnew.The lineage is what a re-stamped record must keep from the one it replaces: its
transformations(the edits and fixes, so the credit still reads “(modified)”), itsderived_from_license_ids(the licences bounding it, #214), itsterms_notes(added tonew’s: the source’s API obligations, #77) and the facts about its bytes (a vendor that reuses them, the vendor’s watermark, that they are AI-generated and to be disclosed, and how they were made:GENERATION_FIELDS,old’s where it states them). Fresh lists, so the two records never share one; aNonereads as empty.new’s flags are then bounded by every licence it now derives from (never widened), so the copy is safe on its own; a laterapply_license_flags()re-derives under the same bound.>>> from foley.base import LicenseRecord >>> old = LicenseRecord(source="g", transformations=["declick"], ... derived_from_license_ids=["CC-BY-NC-4.0"]) >>> new = carry_lineage(LicenseRecord(source="g"), old) >>> new.transformations, new.derived_from_license_ids (['declick'], ['CC-BY-NC-4.0']) >>> new.transformations is old.transformations False >>> cc0 = apply_license_flags(LicenseRecord(source="g", license_id="CC0-1.0")) >>> carry_lineage(cc0, old).commercial_ok False
- Return type:
- foley.licensing.cc_refused_terms(url)[source]#
The NoDerivatives / ShareAlike terms of a CC licence URL or label.
license_id_from_cc_url()refuses these on purpose (foley has no licence row expressing them, so it maps them to'unknown'); this says why a URL was refused, for a message that is not “cannot read a licence”.>>> cc_refused_terms("https://creativecommons.org/licenses/by-nc-sa/4.0/") ('ShareAlike',) >>> cc_refused_terms("CC BY-ND-SA"), cc_refused_terms("https://creativecommons.org/licenses/by/4.0/") (('NoDerivatives', 'ShareAlike'), ()) >>> cc_refused_terms(None) ()
- foley.licensing.check_placed(records, intended_use, *, what)[source]#
The one rights gate for placed sounds (a plan’s, a weave’s): raise, warn, or pass.
With an explicit
intended_use, fail-closed: raiseLicenseRefusalnaming every sound inrecords({sound id: SoundRecord or None}) the intent does not keep. WithNone(the migration default, #208), nothing is refused, but ifDEFAULT_INTENDED_USEwould refuse anything, oneFutureWarningnames each such id and reason: a future release gates by default.- Parameters:
records (
Mapping[str,object]) – The placed sounds, by id (Nonefor one with no record).intended_use (
Optional[IntendedUse]) – The caller’s rights intent, orNone(today’s behaviour).what (
str) – The façade’s name, for the warning ("foley.plan"); the warning points at the first caller outside foley.
- Raises:
LicenseRefusal – If
intended_useis given and refuses any sound.- Return type:
- foley.licensing.checked_refusal_reason(record, intended_use)[source]#
refusal_reason(), fail-closed: an error while checking is itself a reason.The one place a rights check is allowed to fail: whatever goes wrong reading
record(a missing or malformed licence) refuses it, with the error as the reason, so no caller can keep a sound whose licence it could not read.- Parameters:
record (
LicenseRecord) – The sound’sLicenseRecord(aSoundRecord’s.license; seerefusals()for whole sound records).intended_use (
IntendedUse) – The caller’s declared intent.
- Return type:
- Returns:
Noneonly whenkeep()keepsrecord; otherwise why not.
>>> lic = LicenseRecord(source="user", license_id="CC0-1.0", commercial_ok=True, ... rights_verified=True) >>> checked_refusal_reason(lic, IntendedUse()) is None True >>> checked_refusal_reason(None, IntendedUse()) "its licence could not be checked (AttributeError: 'NoneType' object has no attribute 'rights_verified')"
- foley.licensing.code_implies_at_most(code, record, *, restrictions=())[source]#
Whether exporting
recordunder the licencecode, withrestrictionsstated beside it (lacing.Restrictiondicts,license_restrictions()), tells a consumer no more thanrecordallows (None, UNKNOWN, implies nothing).The export is judged as a consumer reads it: the code’s flags under the lowest stated revenue cap, and the code’s excluded territories plus the stated ones.
Every one must hold (
_no_wider(): the permissions of_CODE_PERMISSIONS, attribution, the revenue cap):the code’s row (what foley derives under it) is no wider than the record’s own flags, so a narrowing the record holds is never dropped;
what the code grants anyone (
granted_flags()) is no wider than what each licence of the record’s chain grants, so a lineage restriction is never dropped (needed for share-alike, whose flags are foley’s self-limit and show none);it excludes every territory the chain excludes (
excluded_territories());it is every share-alike licence of the chain: no other licence (another version, CC BY-NC-SA for CC BY-SA) satisfies a share-alike term.
AI use is not compared: a code says nothing a consumer reads about it, so the consumer reads it from the export’s provenance (see
_CODE_PERMISSIONS).>>> sa_nc = apply_license_flags(LicenseRecord(source="s", license_id="CC-BY-SA-4.0", ... derived_from_license_ids=["CC-BY-NC-4.0"])) >>> [code_implies_at_most(c, sa_nc) for c in ("CC-BY-SA-4.0", "CC-BY-NC-4.0", ... "CC-BY-NC-SA-4.0", None)] [False, False, False, True]
- Return type:
- foley.licensing.consumer_license_class(license_id)[source]#
The
CONSUMER_LICENSE_CLASSESentry oflicense_id, from its flag row.>>> [consumer_license_class(i) for i in ("CC0-1.0", "CC-BY-4.0", "CC-BY-NC-4.0")] ['free', 'attribution', 'noncommercial'] >>> consumer_license_class("Tencent-Hunyuan-Community"), consumer_license_class("x") ('unknown', 'unknown')
- Return type:
- foley.licensing.consumer_license_code(license_id)[source]#
foley’s
license_idas a consumer’s licence code: the SSOT consumers import.CONSUMER_LICENSE_CODESfirst, else the id in lowercase (an SPDX-style code such ascc-by-4.0, or a provider’s own code such asstability-community, read withLICENSE_TERMS_PROVIDER).>>> consumer_license_code("CC0-1.0"), consumer_license_code("unknown") ('cc0-1.0', None) >>> consumer_license_code(None) is None True
- foley.licensing.derivative_refusal(source)[source]#
Why a sound with rights
sourcemay not be edited into a new sound, orNone.The fail-closed gate of an edit (#162), applied by the generation’s
editmode before anything is paid for. The first unmet requirement: its rights are verified; its bytes may be sent on (upload_refusal()); its licence is not share-alike (the edit’s own licence, the generator’s, cannot carry it); its licence has aLICENSE_FLAGSrow (else the edit’s rights cannot be derived); it allows modification; it excludes no territory (which the edit’s record could not carry). Every other restriction carries over to the edit (narrow_to_source()).>>> from foley.base import LicenseRecord >>> ok = apply_license_flags(LicenseRecord(source="x", license_id="CC-BY-4.0", ... rights_verified=True)) >>> derivative_refusal(ok) is None True >>> derivative_refusal(apply_license_flags(LicenseRecord(source="x", ... license_id="research-only", ... rights_verified=True))) 'its licence does not allow modification'
- foley.licensing.derive_license_flags(license_id, *, overrides=None)[source]#
Look up the flag set for a
license_id(fail-closed fallback), then apply per-source overrides.- Parameters:
- Returns:
the
LICENSE_FLAGSrow, else theSHARE_ALIKE_FLAGSone, else the all-FalseUNKNOWN_LICENSE_FLAGS(fail closed).- Return type:
- Raises:
ValueError – If
overridescontains a key that is not aLicenseFlagsfield.
- foley.licensing.derived_license_ids(record)[source]#
The licence ids of every sound
recordderives from ([]: not derived).The merge of two records of it: its
derived_from_license_idsfield (#214), plus thesource_license_idof each edit entry in itstransformations(#162), so a record stored before the field existed is still bounded by its source. In order, without repeats.That legacy fallback sees only the direct source: an edit entry names its parent’s licence, not the licences the parent itself derived from. So an edit of an edit stored before this release (no
derived_from_license_ids) is bounded by its parent’s licence only, not its grandparent’s. Re-running the edit, or narrowing it again withnarrow_to_source(), records the full chain.>>> from foley.base import LicenseRecord >>> derived_license_ids(LicenseRecord(source="g")) [] >>> derived_license_ids(LicenseRecord(source="g", derived_from_license_ids=["CC-BY-4.0"], ... transformations=["declick", {"kind": "edit", "source_license_id": "CC-BY-NC-4.0"}])) ['CC-BY-4.0', 'CC-BY-NC-4.0']
- foley.licensing.excluded_territories(record)[source]#
Where
record’s licence, or any licence it derives from, grants nothing.LICENSE_EXCLUDED_TERRITORIESis the SSOT (an exclusion is a term of the licence, not of one sound), read over the record’s whole lineage (derived_license_ids()), so a record restamped or narrowed by an excluding licence is gated too. Sorted codes;[]when nothing is excluded.>>> excluded_territories(LicenseRecord(source="s", license_id="CC0-1.0")) [] >>> excluded_territories(LicenseRecord(source="s", license_id="CC0-1.0", ... derived_from_license_ids=["Tencent-Hunyuan-Community"]))[:3] ['EU', 'GB', 'GG']
- foley.licensing.export_refusal(source)[source]#
Why the bytes of a sound with rights
sourcemay not be exported, orNone.The gate of
foley.export_sound(), fail-closed: an export hands the bytes to another store, which is keeping them, so it followscache_bytes_okexactly as storage does (foley.stores.store_sound()).>>> from foley.base import LicenseRecord >>> export_refusal(LicenseRecord(source="x", cache_bytes_ok=True)) is None True >>> export_refusal(LicenseRecord(source="freesound"))[-24:] 'fetch it from its source'
- foley.licensing.exported_licence_wider(record, bound)[source]#
What the licence
recordis exported under allows thatbound’s does not.Read off
rights_license_id()(the code a consumer classifies), for two verified records: a known code whereboundreads as unknown, a commercial one wherebound’s is non-commercial, one without share-alike wherebound’s has it, or a less restrictive consumer class (CONSUMER_LICENSE_CLASSES).>>> from foley.base import LicenseRecord >>> ncsa = LicenseRecord(source="s", license_id="CC-BY-NC-SA-4.0", rights_verified=True) >>> sa = LicenseRecord(source="s", license_id="CC-BY-SA-4.0", rights_verified=True) >>> exported_licence_wider(sa, ncsa), exported_licence_wider(ncsa, sa) (['commercial use (CC-BY-NC-SA-4.0 -> CC-BY-SA-4.0)'], [])
- foley.licensing.granted_flags(license_id)[source]#
What
license_idgrants anyone, as a consumer reads its code (fail closed).Its
LICENSE_FLAGSrow; for a share-alike licence foley can name, the row of its family without the share-alike term (CC BY-SA 4.0 grants what CC BY 4.0 does, under the obligation to share alike):SHARE_ALIKE_LICENSE_FLAGSis what foley grants itself under it, not what the licence grants. Else all False.>>> granted_flags("CC-BY-SA-4.0") == LICENSE_FLAGS["CC-BY-4.0"] True >>> granted_flags("CC-BY-NC-SA-3.0") == LICENSE_FLAGS["CC-BY-NC-3.0"] True >>> granted_flags(None) == UNKNOWN_LICENSE_FLAGS True
- Return type:
- foley.licensing.intended_use_for(intended_use=None, *, commercial_ok=None, territory=None)[source]#
The rights intent a verb runs under — every verb and surface resolves it here (#63).
An explicit
intended_usewins; elseDEFAULT_INTENDED_USE, withcommercialoverridden whencommercial_okis given (Falseis the explicit opt-in to non-commercial material) andterritorywhen given (an ISO 3166-1 alpha-2 code, or"WORLD"; #175). Always a fresh copy, so callers may mutate it.>>> intended_use_for(commercial_ok=False, territory="us").territory 'US'
- Raises:
ValueError – If both are given and disagree on
commercialorterritory, or the territory is not a code.- Return type:
- foley.licensing.is_cc_license_token(token)[source]#
Whether
tokenis a search constraint a CC-reading source understands.None/'any'(no constraint),'cc0', or a CC / public-domain licence id or family ('CC-BY-4.0','cc-by','PDM-1.0'). Not an ingest-time rights assertion such as'user-owned'.- Return type:
Whether
license_id(or a licence URL / label) is share-alike.Read with the same tokens
license_id_from_cc_url()refuses share-alike by: noLICENSE_FLAGSrow is share-alike (the mapper sends every such licence to'unknown'), so this catches an id stamped by hand or by a source.>>> is_share_alike("CC-BY-SA-4.0"), is_share_alike("CC-BY-4.0"), is_share_alike(None) (True, False, False)
- Return type:
- foley.licensing.keep(record, intended_use)[source]#
Fail-closed candidate license gate (report 07 §8.2).
Run BEFORE ranking/verification in the agent’s
decide(). Unknown or unverified rights => reject. Any single unmet requirement => reject.- Parameters:
record (
LicenseRecord) – The candidate’s rights record.intended_use (
IntendedUse) – The caller’s declared intent.
- Return type:
- Returns:
Trueonly if every requirement inintended_useis satisfied byrecord;Falseotherwise (including unverified rights).
- foley.licensing.keep_sound(sound_record, intended_use)[source]#
Convenience: apply
keep()to aSoundRecord’s nested license.- Parameters:
sound_record – A
SoundRecord(its.licenseis the SSOT consulted).intended_use (
IntendedUse) – The caller’s declared intent.
- Return type:
- Returns:
The result of
keep(sound_record.license, intended_use).
- foley.licensing.license_id_from_cc_url(url)[source]#
Map a Creative-Commons license URL or label to
(license_id, verified).The single SSOT for turning an external source’s license string into a foley
license_id(FSD50K, Clotho, the Freesound API, …). It never widens rights: the string is split into tokens, andany NoDerivatives / ShareAlike sign (
nd,sa,no derivatives,share alike,sharealike) →('unknown', False): foley has no row expressing those restrictions, so the sound is refused everywhere;the Public Domain Mark →
('PDM-1.0', False): a claim about the work, not a licence anyone granted, so never auto-verified (#56); a label that adds words to it (“not public domain”, “public domain in the US only”) →('unknown', False);CC0 (
publicdomain/zero,cc0,creative commons 0) →CC0-1.0;Sampling+ →
CC-Sampling+-1.0;by/attributionwith any mention of commercial use (nc,noncommercial,non commercial,no commercial use) →CC-BY-NC-<v>, elseCC-BY-<v>. The version is kept (/by/3.0/→CC-BY-3.0); a versionless label getsDEFAULT_CC_VERSION; a version foley has no row for (a2.1/jpport) fails closed;anything else — including a string with a token this parser does not know — →
('unknown', False).
- foley.licensing.license_meta(license_id)[source]#
Return the display
LicenseMetaforlicense_id(fail-closed fallback).- Parameters:
license_id (
str) – The normalized license id.- Return type:
- Returns:
The mapped
LicenseMeta, orUNKNOWN_LICENSE_METAfor an unrecognized /Proprietary-*id.
- foley.licensing.license_restrictions(record)[source]#
What
recordmay not be used for that no licence code says, aslacing.Restrictiondicts (the shapeRestriction.model_dump()gives).Read off the licences of the record’s chain, not its stored flags, so a record whose flags went stale still states every term:
revenue_cap: one per chain licence whose row caps revenue (termsits consumer code,usdits cap), plus one withterms=Nonewhen the record’s own cap is lower than all of them (a narrowing);territory_excluded: one per chain licence that excludes territories (LICENSE_EXCLUDED_TERRITORIES), its codes sorted and verbatim (EUis a region code; lacing records it as given).
>>> license_restrictions(LicenseRecord(source="s", license_id="Stability-Community")) ({'kind': 'revenue_cap', 'terms': 'stability-community', 'usd': 1000000},) >>> license_restrictions(LicenseRecord(source="s", license_id="CC0-1.0")) ()
- foley.licensing.narrow_to_source(output, source)[source]#
Narrow
output’s rights to whatsourceallows, in place (never widening).An edit is a derivative of its source: it may be used only where both the generator’s licence and the source’s allow. Each permission of
_DERIVATIVE_SHARED_FLAGSis kept only when both hold it, attribution is required when either requires it, the revenue cap is the lower one, the AI-use scope is the stricter one, and the source’s required notice, terms notes, stated AI-use preference and safety flags carry over.cache_bytes_okstays the output’s (it is about storing the new bytes). Routed throughapply_license_flags(), so the flags still come from the policy layer, never set by hand.>>> from foley.base import LicenseRecord >>> out = apply_license_flags(LicenseRecord(source="g", license_id="Stability-Community")) >>> src = apply_license_flags(LicenseRecord(source="s", license_id="CC-BY-NC-4.0")) >>> narrowed = narrow_to_source(out, src) >>> narrowed.commercial_ok, narrowed.requires_attribution, narrowed.revenue_cap_usd (False, True, 1000000)
- Return type:
- foley.licensing.placed_record(library, sound_id, *, missing=None, unreadable=None)[source]#
library’s record forsound_idas a rights gate reads it, never raising.The one lookup every placed-sound gate uses (a plan’s, a weave’s, the MCP verbs’), so they agree on what “no record” means (#208):
missingwhen there is no entry:libraryisNone, or the lookup raises aLookupError(the id is genuinely absent);unreadable(defaultNone) when the lookup fails any other way (a corrupt stored record, a broken backend): an entry that is there but cannot be judged;Nonewhen the value has no.license(a plain-mapping library of audio arrays holds sounds, not records).
Noneis what the fail-closed gate (refusals()) refuses under an explicit intent, and what the no-intent path only warns about, so a bad library can make a gated call refuse but never make an ungated one raise.>>> from foley.base import SoundRecord >>> rec = SoundRecord(id="a", license=LicenseRecord(source="user")) >>> placed_record({"a": rec}, "a") is rec True >>> placed_record({"a": rec}, "b", missing="own"), placed_record(None, "a") ('own', None) >>> placed_record({"a": [0.0, 0.1]}, "a") is None # audio, not a record True >>> class Corrupt(dict): ... def __getitem__(self, k): ... raise ValueError("bad JSON") >>> placed_record(Corrupt(), "a", missing="own") is None True
- foley.licensing.refusal_reason(record, intended_use)[source]#
Why
keep()refusesrecordforintended_use, orNoneif it keeps it.The one rule, read as text: the first requirement the record does not meet.
- foley.licensing.refusals(sound_records, intended_use)[source]#
{sound id: reason}for each sound recordkeep()refuses forintended_use.The re-check a placed sound gets where it is used (a plan, a weave), whatever intent it was found under (#191). Takes
SoundRecords (each judged by its.licensethroughchecked_refusal_reason(), so fail-closed: a record without a readable licence is refused), or a mapping{sound id: record}in which aNonerecord (the sound has none) is refused too. Empty when every sound is kept.>>> refusals({"a": None}, IntendedUse()) {'a': 'it has no record in the library, so its licence cannot be checked'}
- foley.licensing.restamped_license(stored, fresh, *, widen=True, remade=False)[source]#
What a stored sound’s licence becomes when its source now states
fresh.Returns
(new_record, note):new_recordisNonewhen the stored licence stays as it is, andnoteisNonewhen there is nothing to say. Pure: neither argument is changed. The stored lineage (edits, the licences bounding it) is always kept (carry_lineage()).terms_notesare not rights:fresh’s are added to the stored record whatever happens to its licence (thennew_recordis the stored licence with them, even when its rights stay).widen=True:freshreplaces the stored licence. For a source that is the authority on its own clips (a corpus’s metadata,foley.bootstrap.bootstrap()).widen=False: rights are never widened.freshreplaces an unverified stored licence (nobody asserted it) or one it is no wider than (wider_rights()). Whenfreshgrants more than the stored licence and no less, the stored one is kept with a note naming the widening to apply by hand (foley.index.ingest.restamp_rights()). When each grants something the other does not, the stored licence is bounded byfresh(narrow_to_source()): the sound may be used only where both allow.
remade=True: the sound was made again (a byte-identical derivative re-rendered with corrected credits), sofreshis its whole record: its lineage and credits (REMADE_CREDIT_FIELDS) replace the stored ones whereverfreshis applied. A credit change is a correction, not a widening; dropping a licence the stored record derives from (derived_license_ids()) whose row would still narrow it is a widening, sowiden=Falsekeeps it. DefaultFalse: the source restates its terms and the stored lineage (the edits made since) is kept.>>> from foley.base import LicenseRecord >>> cc0 = apply_license_flags(LicenseRecord(source="s", license_id="CC0-1.0", rights_verified=True)) >>> nc = apply_license_flags(LicenseRecord(source="s", license_id="CC-BY-NC-4.0", rights_verified=True)) >>> restamped_license(cc0, nc, widen=False)[0].license_id 'CC-BY-NC-4.0' >>> new, note = restamped_license(nc, cc0, widen=False) >>> new is None, note.startswith("not widened") (True, True)
- Return type:
- foley.licensing.rights_license_id(record, *, restrictions=())[source]#
The licence id a consumer should read
recordunder, orNone(UNKNOWN).restrictionsare what the export states beside the code (license_restrictions();sound_rightsstates them, #282): the code is judged together with them (code_implies_at_most()), so a cap or excluded territories stated there need not be implied by the code. A Stable Audio edit of a CC BY sound still givesNone: Stability’s licence also bars standalone redistribution, which CC BY grants and no restriction kind states.Nonewhen the rights are unverified (a Public Domain Mark is a claim, not a grant). For a clip derived from others (an edit,derived_license_ids()), the most restrictive of its own licence and every source’s: an edit keeps its generator’slicense_idand narrows only its flags, so exporting that id alone would read a Stable Audio edit of a CC BY-NC sound as free. A source licence that is not public (PUBLIC_LICENSE_IDS) counts as UNKNOWN, and a source that wins as UNKNOWN givesNone. Ties go to the clip’s own licence.A code is returned only when it alone carries every restriction of the chain: a source that wins over a clip whose own licence restricts beyond its class (
carries_own_restriction(): a revenue cap, a provider’s terms) givesNone, since aRightsrecord has one licence field and the source’s public code would drop the clip’s restriction (Stability’s revenue cap).The final gate, whatever the path (an edit, a restamp, a broadcast, a plain record), is
code_implies_at_most(): a code that would let a consumer do more than the record allows givesNone(#274). No other code stands in: CC BY-NC-SA is not what a CC BY-SA record bounded by CC BY-NC may be released under (BY-SA requires adaptations under BY-SA or a compatible licence, and NC-SA is neither).>>> def rec(lid, *lineage): ... return apply_license_flags(LicenseRecord(source="s", license_id=lid, ... rights_verified=True, derived_from_license_ids=list(lineage))) >>> rights_license_id(rec("CC-BY-4.0")) 'CC-BY-4.0' >>> rights_license_id(rec("elevenlabs-free-plan", "CC-BY-4.0")) 'elevenlabs-free-plan' >>> rights_license_id(rec("procedural-free", "CC-BY-NC-4.0")) 'CC-BY-NC-4.0' >>> rights_license_id(rec("Stability-Community", "CC-BY-4.0")) is None True >>> capped = apply_license_flags(LicenseRecord(source="s", license_id="CC-BY-4.0", ... rights_verified=True), overrides={"revenue_cap_usd": 1000}) >>> rights_license_id(capped), rights_license_id(capped, ... restrictions=license_restrictions(capped)) (None, 'CC-BY-4.0') >>> rights_license_id(rec("Stability-Community", "Tencent-Hunyuan-Community")) is None True >>> rights_license_id(rec("CC-BY-SA-4.0", "CC-BY-NC-4.0")) is None True
The share-alike licence a work made of
recordsmay be released under, orNone.Every record must carry the same one (
carries_share_alike()); a missing record (None: rights unknown), a source under another licence, or one that is not share-alike at all givesNone, and the work cannot carry the licence.>>> sa = LicenseRecord(source="s", license_id="CC-BY-SA-4.0") >>> shared_share_alike(sa, sa), shared_share_alike(sa, None) ('CC-BY-SA-4.0', None) >>> shared_share_alike(sa, LicenseRecord(source="s", license_id="CC-BY-NC-SA-4.0"))
- foley.licensing.stamp_source_terms(record, stated)[source]#
Write what a source
statedabout its terms ontorecord, in place, and return it.statedmapsSOURCE_STATED_FIELDSnames to values (a config’s, seefoley.sources.base.source_stated_terms()). No permission flag is touched;terms_notesare added to the record’s own, once each.>>> lic = stamp_source_terms(LicenseRecord(source="s"), ... {"license_basis": "vendor-tos", "terms_notes": ["Pay the piper."]}) >>> lic.license_basis, lic.terms_notes, lic.commercial_ok ('vendor-tos', ['Pay the piper.'], False)
- Raises:
ValueError – On a name that is not a stated field, or a value it does not take.
- Return type:
- foley.licensing.territory_excluded(excluded, territory)[source]#
Whether
territoryis inexcluded("EU"covers its member states).An unstated territory (
None) counts as excluded whenever anything is, and so does one that is not a country code: the gate fails closed.>>> territory_excluded({"EU", "GB"}, "fr"), territory_excluded({"EU"}, "US") (True, False) >>> territory_excluded({"KR"}, None), territory_excluded({"GB"}, "uk") (True, True) >>> territory_excluded({"KR"}, "Korea"), territory_excluded(set(), None) (True, False) >>> territory_excluded({"KR"}, "WORLD"), territory_excluded(set(), "WORLD") (True, False)
- Return type:
- foley.licensing.upload_refusal(source)[source]#
Why the bytes of a sound with rights
sourcemay not be sent to an edit backend, orNone.cache_bytes_okis the source’s terms on its bytes (a Freesound API pull is by-reference even under CC0): bytes foley may not keep, it does not upload either.>>> from foley.base import LicenseRecord >>> upload_refusal(LicenseRecord(source="x", cache_bytes_ok=True)) is None True >>> upload_refusal(LicenseRecord(source="freesound"))[:30] 'its bytes may not be kept or s'
- foley.licensing.vendor_training_refusal(source, backend_config)[source]#
Why a sound with rights
sourcemay not be sent to the backendbackend_configdeclares, because its vendor trains on what it is sent, orNone.A backend whose licence block says
vendor_trains_on_input(Mirelo’s terms §7.4: a training licence on input as well as output) takes the source clip into a proprietary, commercial training set. Fail-closed: the source’s rights must allow that use (ai_use_permitted(), closed-source and commercial); anai_training_okthat is off or a narrowed scope refuses it, before any upload.>>> from foley.base import LicenseRecord >>> trains = {"license": {"vendor_trains_on_input": True}} >>> vendor_training_refusal(LicenseRecord(source="x"), trains)[:26] "its backend's vendor train" >>> vendor_training_refusal(LicenseRecord(source="x", ai_training_ok=True), trains) is None True >>> vendor_training_refusal(LicenseRecord(source="x"), {"license": {}}) is None True
- foley.licensing.wanted_license_ids(config, license)[source]#
The licence ids a
license=request keeps, orNonefor every accepted one.licenseis an explicit licence id (QUERY_AFFORDANCES['license']), matched case-insensitively against the source’saccepted_license_ids;'cc0'is the historical alias for the source’scc0_license_ids, and a family prefix with a dash, such as'cc-by', keeps every accepted id of that family (CC-BY-3.0,CC-BY-4.0).None,'any'and a value that is no licence id at all (e.g.'public-domain') do not narrow, with a warning for the last (the historical “anything but'cc0'” behaviour). A real licence id the source does not accept gives[], so nothing is returned: fail closed, never silently broader.>>> cfg = {"license": {"accepted_license_ids": ["CC0-1.0", "CC-BY-4.0"], ... "cc0_license_ids": ["CC0-1.0"]}} >>> wanted_license_ids(cfg, "cc0"), wanted_license_ids(cfg, "CC-BY-4.0") (['CC0-1.0'], ['CC-BY-4.0']) >>> wanted_license_ids(cfg, "cc-by"), wanted_license_ids(cfg, None), wanted_license_ids(cfg, "cc-by-sa-4.0") (['CC-BY-4.0'], None, [])
- foley.licensing.wider_rights(record, bound)[source]#
What
recordallows thatbounddoes not ([]: no wider thanbound).A permission of
_DERIVATIVE_SHARED_FLAGSit holds andboundlacks, an attribution or a noticeboundrequires and it does not, a higher (or no) revenue cap, a looser AI-use scope, a voice or trademark flagboundraises and it does not, another stated AI-use preference. When the flags show nothing, the licence a consumer reads it under (exported_licence_wider()): every share-alike licence has the same flag row, so only the id tells CC BY-NC-SA from CC BY-SA. How an edit tells that a byte-identical sound already in the library is not the edit it made (seenarrow_to_source()).>>> from foley.base import LicenseRecord >>> nc = apply_license_flags(LicenseRecord(source="s", license_id="CC-BY-NC-4.0")) >>> by = apply_license_flags(LicenseRecord(source="s", license_id="CC-BY-4.0")) >>> wider_rights(by, nc), wider_rights(nc, by) (['commercial_ok', 'ai_training_ok'], [])