Writing Policies
Writing Policies
Section titled “Writing Policies”Brane uses eFLINT to express data access policies. eFLINT is a formal language for institutional rules — it lets you declare what actions are permitted or prohibited under specific conditions.
eFLINT Basics
Section titled “eFLINT Basics”eFLINT works with a few core concepts:
- Facts — Things that are true (e.g., “this dataset exists”, “this user is authorized”)
- Acts — Actions that can happen (e.g., “access data”, “run function”)
- Duties — Obligations that must be fulfilled
- Violations — Conditions that indicate a rule has been broken
Example: Hospital Data Policy
Section titled “Example: Hospital Data Policy”Here’s a policy that allows local model training but prevents raw data export:
// Define the facts about our domainFact dataset Identified by name.Fact function Identified by name.Fact user Identified by name.
// Define possible actionsAct access-dataset Actor user Recipient dataset.
Act run-function Actor user Recipient function.
Act export-data Actor user Recipient dataset.
// Rules: allow local operations, deny export+run-function When function.name == "train_local".+access-dataset When True.-export-data When True.This policy:
- Allows any user to access datasets on this node
- Allows the
train_localfunction to execute - Denies all data export operations
Common Policy Patterns
Section titled “Common Policy Patterns”Allow All (Development Only)
Section titled “Allow All (Development Only)”// WARNING: Only use for testing+access-dataset When True.+run-function When True.+export-data When True.Deny All (Default)
Section titled “Deny All (Default)”The default policy when no rules are set. All actions are denied.
Allow Specific Functions
Section titled “Allow Specific Functions”+run-function When function.name == "aggregate_results".+run-function When function.name == "compute_statistics".-run-function When True.Allow Results but Not Raw Data
Section titled “Allow Results but Not Raw Data”+access-dataset When True.+run-function When True.-export-data When dataset.type == "raw".+export-data When dataset.type == "aggregated".Deploying Policies
Section titled “Deploying Policies”Using the Policy Reasoner GUI
Section titled “Using the Policy Reasoner GUI”- Open the GUI in your browser
- Enter the node address and your access token
- Write or paste your eFLINT policy
- Click “Activate” to deploy
Using branectl
Section titled “Using branectl”branectl policy push ./my-policy.eflint \ --node http://<WORKER_ADDRESS> \ --token ./policy_token.json
branectl policy activate <POLICY_ID> \ --node http://<WORKER_ADDRESS> \ --token ./policy_token.jsonTesting Policies
Section titled “Testing Policies”Offline Testing
Section titled “Offline Testing”Use the eFLINT REPL to test your policies without deploying:
eflint-repl my-policy.eflintIn the REPL, you can:
- Create test facts
- Attempt actions and see if they are allowed
- Inspect the current state
On the Node
Section titled “On the Node”After deploying, test by running workflows that exercise your policy rules. Check that:
- Allowed operations succeed
- Denied operations fail with policy violation errors
- Start with a deny-all policy and explicitly allow what’s needed
- Test policies offline before deploying to a live node
- Document each policy rule with comments explaining the rationale
- Review policies regularly as requirements change
- Coordinate with other domain administrators when cross-domain operations are needed