{"record":"kye.contract","id":"kye:contract:kye-self:door:v1","version":"1.0.0","says":"The sandbox door: how an outside agent finds KYE's agent, opens a channel with it, asks for governed decisions over that channel, and gets the evidence pack of each one. Every binding (HTTP, MCP) and the discovery document are derived from this file; an operation that is not here does not exist.","environment":"sandbox","bindings":["mcp","http"],"guide":"This is KYE Protocol's sandbox door. Call kye_world to see the synthetic world, kye_open to open a channel (the handshake), then kye_decide on that channel, numbering messages from 1. Every decision returns its evidence pack, and the pack's seal when the notary has made one in time; kye_pack returns a pack again by its ID while it is kept, and has it sealed, if the notary can, when it was not. Opening a channel grants no authority to act.","definitions":{"id":{"type":"string","pattern":"^kye:[a-z0-9]+(-[a-z0-9]+)*(:[a-z0-9]+(-[a-z0-9]+)*){3}$","maxLength":320},"digest":{"type":"string","pattern":"^sha256:[0-9a-f]{64}$","maxLength":71},"instant":{"type":"string","pattern":"^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$","maxLength":20},"handle":{"type":"string","pattern":"^[a-z0-9]+(-[a-z0-9]+)*$","minLength":1,"maxLength":40},"text":{"type":"string","minLength":1,"maxLength":280},"token":{"type":"string","pattern":"^[A-Za-z0-9_-]{43}$","maxLength":43},"sequence":{"type":"integer","minimum":1,"maximum":1000000},"verdict":{"type":"string","enum":["ALLOW","DENY","HOLD","ERROR"]},"channel":{"type":"object","additionalProperties":false,"required":["id","parties","cardinality","purpose","contract","state","opened_at","expires_at","next_sequence"],"properties":{"id":{"$ref":"#/definitions/id"},"parties":{"type":"array","items":{"$ref":"#/definitions/id"},"minItems":2,"maxItems":2},"cardinality":{"type":"string","const":"1:1"},"purpose":{"$ref":"#/definitions/text"},"contract":{"$ref":"#/definitions/id"},"state":{"type":"string","enum":["open","closed","expired"]},"opened_at":{"$ref":"#/definitions/instant"},"expires_at":{"$ref":"#/definitions/instant"},"next_sequence":{"$ref":"#/definitions/sequence"}}},"evidence":{"type":"object","additionalProperties":false,"required":["decision_id","verdict","reason","pack_id","pack_digest","pack"],"properties":{"decision_id":{"$ref":"#/definitions/id"},"verdict":{"$ref":"#/definitions/verdict"},"reason":{"type":"string","pattern":"^[a-z0-9_]+$","maxLength":120},"pack_id":{"$ref":"#/definitions/id"},"pack_digest":{"$ref":"#/definitions/digest"},"pack":{"type":"object","opaque":"kye.evidence-pack"},"seal":{"type":"object","opaque":"kye.seal"}}}},"errors":{"input_refused":"What was sent is not what this operation takes. The message says which field and why.","handle_unknown":"No entity in the sandbox has this handle.","sandbox_full":"The sandbox holds as many channels as may be open at once. Channels expire: the message says in how many seconds the first of them is over.","sandbox_busy":"The sandbox has decided as much as it may this minute, for everyone together. Nothing was taken: send the same message again when the next minute begins, which the message says in seconds.","channel_unknown":"There is no such channel.","not_a_party":"The token is not the one this channel was opened with: the caller is not a party to it.","channel_not_open":"The channel was closed or has expired. Open a new one.","sequence_out_of_order":"The sequence number is not the next one on this channel. A message is taken once, in order.","channel_spent":"The channel has carried as many messages as it may. Open a new one.","pack_unknown":"No evidence pack with this ID is held here: none was issued, or it was issued longer ago than packs are kept (see the world's limits).","door_failed":"The door could not keep what it was doing. Nothing was taken: the same call can be made again."},"operations":[{"name":"resolve","title":"Resolve a handle","says":"Looks up a handle in the sandbox and returns the entity it is bound to: its permanent KYE ID, where its public keys are, and how to reach it. A handle is a name; authority never attaches to it.","effect":"read","channel":"none","input":{"type":"object","additionalProperties":false,"required":["handle"],"properties":{"handle":{"$ref":"#/definitions/handle"}}},"output":{"type":"object","additionalProperties":false,"required":["handle","id","kind","environment","keys_url","contract","contract_digest","bindings"],"properties":{"handle":{"$ref":"#/definitions/handle"},"id":{"$ref":"#/definitions/id"},"kind":{"type":"string","enum":["agent"]},"environment":{"type":"string","const":"sandbox"},"keys_url":{"type":"string","maxLength":300},"contract":{"$ref":"#/definitions/id"},"contract_digest":{"$ref":"#/definitions/digest"},"bindings":{"type":"array","maxItems":4,"items":{"type":"object","additionalProperties":false,"required":["binding","url"],"properties":{"binding":{"type":"string","enum":["http","mcp"]},"url":{"type":"string","maxLength":300}}}}}},"errors":["input_refused","handle_unknown","door_failed"]},{"name":"world","example":{"says":"See the world first: the actions, what a visitor is delegated, and the limits.","input":{}},"title":"See the sandbox world","says":"Returns the synthetic world the sandbox decides on: the actions that exist, which of them a visitor is delegated, and by whom, and the sandbox's limits: how many channels may be open at once, how many messages a channel carries, how long a channel and a visitor's delegation last, how many decisions the sandbox makes a minute for everyone together, and for how many hours a pack is kept. Nothing in it is real: every ID is in the kye-sandbox trust domain.","effect":"read","channel":"none","input":{"type":"object","additionalProperties":false,"required":[],"properties":{}},"output":{"type":"object","additionalProperties":false,"required":["issuer","accountable_person","door","limits","actions"],"properties":{"issuer":{"type":"string","const":"kye-sandbox:door"},"accountable_person":{"$ref":"#/definitions/id"},"door":{"$ref":"#/definitions/id"},"limits":{"type":"object","additionalProperties":false,"required":["channels","messages_per_channel","channel_minutes","delegation_hours","decisions_per_minute","pack_hours"],"properties":{"channels":{"type":"integer","minimum":1,"maximum":1000000},"messages_per_channel":{"type":"integer","minimum":1,"maximum":1000000},"channel_minutes":{"type":"integer","minimum":1,"maximum":1000000},"delegation_hours":{"type":"integer","minimum":1,"maximum":1000000},"decisions_per_minute":{"type":"integer","minimum":1,"maximum":1000000},"pack_hours":{"type":"integer","minimum":1,"maximum":1000000}}},"actions":{"type":"array","maxItems":20,"items":{"type":"object","additionalProperties":false,"required":["id","effect","approval","delegated_to_a_visitor","expect"],"properties":{"id":{"$ref":"#/definitions/id"},"effect":{"$ref":"#/definitions/text"},"approval":{"type":"string","enum":["none","owner"]},"delegated_to_a_visitor":{"type":"string","enum":["yes","no","yes-but-expired"]},"expect":{"$ref":"#/definitions/text"}}}}}},"errors":["input_refused","door_failed"]},{"name":"open","example":{"says":"The handshake. Give your agent a name and say why it is here.","input":{"visitor":"your-agent","purpose":"to see how KYE decides"}},"title":"Open a channel","says":"The handshake. Admits the visitor to the sandbox under a delegation from the sandbox's accountable person, then decides whether the visitor may open a channel with the door. On ALLOW a channel between exactly these two parties is opened and its token returned once. The decision and its evidence pack are returned whatever the verdict. Opening a channel grants no authority to act.","effect":"decide","channel":"opens","input":{"type":"object","additionalProperties":false,"required":["visitor","purpose"],"properties":{"visitor":{"$ref":"#/definitions/handle"},"purpose":{"$ref":"#/definitions/text"}}},"output":{"type":"object","additionalProperties":false,"required":["visitor","evidence"],"properties":{"visitor":{"$ref":"#/definitions/id"},"channel":{"$ref":"#/definitions/channel"},"token":{"$ref":"#/definitions/token"},"evidence":{"$ref":"#/definitions/evidence"}}},"errors":["input_refused","sandbox_full","sandbox_busy","door_failed"]},{"name":"decide","example":{"says":"Then, with the channel and the token that open returned, ask whether your agent may act. Number your messages from 1.","input":{"channel":"kye:channel:kye-sandbox:door:from-open","token":"TOKEN-RETURNED-BY-OPEN---------------------","sequence":1,"action":"kye:action:kye-sandbox:demo:read-balance","subject":"account 0001","purpose":"a test"}},"title":"Ask for a decision","says":"Sends one message on an open channel: the visitor asks whether it may take an action in the sandbox world. The kernel decides on the delegated authority alone and the decision is recorded in an evidence pack whatever the verdict: ALLOW, HOLD (an approval is required), or DENY. The pack comes with the notary's seal when the notary makes it in time; without one the decision stands, and the seal can be had later by fetching the pack. The message is taken once, in sequence: its number is used up only when its decision has been kept, so a message the door could not keep can be sent again. The pack's request names the channel and the message's number in its subject, before the subject given, so each message has a pack of its own.","effect":"decide","channel":"required","input":{"type":"object","additionalProperties":false,"required":["channel","token","sequence","action","subject","purpose"],"properties":{"channel":{"$ref":"#/definitions/id"},"token":{"$ref":"#/definitions/token"},"sequence":{"$ref":"#/definitions/sequence"},"action":{"$ref":"#/definitions/id"},"subject":{"$ref":"#/definitions/text"},"purpose":{"$ref":"#/definitions/text"}}},"output":{"type":"object","additionalProperties":false,"required":["channel","sequence","next_sequence","evidence"],"properties":{"channel":{"$ref":"#/definitions/id"},"sequence":{"$ref":"#/definitions/sequence"},"next_sequence":{"$ref":"#/definitions/sequence"},"evidence":{"$ref":"#/definitions/evidence"}}},"errors":["input_refused","channel_unknown","not_a_party","channel_not_open","sequence_out_of_order","channel_spent","sandbox_busy","door_failed"]},{"name":"close","title":"Close a channel","says":"Closes the channel. No message is taken on it afterwards.","effect":"write","channel":"closes","input":{"type":"object","additionalProperties":false,"required":["channel","token"],"properties":{"channel":{"$ref":"#/definitions/id"},"token":{"$ref":"#/definitions/token"}}},"output":{"type":"object","additionalProperties":false,"required":["channel"],"properties":{"channel":{"$ref":"#/definitions/channel"}}},"errors":["input_refused","channel_unknown","not_a_party","channel_not_open","door_failed"]},{"name":"pack","title":"Fetch an evidence pack","says":"Returns an evidence pack issued by the door, by its ID, with its seal. A pack the notary did not seal when it was issued is sealed now if the notary can and the sandbox has room this minute, and is otherwise returned without a seal; a seal made now is kept, which is the one thing this operation writes. The door is where a pack and its seal are kept, for the hours the world's limits say; keep your own copy of what you are returned. A pack carries everything needed to check the decision again offline: the request, the facts it was decided on, and the decision.","effect":"write","channel":"none","input":{"type":"object","additionalProperties":false,"required":["pack_id"],"properties":{"pack_id":{"$ref":"#/definitions/id"}}},"output":{"$ref":"#/definitions/evidence"},"errors":["input_refused","pack_unknown","door_failed"]}]}