{"graphCode":"qr-pass","graphRevision":"1.0.0","checksum":"c424213f92c530cf4f68e2633241d3f2670058cd32ab07ce04d5e57ecb623709","extensionChecksum":"77f4b85c2d6e13a0ddcffefef30fd349daf829608b56acf26d2781c784bdc7f7","json":"{\n  \"graph_code\": \"qr-pass\",\n  \"graph_id\": 62108,\n  \"root_node_id\": 10,\n  \"graph_version\": \"1.0.0\",\n  \"dsl_version\": \"1.0\",\n  \"schema_version\": \"1.0\",\n  \"strict_validation\": true,\n  \"default_lang\": \"en\",\n  \"allowed_langs\": [\n    \"en\",\n    \"es\"\n  ],\n  \"nodes\": [\n    {\n      \"id\": 10,\n      \"is_terminal\": false\n    },\n    {\n      \"id\": 90,\n      \"is_terminal\": true\n    }\n  ],\n  \"edges\": [\n    {\n      \"id\": 101,\n      \"from\": 10,\n      \"to\": 90\n    }\n  ],\n  \"labels\": [\n    {\n      \"edge_id\": 101,\n      \"lang\": \"en\",\n      \"text\": \"Create pass\"\n    },\n    {\n      \"edge_id\": 101,\n      \"lang\": \"es\",\n      \"text\": \"Crear acreditación\"\n    }\n  ],\n  \"metadata\": [\n    {\n      \"id\": 101,\n      \"node_id\": 10,\n      \"lang\": \"en\",\n      \"title\": \"Visitor name\",\n      \"description\": \"Use a fictional first name, which will appear in the link.\",\n      \"extras\": {\n        \"inputs\": [\n          {\n            \"key\": \"name\",\n            \"type\": \"text\",\n            \"label\": \"First name\",\n            \"minLength\": 1,\n            \"maxLength\": 30,\n            \"characterClass\": \"unicode-letter\"\n          }\n        ]\n      }\n    },\n    {\n      \"id\": 102,\n      \"node_id\": 10,\n      \"lang\": \"es\",\n      \"title\": \"Nombre del visitante\",\n      \"description\": \"Utiliza un nombre ficticio, que aparecerá en el enlace.\",\n      \"extras\": {\n        \"inputs\": [\n          {\n            \"key\": \"name\",\n            \"type\": \"text\",\n            \"label\": \"Nombre\",\n            \"minLength\": 1,\n            \"maxLength\": 30,\n            \"characterClass\": \"unicode-letter\"\n          }\n        ]\n      }\n    },\n    {\n      \"id\": 901,\n      \"node_id\": 90,\n      \"lang\": \"en\",\n      \"title\": \"Visitor pass\",\n      \"description\": \"Demo pass, not an access credential.\"\n    },\n    {\n      \"id\": 902,\n      \"node_id\": 90,\n      \"lang\": \"es\",\n      \"title\": \"Acreditación de visitante\",\n      \"description\": \"Acreditación ficticia, no es una credencial de acceso.\"\n    }\n  ],\n  \"conditions\": [],\n  \"outputs\": []\n}\n","dsl":"flow qr-pass {\n  graph_id 62108\n  lang en, es\n  default_lang \"en\"\n  version \"1.0.0\"\n  dsl_version \"1.0\"\n  schema_version \"1.0\"\n  nodes {\n    node 10 root {\n      meta en {\n        id 101\n        title \"Visitor name\"\n        description \"Use a fictional first name, which will appear in the link.\"\n        extras {\"inputs\":[{\"key\":\"name\",\"type\":\"text\",\"label\":\"First name\",\"minLength\":1,\"maxLength\":30,\"characterClass\":\"unicode-letter\"}]}\n      }\n      meta es {\n        id 102\n        title \"Nombre del visitante\"\n        description \"Utiliza un nombre ficticio, que aparecerá en el enlace.\"\n        extras {\"inputs\":[{\"key\":\"name\",\"type\":\"text\",\"label\":\"Nombre\",\"minLength\":1,\"maxLength\":30,\"characterClass\":\"unicode-letter\"}]}\n      }\n    }\n    node 90 terminal {\n      meta en {\n        id 901\n        title \"Visitor pass\"\n        description \"Demo pass, not an access credential.\"\n      }\n      meta es {\n        id 902\n        title \"Acreditación de visitante\"\n        description \"Acreditación ficticia, no es una credencial de acceso.\"\n      }\n    }\n  }\n  edges {\n    edge 101: 10 -> 90 {\n      label en \"Create pass\"\n      label es \"Crear acreditación\"\n    }\n  }\n  terminals {\n    terminal 90 {\n    }\n  }\n}\n","files":{"qr-pass-plugin.json":"{\n  \"name\": \"showcase-qr-pass\",\n  \"version\": \"1.0.0\",\n  \"requires\": {\n    \"execkernel\": \">=1.0.0 <=1.0.0\"\n  },\n  \"provides\": {\n    \"terminal_outputs\": [\"qr-pass\"],\n    \"outputs\": [\"Showcase\\\\QrPass\\\\QrPassPayloadHook\"]\n  }\n}\n","QrPassType.php":"<?php\ndeclare(strict_types=1);\n\nnamespace Showcase\\QrPass;\n\nuse InvalidArgumentException;\n\n\/** Bounded custom output contract. No credentials, IO or access authority. *\/\nfinal class QrPassType\n{\n    public const TYPE='qr-pass';\n    public const PATH='\/qr-pass\/pass\/';\n    public const MAX_NAME=30;\n\n    public function __construct(public readonly string $origin)\n    {\n        if (!self::validOrigin($origin)) throw new InvalidArgumentException('Invalid configured QR origin');\n    }\n\n    private static function validOrigin(string $origin):bool\n    {\n        \/\/ Operator configuration, never request-derived. An absolute HTTP(S)\n        \/\/ origin only; reject user info, paths, query, fragments and escapes.\n        if (strlen($origin)>300 || !preg_match('~\\Ahttps?:\/\/[A-Za-z0-9.\\-:\\[\\]]+\\z~D',$origin)) return false;\n        $parts=parse_url($origin);\n        if (!is_array($parts)||!isset($parts['scheme'],$parts['host'])||\n            array_diff(array_keys($parts),['scheme','host','port'])) return false;\n        $host=$parts['host'];$port=$parts['port']??null;\n        $ipv6=str_starts_with($host,'[')&&str_ends_with($host,']')\n            &&filter_var(substr($host,1,-1),FILTER_VALIDATE_IP,FILTER_FLAG_IPV6)!==false;\n        $dns=preg_match('\/\\A(?=.{1,253}\\z)(?:[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)(?:\\.[A-Za-z0-9](?:[A-Za-z0-9-]{0,61}[A-Za-z0-9])?)*\\z\/D',$host)===1;\n        if (!$ipv6&&!$dns) return false;\n        \/\/ Reject noncanonical numeric hosts (octal\/hex\/short IPv4 forms).\n        if (!$ipv6&&preg_match('\/(?:\\A|\\.)(?:[0-9]+|0[xX][0-9a-fA-F]+)\\z\/D',$host)\n            &&filter_var($host,FILTER_VALIDATE_IP,FILTER_FLAG_IPV4)===false) return false;\n        return ($port===null||($port>=1&&$port<=65535))\n            &&$origin===$parts['scheme'].':\/\/'.$host.($port===null?'':':'.$port);\n    }\n\n    public static function validName(mixed $name):bool\n    {\n        \/\/ UTF-8 letters only (Unicode L). No trim, case-fold, normalization,\n        \/\/ truncation, combining marks, separators, digits or control codes.\n        return is_string($name)&&strlen($name)<=self::MAX_NAME*4\n            &&preg_match('\/\\A\\p{L}{1,30}\\z\/uD',$name)===1;\n    }\n\n    public static function nameFromPath(string $uri):?string\n    {\n        if (!str_starts_with($uri,self::PATH)||strlen($uri)>strlen(self::PATH)+self::MAX_NAME*12) return null;\n        $encoded=substr($uri,strlen(self::PATH));\n        $name=rawurldecode($encoded);\n        \/\/ Exactly the canonical path segment generated by the hook.\n        \/\/ Never decode twice, accept aliases, queries, or extra path segments.\n        return self::validName($name)&&rawurlencode($name)===$encoded?$name:null;\n    }\n\n    public function output(string $name,string $lang):array\n    {\n        if (!self::validName($name)||!in_array($lang,['en','es'],true)) throw new InvalidArgumentException('Invalid QR pass values');\n        return ['node_id'=>90,'type'=>self::TYPE,'url'=>$this->origin.self::PATH.rawurlencode($name),\n            'label'=>$lang==='es'?'Abrir acreditación':'Open pass','open_behavior'=>'new_tab','lang'=>$lang,'content'=>$name];\n    }\n\n    public function validate(array $output):bool\n    {\n        if (!self::validName($output['content']??null)||!in_array($output['lang']??null,['en','es'],true))return false;\n        $expected=$this->output($output['content'],$output['lang']);\n        \/\/ Match every declared field and reject extra fields, independent of order.\n        if(count($output)!==count($expected))return false;\n        foreach($expected as $key=>$value)if(!array_key_exists($key,$output)||$output[$key]!==$value)return false;\n        return true;\n    }\n}\n","QrPassPayloadHook.php":"<?php\ndeclare(strict_types=1);\n\nnamespace Showcase\\QrPass;\n\nuse ExecKernel\\Domain\\Engine\\PayloadOutputHookInterface;\nuse ExecKernel\\Domain\\Graph\\Graph;\nuse ExecKernel\\Domain\\Session\\SessionState;\nuse RuntimeException;\n\n\/** A pure presentation hook; the engine's registry validates its output. *\/\nfinal class QrPassPayloadHook implements PayloadOutputHookInterface\n{\n    public function __construct(private readonly QrPassType $type) {}\n\n    public function apply(Graph $graph,SessionState $state,string $lang,array $payload):array\n    {\n        if($graph->graphId!==62108||$state->graphCode!=='qr-pass')throw new RuntimeException('Unexpected QR graph');\n        $context=$state->context->toArray();\n        if($state->currentNodeId===10&&($payload['type']??null)==='node'&&$context===[])return $payload;\n        if($state->currentNodeId!==90||($payload['type']??null)!=='terminal'||($payload['outputs']??null)!==[]\n            ||array_keys($context)!==['name']||!QrPassType::validName($context['name']))\n            throw new RuntimeException('Unexpected QR terminal state');\n        $payload['outputs'][]=$this->type->output($context['name'],$lang);\n        return $payload;\n    }\n}\n","QrPassPlugin.php":"<?php\ndeclare(strict_types=1);\n\nnamespace Showcase\\QrPass;\n\nuse ExecKernel\\Domain\\Engine\\{PluginInterface,PluginRegistry};\n\nfinal class QrPassPlugin implements PluginInterface\n{\n    public function __construct(private readonly QrPassType $type) {}\n\n    public function register(PluginRegistry $registry):void\n    {\n        $type=$this->type;\n        $registry->addTerminalOutputType(QrPassType::TYPE,static fn(array $output):bool=>$type->validate($output));\n        $registry->addOutputHook(QrPassPayloadHook::class,static fn()=>new QrPassPayloadHook($type));\n    }\n    public function boot():void {}\n}\n","PluginRegistration.php":"<?php\ndeclare(strict_types=1);\n\nnamespace Showcase\\QrPass;\n\nuse ExecKernel\\Domain\\Engine\\{ExecKernel,PluginRegistry};\nuse ExecKernel\\Domain\\Versioning\\CompatibilityMode;\nuse ExecKernel\\Infrastructure\\Engine\\ExecKernelFactory;\nuse ExecKernel\\Infrastructure\\Loader\\ArrayGraphLoader;\nuse RuntimeException;\n\nfinal class PluginRegistration\n{\n    public const TTL=3600;\n    public const FILES=['qr-pass-plugin.json','QrPassType.php','QrPassPayloadHook.php','QrPassPlugin.php','PluginRegistration.php'];\n\n    public static function sources():array\n    {\n        $files=[];\n        foreach(self::FILES as $name){\n            $raw=file_get_contents(__DIR__.'\/'.$name);\n            if($raw===false||$raw==='')throw new RuntimeException('Missing extension file');\n            $files[$name]=$raw;\n        }\n        return $files;\n    }\n    public static function registry(QrPassType $type):PluginRegistry\n    {\n        $registry=new PluginRegistry(engineVersion:'1.0.0',compatibilityMode:CompatibilityMode::STRICT);\n        $registry->registerPluginFromManifest(__DIR__.'\/qr-pass-plugin.json',new QrPassPlugin($type));\n        return $registry;\n    }\n    public static function loader(array $definition,?PluginRegistry $registry=null):ArrayGraphLoader\n    {\n        return new ArrayGraphLoader($definition,pluginRegistry:$registry,compatibilityMode:CompatibilityMode::STRICT);\n    }\n    public static function engine(QrPassType $type):ExecKernel\n    {\n        return (new ExecKernelFactory())->build(pluginRegistry:self::registry($type),sessionTtlSeconds:self::TTL);\n    }\n}\n"}}