Taskweft.ReBAC (taskweft_rebac v0.2.0-dev.0)

Copy Markdown View Source

Relationship-Based Access Control (ReBAC) graph engine.

Wraps the C++ tw_rebac.hpp via Fine NIF. The graph is passed as a JSON string (wire format: {"edges":[{"subject","object","rel"}],"definitions":{}}). Relation expressions (RelExpr) are also JSON maps:

{"type":"base","rel":"OWNS"}
{"type":"union","a":{...},"b":{...}}
{"type":"intersection","a":{...},"b":{...}}
{"type":"difference","a":{...},"b":{...}}
{"type":"tuple_to_userset","pivot_rel":"IS_MEMBER_OF","inner":{...}}

Valid relation names: HAS_CAPABILITY, CONTROLS, OWNS, IS_MEMBER_OF, DELEGATED_TO, SUPERVISOR_OF, PARTNER_OF, CAN_ENTER, CAN_INSTANCE.

Summary

Functions

Add a directed edge (subj)-[rel]->(obj) to the graph.

Check whether subj satisfies expr_json with respect to obj.

Convenience helper for a simple base relation check.

Expand rel → all subjects that hold rel to obj.

Return an empty graph JSON string.

Parse relation edges from a list of memory facts.

Functions

add_edge(graph_json, subj, obj, rel)

Add a directed edge (subj)-[rel]->(obj) to the graph.

check(graph_json, subj, expr_json, obj, fuel \\ 8)

Check whether subj satisfies expr_json with respect to obj.

fuel limits recursive expansion depth (default 8). Returns true or false.

check_rel(graph_json, subj, rel, obj, fuel \\ 8)

Convenience helper for a simple base relation check.

check_rel(graph, "alice", "OWNS", "resource_x")

expand(graph_json, rel, obj, fuel \\ 8)

Expand rel → all subjects that hold rel to obj.

Follows IS_MEMBER_OF transitive chains up to fuel hops. Returns a list of subject strings.

new_graph()

Return an empty graph JSON string.

parse_relation_edges(facts_json, trust_threshold \\ 0.5)

Parse relation edges from a list of memory facts.

facts_json is a JSON array of {content, trust_score?, ...} objects. Sentences matching known verb phrases (owns, controls, delegates to, etc.) become edges. Returns a graph JSON string.