YAML Metadata Warning:empty or missing yaml metadata in repo card

Check out the documentation for more information.

License Policy Engine

Prolog-based cartographic license compatibility reasoner for tri-license strategy (BSL + AGPL + MPL).

What Is This?

A declarative policy engine that:

  • Maps use cases to optimal license tiers (BSL, AGPL, MPL, Commercial)
  • Validates dependency compatibility
  • Generates compatibility matrices
  • Enforces license policy across codebases

Built in Prolog because license compatibility is a graph reasoning problem, not imperative logic.


Tri-License Strategy

BSL-1.1 (Business Source License)
  β”œβ”€ Source-available with commercial restrictions
  β”œβ”€ No managed services at enterprise scale
  └─ Converts to AGPL-3.0 after transition period

AGPL-3.0 (GNU Affero General Public License)
  β”œβ”€ Strong network copyleft
  β”œβ”€ SaaS/network distribution triggers source disclosure
  └─ All modifications must be AGPL-3.0

MPL-2.0 (Mozilla Public License)
  β”œβ”€ Weak copyleft (file-level)
  β”œβ”€ Can combine with proprietary code
  └─ Modified files must remain MPL-2.0

Commercial License
  └─ Bypasses all copyleft restrictions

Usage

1. Check Compatibility Matrix

swipl -q -t halt -f license_policy.pl -- matrix

Output:

=== LICENSE COMPATIBILITY MATRIX ===
 [OK] mpl_2_0 <--> proprietary
 [OK] mpl_2_0 <--> mpl_2_0
 [OK] bsl_1_1 <--> source_available
 [OK] agpl_3_0 <--> agpl_3_0
 [OK] commercial <--> proprietary

2. Select License for Use Case

swipl -q -t halt -f license_policy.pl -- select saas_wrapper

Output:

Recommended License: agpl_3_0

Supported use cases:

  • saas_wrapper β†’ AGPL-3.0 (network copyleft)
  • enterprise_restricted β†’ BSL-1.1 (no managed services)
  • file_level_mod β†’ MPL-2.0 (weak copyleft)
  • copyleft_bypass β†’ Commercial (no restrictions)
  • open_source_redistribution β†’ AGPL-3.0 (default copyleft)

3. Check Dependency Compatibility

swipl -q -t halt -f license_policy.pl -- check mpl_2_0 proprietary

Output:

mpl_2_0 is compatible with proprietary.

Architecture

Core Predicates

% License taxonomy
license(bsl_1_1).
license(agpl_3_0).
license(mpl_2_0).
license(commercial).

% Use case β†’ License mapping
use_case(saas_wrapper, agpl_3_0).
use_case(enterprise_restricted, bsl_1_1).
use_case(file_level_mod, mpl_2_0).
use_case(copyleft_bypass, commercial).

% Compatibility rules
compatible(mpl_2_0, proprietary).
compatible(bsl_1_1, source_available).
compatible(agpl_3_0, agpl_3_0).
compatible(commercial, proprietary).

% Query API
select_license(UseCase, License).
check_compatibility(License, Dependency).

Why Prolog?

License compatibility is graph reasoning:

  • Transitive closure (A compat B, B compat C β†’ A compat C?)
  • Constraint satisfaction (can this dep tree satisfy license X?)
  • Declarative rules (not imperative if/else chains)

Prolog excels at:

  • Logical inference
  • Backtracking search
  • Horn clause reasoning
  • Pattern matching

This is a cartographic engine β€” it maps the license compatibility graph and finds valid paths.


Integration

Embed in CI/CD

# .github/workflows/license-check.yml
name: License Policy Enforcement
on: [push]
jobs:
  check:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      - run: sudo apt-get install -y swi-prolog
      - run: swipl -q -t halt -f license_policy.pl -- matrix
      - run: swipl -q -t halt -f license_policy.pl -- check agpl_3_0 mit

Call from Python

import subprocess

result = subprocess.run(
    ["swipl", "-q", "-t", "halt", "-f", "license_policy.pl", "--", "select", "saas_wrapper"],
    capture_output=True,
    text=True
)

print(result.stdout)  # Recommended License: agpl_3_0

Call from Rust

use std::process::Command;

let output = Command::new("swipl")
    .args(&["-q", "-t", "halt", "-f", "license_policy.pl", "--", "matrix"])
    .output()?;

println!("{}", String::from_utf8_lossy(&output.stdout));

Examples

Example 1: SaaS Wrapper

Question: I'm wrapping this code in a SaaS product. Which license applies?

$ swipl -q -t halt -f license_policy.pl -- select saas_wrapper
Recommended License: agpl_3_0

Answer: AGPL-3.0. Network distribution triggers copyleft disclosure.


Example 2: Enterprise Integration

Question: We want to use this at enterprise scale but not offer it as a managed service. Which license?

$ swipl -q -t halt -f license_policy.pl -- select enterprise_restricted
Recommended License: bsl_1_1

Answer: BSL-1.1. Source-available with commercial restrictions.


Example 3: File Modification

Question: I'm only modifying 3 specific files, not the whole codebase. Which license?

$ swipl -q -t halt -f license_policy.pl -- select file_level_mod
Recommended License: mpl_2_0

Answer: MPL-2.0. File-level copyleft, can combine with proprietary code.


Example 4: Commercial Bypass

Question: We want to bypass all copyleft restrictions. What do we need?

$ swipl -q -t halt -f license_policy.pl -- select copyleft_bypass
Recommended License: commercial

Answer: Commercial license. Contact: ahmedparr93@gmail.com


Extending the Engine

Add a New Use Case

% In license_policy.pl
use_case(embedded_device, bsl_1_1).

Add a New Compatibility Rule

% LGPL can link with proprietary
compatible(lgpl_3_0, proprietary).

Add License Validation

% Check if a license requires source disclosure
requires_disclosure(License) :-
    member(License, [agpl_3_0, bsl_1_1, mpl_2_0]).

Theory

License Compatibility Graph

       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
       β”‚  Commercial β”‚
       β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
             β”‚
       β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”
       β”‚     BSL     β”‚ (converts to AGPL after 2 years)
       β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
             β”‚
       β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”
       β”‚    AGPL     β”‚ (network copyleft)
       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
       β”‚     MPL     β”‚ (file-level copyleft)
       β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”˜
             β”‚
       β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”
       β”‚ Proprietary β”‚
       β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Compatibility Rules

  • Strong copyleft (AGPL): Can absorb permissive/weak copyleft, but infects the whole
  • Weak copyleft (MPL): File-level boundary, can link with proprietary
  • BSL: Source-available but restricted, converts to copyleft after transition
  • Commercial: Bypasses all restrictions

Requirements

  • SWI-Prolog 8.0+
# Install SWI-Prolog
# macOS
brew install swi-prolog

# Ubuntu/Debian
sudo apt-get install swi-prolog

# Windows
# Download from https://www.swi-prolog.org/download/stable

License

This engine itself is tri-licensed under BSL-1.1 + AGPL-3.0 + MPL-2.0.

Use the engine to determine which license applies to your use case.


Contact

Ahmad Ali Parr
Bel Esprit D'Accord Irrevocable Trust
SnapKitty Collective Limited (FLP)

Email: ahmedparr93@gmail.com
GitHub: https://github.com/SNAPKITTYWEST/license-policy-engine

Downloads last month

-

Downloads are not tracked for this model. How to track
Inference Providers NEW
This model isn't deployed by any Inference Provider. πŸ™‹ Ask for provider support

Space using Snapkitty/license-policy-engine 1