Class: MandateClaw::DSL::Contract
- Inherits:
-
Object
- Object
- MandateClaw::DSL::Contract
- Defined in:
- lib/mandate_claw/dsl/contract.rb
Overview
Base class for all MandateClaw contracts.
Usage:
class InvoiceContract < MandateClaw::DSL::Contract
contract do
party :buyer, identifies_by: :customer_id
party :seller, identifies_by: :merchant_id
party :ai_agent, identifies_by: :agent_did, kind: :autonomous
obligation :pay_invoice, on: :buyer, within: 30.days, breach: :late_payment_penalty
:dispute, on: :buyer, within: 7.days, event: :raise_dispute
prohibition :unilateral_amend, on: :ai_agent, breach: :void_transition
agent_bounds :ai_agent do
may :issue_invoice, :send_reminder
must_not :modify_amount, :waive_penalty
must_log_to :contract_registry
end
attestation do
require_signature_from :buyer, :seller, :ai_agent
sign_with :ed25519
end
end
end
Class Attribute Summary collapse
-
._agent_bounds ⇒ Object
readonly
Returns the value of attribute _agent_bounds.
-
._attestation ⇒ Object
readonly
Returns the value of attribute _attestation.
-
._contract_name ⇒ Object
readonly
Returns the value of attribute _contract_name.
-
._obligations ⇒ Object
readonly
Returns the value of attribute _obligations.
-
._parties ⇒ Object
readonly
Returns the value of attribute _parties.
-
._permissions ⇒ Object
readonly
Returns the value of attribute _permissions.
-
._prohibitions ⇒ Object
readonly
Returns the value of attribute _prohibitions.
-
._rules ⇒ Object
readonly
Returns the value of attribute _rules.
Class Method Summary collapse
- .autonomous_parties ⇒ Object
- .contract(name = nil, &block) ⇒ Object
- .to_markdown ⇒ Object
- .validate! ⇒ Object
Class Attribute Details
._agent_bounds ⇒ Object (readonly)
Returns the value of attribute _agent_bounds.
36 37 38 |
# File 'lib/mandate_claw/dsl/contract.rb', line 36 def _agent_bounds @_agent_bounds end |
._attestation ⇒ Object (readonly)
Returns the value of attribute _attestation.
36 37 38 |
# File 'lib/mandate_claw/dsl/contract.rb', line 36 def _attestation @_attestation end |
._contract_name ⇒ Object (readonly)
Returns the value of attribute _contract_name.
36 37 38 |
# File 'lib/mandate_claw/dsl/contract.rb', line 36 def _contract_name @_contract_name end |
._obligations ⇒ Object (readonly)
Returns the value of attribute _obligations.
36 37 38 |
# File 'lib/mandate_claw/dsl/contract.rb', line 36 def _obligations @_obligations end |
._parties ⇒ Object (readonly)
Returns the value of attribute _parties.
36 37 38 |
# File 'lib/mandate_claw/dsl/contract.rb', line 36 def _parties @_parties end |
._permissions ⇒ Object (readonly)
Returns the value of attribute _permissions.
36 37 38 |
# File 'lib/mandate_claw/dsl/contract.rb', line 36 def @_permissions end |
._prohibitions ⇒ Object (readonly)
Returns the value of attribute _prohibitions.
36 37 38 |
# File 'lib/mandate_claw/dsl/contract.rb', line 36 def _prohibitions @_prohibitions end |
._rules ⇒ Object (readonly)
Returns the value of attribute _rules.
36 37 38 |
# File 'lib/mandate_claw/dsl/contract.rb', line 36 def _rules @_rules end |
Class Method Details
.autonomous_parties ⇒ Object
62 63 64 |
# File 'lib/mandate_claw/dsl/contract.rb', line 62 def autonomous_parties _parties.select { |_, p| p.kind == :autonomous }.keys end |
.contract(name = nil, &block) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/mandate_claw/dsl/contract.rb', line 40 def contract(name = nil, &block) @_contract_name = name || self.name&.underscore&.to_sym || :unnamed @_parties = {} @_obligations = [] @_permissions = [] @_prohibitions = [] @_agent_bounds = {} @_attestation = nil @_rules = [] DSL::ContractBuilder.new(self).instance_eval(&block) if block_given? self end |
.to_markdown ⇒ Object
58 59 60 |
# File 'lib/mandate_claw/dsl/contract.rb', line 58 def to_markdown MandateClaw::Renderers::MarkdownRenderer.new(self).render end |
.validate! ⇒ Object
54 55 56 |
# File 'lib/mandate_claw/dsl/contract.rb', line 54 def validate! MandateClaw::Validators::ContractValidator.new(self).validate! end |