piqrypt_verify_chain
Verify an agent's decision history for integrity, detecting tampering, missing events, chain breaks, or forks. Ensures the audit trail is untampered before trusting historical agent outputs.
Instructions
Verify that an agent's decision history is intact and untampered. Detects modified events, missing events, hash chain breaks, and forks. Call before trusting any historical agent output.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| events | Yes | Array of PiQrypt events to verify |
Implementation Reference
- src/python/bridge.py:123-172 (handler)The verify_chain() function is the actual handler that receives events from the TypeScript layer, looks up the agent identity, calls aiss.verify_chain(), and returns the validation result (valid, events_count, errors, vigil_url).
def verify_chain(params: Dict[str, Any]) -> Dict[str, Any]: """ Verify integrity of event chain. Args: params: dict with events list, optional agent_name Returns: dict with valid, events_count, errors, vigil_url """ events = params.get("events", []) agent_name = params.get("agent_name") errors = [] valid = False try: if agent_name: identity = aiss.load_agent_identity(agent_name) elif events: agent_id = events[0].get("agent_id", "") identity = _find_identity_by_agent_id(agent_id) if identity is None: return { "valid": False, "events_count": len(events), "errors": [ f"Identity not found locally for agent_id '{agent_id}'. " "Pass agent_name to verify a chain whose identity is stored here." ], "vigil_url": VIGIL_URL, } else: return { "valid": True, "events_count": 0, "errors": [], "vigil_url": VIGIL_URL, } valid = bool(aiss.verify_chain(events, identity)) except Exception as exc: errors.append(str(exc)) return { "valid": valid, "events_count": len(events), "errors": errors, "vigil_url": VIGIL_URL, } - src/index.ts:91-104 (schema)The input schema for piqrypt_verify_chain tool. Defines the 'events' array parameter as required input.
{ name: 'piqrypt_verify_chain', description: 'Verify that an agent\'s decision history is intact and untampered. Detects modified events, missing events, hash chain breaks, and forks. Call before trusting any historical agent output.', inputSchema: { type: 'object', properties: { events: { type: 'array', description: 'Array of PiQrypt events to verify', items: { type: 'object' }, }, }, required: ['events'], }, - src/index.ts:203-207 (registration)The tool registration inside the CallToolRequestSchema handler. Maps tool name 'piqrypt_verify_chain' to callPythonBridge('verify', {events: args.events}).
case 'piqrypt_verify_chain': result = callPythonBridge('verify', { events: args.events, }); break; - src/index.ts:92-92 (registration)Tool definition in the tools array, listing name, description, and inputSchema for piqrypt_verify_chain.
name: 'piqrypt_verify_chain', - src/python/bridge.py:138-164 (helper)Core verification logic: resolves identity (via agent_name or agent_id from events), calls aiss.verify_chain(events, identity), and catches exceptions to populate errors list.
try: if agent_name: identity = aiss.load_agent_identity(agent_name) elif events: agent_id = events[0].get("agent_id", "") identity = _find_identity_by_agent_id(agent_id) if identity is None: return { "valid": False, "events_count": len(events), "errors": [ f"Identity not found locally for agent_id '{agent_id}'. " "Pass agent_name to verify a chain whose identity is stored here." ], "vigil_url": VIGIL_URL, } else: return { "valid": True, "events_count": 0, "errors": [], "vigil_url": VIGIL_URL, } valid = bool(aiss.verify_chain(events, identity)) except Exception as exc: