|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| .type AgentID = symbol
|
| .type ActorNum = number
|
| .type EventID = unsigned
|
| .type Hash32 = symbol
|
| .type Capability = symbol
|
| .type EventType = unsigned
|
| .type Weight = unsigned
|
|
|
|
|
|
|
|
|
| .decl actor(id: ActorNum, name: AgentID)
|
| actor(1, "bob").
|
| actor(2, "metatron").
|
| actor(3, "edaulc").
|
| actor(4, "autonomous").
|
|
|
| .decl capability(actor_id: ActorNum, cap: Capability)
|
| capability(1, "execute").
|
| capability(1, "write").
|
| capability(2, "read").
|
| capability(2, "verify").
|
| capability(3, "observe").
|
| capability(4, "vacuum_collapse").
|
|
|
| .decl target(id: number, resource: symbol)
|
| target(100, "memory").
|
| target(101, "stack").
|
| target(102, "entropy_pool").
|
| target(200, "seb_chain").
|
| target(201, "seb_partition").
|
| target(202, "seb_fiscal").
|
|
|
| .decl precondition_met(actor_id: ActorNum, target_id: number)
|
| precondition_met(1, 100).
|
| precondition_met(1, 101).
|
| precondition_met(1, 200).
|
| precondition_met(1, 201).
|
| precondition_met(2, 100).
|
| precondition_met(2, 200).
|
| precondition_met(3, 200).
|
| precondition_met(4, 102).
|
| precondition_met(4, 202).
|
|
|
|
|
|
|
| .decl si_authorized(actor_id: ActorNum, target_id: number, cap: Capability)
|
| .decl si_denied(actor_id: ActorNum, target_id: number, reason: symbol)
|
|
|
| si_authorized(A, T, C) :-
|
| actor(A, _),
|
| capability(A, C),
|
| target(T, _),
|
| precondition_met(A, T).
|
|
|
| si_denied(A, T, "no_capability") :-
|
| actor(A, _),
|
| target(T, _),
|
| !capability(A, _).
|
|
|
| si_denied(A, T, "precondition_failed") :-
|
| actor(A, _),
|
| capability(A, _),
|
| target(T, _),
|
| !precondition_met(A, T).
|
|
|
|
|
|
|
| .decl agent_competency(a: AgentID, c: Capability)
|
| .decl agent_status(a: AgentID, s: symbol)
|
| .decl event_schema(t: EventType, schema_hash: Hash32, req_cap: Capability, weight: Weight)
|
| .decl event_header(offset: EventID, agent: AgentID, etype: EventType,
|
| prev_hash: Hash32, event_hash: Hash32, sig: symbol, payload_hash: Hash32)
|
| .decl bifrost_confirmed(offset: EventID)
|
|
|
|
|
| agent_competency("bob", "execute") :- capability(1, "execute").
|
| agent_competency("bob", "write") :- capability(1, "write").
|
| agent_competency("metatron", "read") :- capability(2, "read").
|
| agent_competency("metatron", "verify") :- capability(2, "verify").
|
| agent_competency("edaulc", "observe") :- capability(3, "observe").
|
| agent_competency("autonomous", "vacuum_collapse") :- capability(4, "vacuum_collapse").
|
|
|
|
|
|
|
| .decl verified_agent(a: AgentID, offset: EventID)
|
| verified_agent(A, O) :-
|
| event_header(O, A, _, _, EH, Sig, PH),
|
| ed25519_verify(A, EH, Sig),
|
| lattice_verify(PH, EH),
|
| bifrost_confirmed(O).
|
|
|
|
|
|
|
| .decl authorized(a: AgentID, offset: EventID)
|
| authorized(A, O) :-
|
| verified_agent(A, O),
|
| event_header(O, _, ET, _, _, _, _),
|
| event_schema(ET, _, C, _),
|
| agent_competency(A, C),
|
| agent_status(A, "active"),
|
| !agent_status(A, "revoked").
|
|
|
|
|
|
|
|
|
|
|
| .decl constitution_denied(a: AgentID, offset: EventID, reason: symbol)
|
|
|
|
|
| constitution_denied(A, O, "capability_mismatch") :-
|
| event_header(O, A, ET, _, _, _, _),
|
| event_schema(ET, _, ReqCap, _),
|
| !agent_competency(A, ReqCap).
|
|
|
|
|
| constitution_denied(A, O, "requires_vacuum_collapse") :-
|
| event_header(O, A, 0xFFFF, _, _, _, _),
|
| !agent_competency(A, "vacuum_collapse").
|
|
|
|
|
|
|
| .decl fiscal_ok(a: AgentID, offset: EventID)
|
| fiscal_ok(A, O) :-
|
| event_header(O, _, ET, _, _, _, _),
|
| event_schema(ET, _, _, W),
|
| W != 0xFFFFFFFF.
|
| fiscal_ok(A, O) :-
|
| event_header(O, _, ET, _, _, _, _),
|
| event_schema(ET, _, _, W),
|
| W = 0xFFFFFFFF,
|
| treasury_balance(A, B),
|
| B >= W.
|
|
|
|
|
|
|
| .decl kernel_authorize(a: AgentID, offset: EventID)
|
| kernel_authorize(A, O) :-
|
| authorized(A, O),
|
| fiscal_ok(A, O),
|
| !constitution_denied(A, O, _).
|
|
|
|
|
|
|
| .decl convergence_event(offset: EventID, event_type: symbol, delta: float)
|
| .decl attack_condition(reason: symbol)
|
|
|
| attack_condition("negative_universe_sum") :-
|
| convergence_event(_, "attack_detected", D),
|
| D < 0.0.
|
|
|
|
|
|
|
| .decl si_actor_authorized(name: AgentID, resource: symbol)
|
| si_actor_authorized(N, R) :-
|
| actor(A, N),
|
| target(T, R),
|
| si_authorized(A, T, _).
|
|
|
| .output kernel_authorize
|
| .output si_authorized
|
| .output si_denied
|
| .output constitution_denied
|
| .output attack_condition
|
| .output si_actor_authorized
|
|
|
|
|
|
|
| .external ed25519_verify(pubkey: symbol, msg: symbol, sig: symbol) : bool
|
| .external lattice_verify(prev_hash: symbol, event_hash: symbol) : bool
|
| .external treasury_balance(agent: symbol, balance: unsigned) : bool
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| .decl floating_agent(a: AgentID, reason: symbol)
|
| .decl reachable_agent(a: AgentID)
|
|
|
|
|
| reachable_agent(A) :- si_authorized(Num, _, _), actor(Num, A).
|
| reachable_agent(A) :- kernel_authorize(A, _).
|
|
|
|
|
| floating_agent(A, "no_authorized_target") :-
|
| actor(_, A),
|
| !reachable_agent(A).
|
|
|
|
|
| floating_agent(A, "all_capabilities_revoked") :-
|
| actor(_, A),
|
| agent_status(A, "revoked").
|
|
|
|
|
|
|
| .decl agent_edge(from_agent: AgentID, to_agent: AgentID)
|
| agent_edge(A, B) :-
|
| kernel_authorize(A, O),
|
| event_header(O, B, _, _, _, _, _).
|
|
|
| .decl agent_reachable(a: AgentID, b: AgentID)
|
| agent_reachable(A, B) :- agent_edge(A, B).
|
| agent_reachable(A, C) :- agent_reachable(A, B), agent_edge(B, C).
|
|
|
| .output floating_agent
|
| .output reachable_agent
|
|
|
|
|
|
|
|
|
| .decl convergence_event(offset: EventID, etype: symbol, delta: float)
|
| .decl attack_condition(reason: symbol)
|
|
|
| attack_condition("negative_universe_sum") :-
|
| convergence_event(_, "attack_detected", D),
|
| D < 0.0.
|
|
|
| .output attack_condition
|
|
|