<?php
// C-only shadow. Inclusion and --gate never load config or connect.
function pc_reference(){return json_decode(<<<'PC_REFERENCE_JSON'
{
  "contract": {
    "status": "ROOT_AUTHORIZED_C_SHADOW_ONCE_AFTER_PURE_GATES_NOT_BUSINESS_DDL",
    "lane": "C",
    "marker": "CDXPPUT261011S1",
    "table": "ZHCT_APP.CDX_PPUT261011_S1",
    "trigger": "TRG_CDX_PPUT261011_S1",
    "pk": "PK_CDX_PPUT261011_S1",
    "columns": [
      "ID",
      "LEASE_ID",
      "MEAL_ORDER_ID",
      "MEAL_ORDER_NO",
      "USER_ID",
      "UPDATE_BY",
      "RAW_REQUEST_A",
      "EXPIRE_TIME",
      "CREATE_TIME",
      "UPDATE_TIME"
    ],
    "budget": {
      "read": 132,
      "DML": 28,
      "DDL": 5,
      "HTTP": 0,
      "business_writes": 0,
      "max_rows": 4
    },
    "connection": {
      "host": "127.0.0.1",
      "port": "5237",
      "schema": "ZHCT_APP",
      "config_path": "/tmp/zhct-dm-poc-20260928.fcpiiN/store/application/database.php",
      "expected_version_banners": [
        "DM Database Server 64 V8",
        "8.4",
        "企业版",
        "DB Version: 0x7000d",
        "03134284488-20260212-314192-20200",
        "Msg Version: 1",
        "Gsu level(5) cnt: 102"
      ]
    },
    "runtime_directory": "/tmp/cdx-prepay-onupdate-C-oracle-20261011",
    "source_hashes": {
      "candidate_trigger_file_sha256": "824f41b19db6188775d3a79d22e90e42376395ae47f820d7a82209021813e55f",
      "B_manifest_sha256": "ff4172eda57d28e9cccd2c36cd76612cf9c29b9584d86f6caad321a6a3286b6d",
      "B_raw_sha256": "76a97779aff9fda0469a971439c5f1883c211eec5ee699f3b2556514034db06d"
    },
    "read_queries": {
      "identity": {
        "SQL": "SELECT SYS_CONTEXT('USERENV','CURRENT_SCHEMA') AS SCHEMA_NAME FROM DUAL",
        "binds": []
      },
      "version": {
        "SQL": "SELECT * FROM V$VERSION",
        "binds": []
      },
      "clock": {
        "SQL": "SELECT CURRENT_TIMESTAMP AS CLOCK_RAW,CAST(CURRENT_TIMESTAMP(0) AS DATETIME(0)) AS CLOCK0,TO_CHAR(CURRENT_TIMESTAMP(6),'YYYY-MM-DD HH24:MI:SS.FF6') AS CLOCK6 FROM DUAL",
        "binds": []
      },
      "table": {
        "SQL": "SELECT TABLE_NAME FROM USER_TABLES WHERE TABLE_NAME=?",
        "binds": [
          "CDX_PPUT261011_S1"
        ]
      },
      "indexes": {
        "SQL": "SELECT INDEX_NAME,INDEX_TYPE,UNIQUENESS,TABLE_NAME FROM USER_INDEXES WHERE TABLE_NAME=? OR INDEX_NAME=? ORDER BY INDEX_NAME",
        "binds": [
          "CDX_PPUT261011_S1",
          "PK_CDX_PPUT261011_S1"
        ]
      },
      "index_columns": {
        "SQL": "SELECT * FROM USER_IND_COLUMNS WHERE TABLE_NAME=? ORDER BY INDEX_NAME,COLUMN_POSITION",
        "binds": [
          "CDX_PPUT261011_S1"
        ]
      },
      "constraints": {
        "SQL": "SELECT * FROM USER_CONSTRAINTS WHERE TABLE_NAME=? OR CONSTRAINT_NAME=? ORDER BY CONSTRAINT_NAME",
        "binds": [
          "CDX_PPUT261011_S1",
          "PK_CDX_PPUT261011_S1"
        ]
      },
      "constraint_columns": {
        "SQL": "SELECT * FROM USER_CONS_COLUMNS WHERE TABLE_NAME=? ORDER BY CONSTRAINT_NAME,POSITION",
        "binds": [
          "CDX_PPUT261011_S1"
        ]
      },
      "triggers": {
        "SQL": "SELECT * FROM USER_TRIGGERS WHERE TABLE_NAME=? OR TRIGGER_NAME=?",
        "binds": [
          "CDX_PPUT261011_S1",
          "TRG_CDX_PPUT261011_S1"
        ]
      },
      "objects": {
        "SQL": "SELECT OBJECT_NAME,OBJECT_TYPE,STATUS FROM USER_OBJECTS WHERE OBJECT_NAME IN (?,?,?) ORDER BY OBJECT_NAME",
        "binds": [
          "CDX_PPUT261011_S1",
          "PK_CDX_PPUT261011_S1",
          "TRG_CDX_PPUT261011_S1"
        ]
      },
      "foreign_keys": {
        "SQL": "SELECT * FROM USER_CONSTRAINTS WHERE CONSTRAINT_TYPE='R' AND (TABLE_NAME=? OR R_CONSTRAINT_NAME IN (SELECT CONSTRAINT_NAME FROM USER_CONSTRAINTS WHERE TABLE_NAME=?))",
        "binds": [
          "CDX_PPUT261011_S1",
          "CDX_PPUT261011_S1"
        ]
      },
      "dependencies": {
        "SQL": "SELECT * FROM USER_DEPENDENCIES WHERE REFERENCED_OWNER=? AND REFERENCED_NAME=?",
        "binds": [
          "ZHCT_APP",
          "CDX_PPUT261011_S1"
        ]
      },
      "columns": {
        "SQL": "SELECT * FROM USER_TAB_COLUMNS WHERE TABLE_NAME=? ORDER BY COLUMN_ID",
        "binds": [
          "CDX_PPUT261011_S1"
        ]
      },
      "table_ddl": {
        "SQL": "SELECT DBMS_METADATA.GET_DDL('TABLE',?,'ZHCT_APP') AS DDL FROM DUAL",
        "binds": [
          "CDX_PPUT261011_S1"
        ]
      },
      "trigger_ddl": {
        "SQL": "SELECT DBMS_METADATA.GET_DDL('TRIGGER',?,'ZHCT_APP') AS DDL FROM DUAL",
        "binds": [
          "TRG_CDX_PPUT261011_S1"
        ]
      },
      "snapshot": {
        "SQL": "SELECT T.*,CAST(ID AS VARCHAR(40)) AS H_ID,CAST(MEAL_ORDER_ID AS VARCHAR(40)) AS H_MEAL_ORDER_ID,CAST(USER_ID AS VARCHAR(40)) AS H_USER_ID,RAWTOHEX(CHARTOBIN(LEASE_ID)) AS H_LEASE_ID,RAWTOHEX(CHARTOBIN(MEAL_ORDER_NO)) AS H_MEAL_ORDER_NO,RAWTOHEX(CHARTOBIN(UPDATE_BY)) AS H_UPDATE_BY,CAST(CASE WHEN RAW_REQUEST_A IS NULL THEN 1 ELSE 0 END AS VARCHAR(1)) AS R_NULL,TO_CHAR(EXPIRE_TIME,'YYYY-MM-DD HH24:MI:SS.FF6') AS F_EXPIRE_TIME,TO_CHAR(CREATE_TIME,'YYYY-MM-DD HH24:MI:SS.FF6') AS F_CREATE_TIME,TO_CHAR(UPDATE_TIME,'YYYY-MM-DD HH24:MI:SS.FF6') AS F_UPDATE_TIME,CURRENT_TIMESTAMP AS CLOCK_RAW,CAST(CURRENT_TIMESTAMP(0) AS DATETIME(0)) AS CLOCK0,TO_CHAR(CURRENT_TIMESTAMP(6),'YYYY-MM-DD HH24:MI:SS.FF6') AS CLOCK6 FROM ZHCT_APP.CDX_PPUT261011_S1 T ORDER BY ID",
        "binds": []
      }
    },
    "schema_queries": [
      "columns",
      "indexes",
      "index_columns",
      "constraints",
      "constraint_columns",
      "triggers",
      "objects",
      "foreign_keys",
      "dependencies",
      "table_ddl"
    ],
    "collision_queries": [
      "table",
      "indexes",
      "constraints",
      "triggers",
      "objects",
      "foreign_keys",
      "dependencies"
    ],
    "cases": [
      {
        "label": "CAS4",
        "SQL": "UPDATE ZHCT_APP.CDX_PPUT261011_S1 SET MEAL_ORDER_ID=?,MEAL_ORDER_NO=?,USER_ID=?,UPDATE_BY=? WHERE ID=? AND MEAL_ORDER_ID=?",
        "binds": [
          7,
          "CDXPPUT261011S1_ORDER",
          8,
          "miniapp",
          1,
          0
        ],
        "PDO_types": [
          1,
          2,
          1,
          2,
          1,
          1
        ],
        "reset_binds": [
          "CDXPPUT261011S1",
          0,
          "",
          0,
          "leaseA",
          null,
          "2000-01-01 00:00:00",
          "2001-01-01 00:00:00",
          "2001-01-01 00:00:00",
          1
        ],
        "reset_PDO_types": [
          2,
          1,
          2,
          1,
          2,
          0,
          2,
          2,
          2,
          1
        ],
        "hypothesis": "changed => server-generated whole second"
      },
      {
        "label": "NOOP_SCALAR",
        "SQL": "UPDATE ZHCT_APP.CDX_PPUT261011_S1 SET MEAL_ORDER_ID=? WHERE ID=?",
        "binds": [
          0,
          1
        ],
        "PDO_types": [
          1,
          1
        ],
        "reset_binds": [
          "CDXPPUT261011S1",
          0,
          "",
          0,
          "leaseA",
          null,
          "2000-01-01 00:00:00",
          "2001-01-01 00:00:00",
          "2001-01-01 00:00:00",
          1
        ],
        "reset_PDO_types": [
          2,
          1,
          2,
          1,
          2,
          0,
          2,
          2,
          2,
          1
        ],
        "hypothesis": "unchanged scalar => preserve anchor"
      },
      {
        "label": "VARCHAR_CASE",
        "SQL": "UPDATE ZHCT_APP.CDX_PPUT261011_S1 SET UPDATE_BY=? WHERE ID=?",
        "binds": [
          "leasea",
          1
        ],
        "PDO_types": [
          2,
          1
        ],
        "reset_binds": [
          "CDXPPUT261011S1",
          0,
          "",
          0,
          "leaseA",
          null,
          "2000-01-01 00:00:00",
          "2001-01-01 00:00:00",
          "2001-01-01 00:00:00",
          1
        ],
        "reset_PDO_types": [
          2,
          1,
          2,
          1,
          2,
          0,
          2,
          2,
          2,
          1
        ],
        "hypothesis": "case byte change => server-generated whole second"
      },
      {
        "label": "CLOB_NULL_EMPTY",
        "SQL": "UPDATE ZHCT_APP.CDX_PPUT261011_S1 SET RAW_REQUEST_A=? WHERE ID=?",
        "binds": [
          "",
          1
        ],
        "PDO_types": [
          2,
          1
        ],
        "reset_binds": [
          "CDXPPUT261011S1",
          0,
          "",
          0,
          "leaseA",
          null,
          "2000-01-01 00:00:00",
          "2001-01-01 00:00:00",
          "2001-01-01 00:00:00",
          1
        ],
        "reset_PDO_types": [
          2,
          1,
          2,
          1,
          2,
          0,
          2,
          2,
          2,
          1
        ],
        "hypothesis": "NULL to non-NULL empty => changed"
      },
      {
        "label": "CLOB_EMPTY_NULL",
        "SQL": "UPDATE ZHCT_APP.CDX_PPUT261011_S1 SET RAW_REQUEST_A=? WHERE ID=?",
        "binds": [
          null,
          1
        ],
        "PDO_types": [
          0,
          1
        ],
        "reset_binds": [
          "CDXPPUT261011S1",
          0,
          "",
          0,
          "leaseA",
          "",
          "2000-01-01 00:00:00",
          "2001-01-01 00:00:00",
          "2001-01-01 00:00:00",
          1
        ],
        "reset_PDO_types": [
          2,
          1,
          2,
          1,
          2,
          2,
          2,
          2,
          2,
          1
        ],
        "hypothesis": "empty to NULL => changed"
      },
      {
        "label": "CLOB_SAME",
        "SQL": "UPDATE ZHCT_APP.CDX_PPUT261011_S1 SET RAW_REQUEST_A=? WHERE ID=?",
        "binds": [
          "原始A",
          1
        ],
        "PDO_types": [
          2,
          1
        ],
        "reset_binds": [
          "CDXPPUT261011S1",
          0,
          "",
          0,
          "leaseA",
          "原始A",
          "2000-01-01 00:00:00",
          "2001-01-01 00:00:00",
          "2001-01-01 00:00:00",
          1
        ],
        "reset_PDO_types": [
          2,
          1,
          2,
          1,
          2,
          2,
          2,
          2,
          2,
          1
        ],
        "hypothesis": "SOURCE_ORACLE_REQUIRED; do not assume LOB assignment no-op"
      },
      {
        "label": "CLOB_CASE",
        "SQL": "UPDATE ZHCT_APP.CDX_PPUT261011_S1 SET RAW_REQUEST_A=? WHERE ID=?",
        "binds": [
          "原始a",
          1
        ],
        "PDO_types": [
          2,
          1
        ],
        "reset_binds": [
          "CDXPPUT261011S1",
          0,
          "",
          0,
          "leaseA",
          "原始A",
          "2000-01-01 00:00:00",
          "2001-01-01 00:00:00",
          "2001-01-01 00:00:00",
          1
        ],
        "reset_PDO_types": [
          2,
          1,
          2,
          1,
          2,
          2,
          2,
          2,
          2,
          1
        ],
        "hypothesis": "CLOB case byte change => changed"
      },
      {
        "label": "EXPLICIT_SELF_CHANGED",
        "SQL": "UPDATE ZHCT_APP.CDX_PPUT261011_S1 SET MEAL_ORDER_ID=?,UPDATE_TIME=UPDATE_TIME WHERE ID=?",
        "binds": [
          7,
          1
        ],
        "PDO_types": [
          1,
          1
        ],
        "reset_binds": [
          "CDXPPUT261011S1",
          0,
          "",
          0,
          "leaseA",
          null,
          "2000-01-01 00:00:00",
          "2001-01-01 00:00:00",
          "2001-01-01 00:00:00",
          1
        ],
        "reset_PDO_types": [
          2,
          1,
          2,
          1,
          2,
          0,
          2,
          2,
          2,
          1
        ],
        "hypothesis": "explicit self preserves anchor despite other change"
      },
      {
        "label": "EXPLICIT_VALUE_CHANGED",
        "SQL": "UPDATE ZHCT_APP.CDX_PPUT261011_S1 SET MEAL_ORDER_ID=?,UPDATE_TIME=? WHERE ID=?",
        "binds": [
          7,
          "2001-01-01 09:07:25.720472",
          1
        ],
        "PDO_types": [
          1,
          2,
          1
        ],
        "reset_binds": [
          "CDXPPUT261011S1",
          0,
          "",
          0,
          "leaseA",
          null,
          "2000-01-01 00:00:00",
          "2001-01-01 00:00:00",
          "2001-01-01 00:00:00",
          1
        ],
        "reset_PDO_types": [
          2,
          1,
          2,
          1,
          2,
          0,
          2,
          2,
          2,
          1
        ],
        "hypothesis": "explicit DATETIME0 rounds to 09:07:26; never automatic current time"
      },
      {
        "label": "EXPLICIT_NULL_CHANGED",
        "SQL": "UPDATE ZHCT_APP.CDX_PPUT261011_S1 SET MEAL_ORDER_ID=?,UPDATE_TIME=? WHERE ID=?",
        "binds": [
          7,
          null,
          1
        ],
        "PDO_types": [
          1,
          0,
          1
        ],
        "reset_binds": [
          "CDXPPUT261011S1",
          0,
          "",
          0,
          "leaseA",
          null,
          "2000-01-01 00:00:00",
          "2001-01-01 00:00:00",
          "2001-01-01 00:00:00",
          1
        ],
        "reset_PDO_types": [
          2,
          1,
          2,
          1,
          2,
          0,
          2,
          2,
          2,
          1
        ],
        "hypothesis": "SOURCE_ORACLE_REQUIRED under actual SQL_MODE; preserve warning/error and full before/after"
      },
      {
        "label": "EXPLICIT_DEFAULT_CHANGED",
        "SQL": "UPDATE ZHCT_APP.CDX_PPUT261011_S1 SET MEAL_ORDER_ID=?,UPDATE_TIME=DEFAULT WHERE ID=?",
        "binds": [
          7,
          1
        ],
        "PDO_types": [
          1,
          1
        ],
        "reset_binds": [
          "CDXPPUT261011S1",
          0,
          "",
          0,
          "leaseA",
          null,
          "2000-01-01 00:00:00",
          "2001-01-01 00:00:00",
          "2001-01-01 00:00:00",
          1
        ],
        "reset_PDO_types": [
          2,
          1,
          2,
          1,
          2,
          0,
          2,
          2,
          2,
          1
        ],
        "hypothesis": "explicit DEFAULT observed against local clock; no assumption it is a no-op"
      },
      {
        "label": "ALL9_SELF",
        "SQL": "UPDATE ZHCT_APP.CDX_PPUT261011_S1 SET ID=ID,LEASE_ID=LEASE_ID,MEAL_ORDER_ID=MEAL_ORDER_ID,MEAL_ORDER_NO=MEAL_ORDER_NO,USER_ID=USER_ID,UPDATE_BY=UPDATE_BY,RAW_REQUEST_A=RAW_REQUEST_A,EXPIRE_TIME=EXPIRE_TIME,CREATE_TIME=CREATE_TIME WHERE ID=?",
        "binds": [
          1
        ],
        "PDO_types": [
          1
        ],
        "reset_binds": [
          "CDXPPUT261011S1",
          0,
          "",
          0,
          "leaseA",
          null,
          "2000-01-01 00:00:00",
          "2001-01-01 00:00:00",
          "2001-01-01 00:00:00",
          1
        ],
        "reset_PDO_types": [
          2,
          1,
          2,
          1,
          2,
          0,
          2,
          2,
          2,
          1
        ],
        "hypothesis": "SOURCE_ORACLE_REQUIRED; Staff ALL76_SELF counterexample remains open"
      }
    ]
  },
  "create": "CREATE TABLE ZHCT_APP.CDX_PPUT261011_S1 (ID INT NOT NULL,LEASE_ID VARCHAR(32 CHAR) NOT NULL,MEAL_ORDER_ID BIGINT DEFAULT 0 NOT NULL,MEAL_ORDER_NO VARCHAR(32 CHAR) DEFAULT '' NOT NULL,USER_ID BIGINT DEFAULT 0 NOT NULL,UPDATE_BY VARCHAR(32 CHAR) DEFAULT '' NOT NULL,RAW_REQUEST_A CLOB NULL,EXPIRE_TIME DATETIME(6) DEFAULT '2000-01-01 00:00:00' NOT NULL,CREATE_TIME DATETIME(6) DEFAULT CURRENT_TIMESTAMP NOT NULL,UPDATE_TIME DATETIME(6) DEFAULT CURRENT_TIMESTAMP NOT NULL,CONSTRAINT PK_CDX_PPUT261011_S1 PRIMARY KEY(ID))",
  "alter": "ALTER TABLE ZHCT_APP.CDX_PPUT261011_S1 MODIFY (EXPIRE_TIME DATETIME(0) DEFAULT '2000-01-01 00:00:00' NOT NULL,CREATE_TIME DATETIME(0) DEFAULT CURRENT_TIMESTAMP(0) NOT NULL,UPDATE_TIME DATETIME(0) DEFAULT CURRENT_TIMESTAMP(0) NOT NULL)",
  "create_trigger": "-- PROPOSAL ONLY; own 10-column shadow, no business object authorization.\nCREATE TRIGGER ZHCT_APP.TRG_CDX_PPUT261011_S1\nBEFORE UPDATE ON ZHCT_APP.CDX_PPUT261011_S1\nFOR EACH ROW\nDECLARE\n  changed_value INT := 0;\n  char_position INT := 1;\n  old_length INT;\n  new_length INT;\nBEGIN\n  IF NOT UPDATING('UPDATE_TIME') THEN\n    IF :NEW.ID <> :OLD.ID\n       OR :NEW.MEAL_ORDER_ID <> :OLD.MEAL_ORDER_ID\n       OR :NEW.USER_ID <> :OLD.USER_ID\n       OR :NEW.EXPIRE_TIME <> :OLD.EXPIRE_TIME\n       OR :NEW.CREATE_TIME <> :OLD.CREATE_TIME\n       OR NVL(RAWTOHEX(CHARTOBIN(:NEW.LEASE_ID)), '#') <> NVL(RAWTOHEX(CHARTOBIN(:OLD.LEASE_ID)), '#')\n       OR NVL(RAWTOHEX(CHARTOBIN(:NEW.MEAL_ORDER_NO)), '#') <> NVL(RAWTOHEX(CHARTOBIN(:OLD.MEAL_ORDER_NO)), '#')\n       OR NVL(RAWTOHEX(CHARTOBIN(:NEW.UPDATE_BY)), '#') <> NVL(RAWTOHEX(CHARTOBIN(:OLD.UPDATE_BY)), '#') THEN\n      changed_value := 1;\n    END IF;\n    IF (:NEW.RAW_REQUEST_A IS NULL AND :OLD.RAW_REQUEST_A IS NOT NULL)\n       OR (:NEW.RAW_REQUEST_A IS NOT NULL AND :OLD.RAW_REQUEST_A IS NULL) THEN\n      changed_value := 1;\n    ELSIF :NEW.RAW_REQUEST_A IS NOT NULL AND :OLD.RAW_REQUEST_A IS NOT NULL THEN\n      old_length := LENGTH(:OLD.RAW_REQUEST_A);\n      new_length := LENGTH(:NEW.RAW_REQUEST_A);\n      IF old_length <> new_length THEN\n        changed_value := 1;\n      ELSE\n        WHILE char_position <= old_length LOOP\n          IF NVL(RAWTOHEX(CHARTOBIN(SUBSTR(:NEW.RAW_REQUEST_A,char_position,256))), '#')\n             <> NVL(RAWTOHEX(CHARTOBIN(SUBSTR(:OLD.RAW_REQUEST_A,char_position,256))), '#') THEN\n            changed_value := 1;\n            EXIT;\n          END IF;\n          char_position := char_position + 256;\n        END LOOP;\n      END IF;\n    END IF;\n    IF changed_value = 1 THEN\n      :NEW.UPDATE_TIME := TO_TIMESTAMP(TO_CHAR(CURRENT_TIMESTAMP,'YYYY-MM-DD HH24:MI:SS'),'YYYY-MM-DD HH24:MI:SS');\n    END IF;\n  END IF;\nEND;",
  "drop_trigger": "DROP TRIGGER ZHCT_APP.TRG_CDX_PPUT261011_S1",
  "drop_table": "DROP TABLE ZHCT_APP.CDX_PPUT261011_S1",
  "reset": "UPDATE ZHCT_APP.CDX_PPUT261011_S1 SET LEASE_ID=?,MEAL_ORDER_ID=?,MEAL_ORDER_NO=?,USER_ID=?,UPDATE_BY=?,RAW_REQUEST_A=?,EXPIRE_TIME=?,CREATE_TIME=?,UPDATE_TIME=? WHERE ID=?",
  "seeds": [
    {
      "ordinal": 23,
      "kind": "DML",
      "label": "SEED1",
      "role": "seed",
      "SQL": "INSERT INTO ZHCT_APP.CDX_PPUT261011_S1 (ID,LEASE_ID,MEAL_ORDER_ID,MEAL_ORDER_NO,USER_ID,UPDATE_BY,RAW_REQUEST_A,EXPIRE_TIME,CREATE_TIME,UPDATE_TIME) VALUES (?,?,?,?,?,?,?,?,?,?)",
      "binds": [
        1,
        "CDXPPUT261011S1",
        0,
        "",
        0,
        "leaseA",
        null,
        "2000-01-01 00:00:00",
        "2001-01-01 00:00:00",
        "2001-01-01 00:00:00"
      ],
      "PDO_types": [
        1,
        2,
        1,
        2,
        1,
        2,
        0,
        2,
        2,
        2
      ],
      "seed_id": 1,
      "phase": 6
    },
    {
      "ordinal": 26,
      "kind": "DML",
      "label": "SEED2",
      "role": "seed",
      "SQL": "INSERT INTO ZHCT_APP.CDX_PPUT261011_S1 (ID,LEASE_ID,MEAL_ORDER_ID,MEAL_ORDER_NO,USER_ID,UPDATE_BY,RAW_REQUEST_A,EXPIRE_TIME,CREATE_TIME,UPDATE_TIME) VALUES (?,?,?,?,?,?,?,?,?,?)",
      "binds": [
        2,
        "CDXPPUT261011S1",
        0,
        "",
        0,
        "",
        null,
        "2001-01-01 01:01:01.499999",
        "2001-01-01 01:01:01.499999",
        "2001-01-01 01:01:01.499999"
      ],
      "PDO_types": [
        1,
        2,
        1,
        2,
        1,
        2,
        0,
        2,
        2,
        2
      ],
      "seed_id": 2,
      "phase": 6
    },
    {
      "ordinal": 29,
      "kind": "DML",
      "label": "SEED3",
      "role": "seed",
      "SQL": "INSERT INTO ZHCT_APP.CDX_PPUT261011_S1 (ID,LEASE_ID,MEAL_ORDER_ID,MEAL_ORDER_NO,USER_ID,UPDATE_BY,RAW_REQUEST_A,EXPIRE_TIME,CREATE_TIME,UPDATE_TIME) VALUES (?,?,?,?,?,?,?,?,?,?)",
      "binds": [
        3,
        "CDXPPUT261011S1",
        0,
        "",
        0,
        "",
        null,
        "2001-01-01 01:01:01.500000",
        "2001-01-01 01:01:01.500000",
        "2001-01-01 01:01:01.500000"
      ],
      "PDO_types": [
        1,
        2,
        1,
        2,
        1,
        2,
        0,
        2,
        2,
        2
      ],
      "seed_id": 3,
      "phase": 6
    },
    {
      "ordinal": 45,
      "kind": "DML",
      "label": "SEED4",
      "role": "seed",
      "SQL": "INSERT INTO ZHCT_APP.CDX_PPUT261011_S1 (ID,LEASE_ID) VALUES (?,?)",
      "binds": [
        4,
        "CDXPPUT261011S1"
      ],
      "PDO_types": [
        1,
        2
      ],
      "seed_id": 4,
      "phase": 0
    }
  ]
}
PC_REFERENCE_JSON
,true);}

function pc_require($ok,$message){if(!$ok)throw new RuntimeException($message);}
function pc_add(&$out,$kind,$label,$role,$sql,$binds=[],$types=null,$extra=[]){if($types===null)$types=array_map(static function($v){return $v===null?0:(is_int($v)?1:2);},$binds);$out[]=array_merge(['ordinal'=>count($out)+1,'kind'=>$kind,'label'=>$label,'role'=>$role,'SQL'=>$sql,'binds'=>$binds,'PDO_types'=>$types],$extra);}
function pc_read_step(&$out,$q,$label,$role,$key,$extra=[]){pc_add($out,'read',$label,$role,$q[$key]['SQL'],$q[$key]['binds'],null,array_merge(['read_query'=>$key],$extra));}
function pc_meta_steps(&$out,$p,$prefix,$role,$phase,$trigger=false){foreach($p['schema_queries']as $key)pc_read_step($out,$p['read_queries'],$prefix.'.'.$key,$role,$key,['phase'=>$phase]);if($trigger)pc_read_step($out,$p['read_queries'],$prefix.'.trigger_ddl',$role,'trigger_ddl',['phase'=>$phase]);}
function pc_op_steps(&$out,$q,$label,$role,$sql,$binds,$types,$extra){pc_read_step($out,$q,$label.'.before','before','snapshot',array_merge(['operation_label'=>$label],$extra));pc_add($out,'DML',$label,$role,$sql,$binds,$types,$extra);pc_read_step($out,$q,$label.'.after','after','snapshot',array_merge(['operation_label'=>$label],$extra));}
function pc_expected_steps($ref){$p=$ref['contract'];$q=$p['read_queries'];$s=[];
 pc_read_step($s,$q,'pre.identity','identity','identity');pc_read_step($s,$q,'pre.version','version','version');pc_read_step($s,$q,'pre.clock','clock','clock');foreach($p['collision_queries']as $k)pc_read_step($s,$q,'pre.'.$k,'collision',$k);
 pc_add($s,'DDL','create','create',$ref['create']);pc_meta_steps($s,$p,'created','created_schema',6);
 foreach(array_slice($ref['seeds'],0,3)as $v)pc_op_steps($s,$q,$v['label'],'seed',$v['SQL'],$v['binds'],$v['PDO_types'],['seed_id'=>$v['seed_id'],'phase'=>6]);
 pc_read_step($s,$q,'alter.before','alter_before','snapshot',['phase'=>6]);pc_add($s,'DDL','alter','alter',$ref['alter']);pc_read_step($s,$q,'alter.after','alter_after','snapshot',['phase'=>0]);pc_meta_steps($s,$p,'altered','altered_schema',0);
 $v=$ref['seeds'][3];pc_op_steps($s,$q,'SEED4','seed',$v['SQL'],$v['binds'],$v['PDO_types'],['seed_id'=>4,'phase'=>0]);pc_read_step($s,$q,'pre.trigger','trigger_collision','triggers');pc_add($s,'DDL','create_trigger','create_trigger',$ref['create_trigger']);pc_meta_steps($s,$p,'final_schema','final_schema',0,true);
 foreach($p['cases']as $c){pc_op_steps($s,$q,$c['label'].'.RESET','reset',$ref['reset'],$c['reset_binds'],$c['reset_PDO_types'],['case_label'=>$c['label'],'phase'=>0]);pc_op_steps($s,$q,$c['label'],'mutation',$c['SQL'],$c['binds'],$c['PDO_types'],['case_label'=>$c['label'],'phase'=>0]);}
 pc_read_step($s,$q,'cleanup.identity','cleanup_identity','identity');pc_read_step($s,$q,'cleanup.version','cleanup_version','version');pc_read_step($s,$q,'cleanup.snapshot','cleanup_snapshot','snapshot',['phase'=>0]);pc_meta_steps($s,$p,'cleanup','cleanup_schema',0,true);pc_add($s,'DDL','drop_trigger','drop_trigger',$ref['drop_trigger']);pc_meta_steps($s,$p,'after_trigger_drop','after_trigger_drop_schema',0);pc_read_step($s,$q,'after_trigger_drop.snapshot','after_trigger_drop_snapshot','snapshot',['phase'=>0]);pc_add($s,'DDL','drop_table','drop_table',$ref['drop_table']);foreach($p['collision_queries']as $k)pc_read_step($s,$q,'post.'.$k,'zero',$k);return $s;
}
function pc_gate_plan($p){$ref=pc_reference();$c=$p;unset($c['steps']);pc_require($c===$ref['contract'],'Exact immutable C contract/endpoint/lease/source hashes');pc_require($p['steps']===pc_expected_steps($ref),'Exact complete C literal ledger');$n=['read'=>0,'DML'=>0,'DDL'=>0];foreach($p['steps']as $s){pc_require(isset($n[$s['kind']]),'Known kind');++$n[$s['kind']];pc_require(substr_count($s['SQL'],'?')===count($s['binds'])&&count($s['binds'])===count($s['PDO_types']),'Exact placeholders/types');foreach($s['binds']as $i=>$v){pc_require($v===null||is_int($v)||is_string($v),'No float/object bind');pc_require($s['PDO_types'][$i]===($v===null?0:(is_int($v)?1:2)),'Exact source bind types');}}pc_require($n===['read'=>132,'DML'=>28,'DDL'=>5],'132/28/5 exact caps');return $n;}
function pc_gate_step($p,$s,$state){pc_require(isset($p['steps'][$state['cursor']])&&$s===$p['steps'][$state['cursor']],'Unknown SQL/bind/type/order/replay rejected');pc_require($state[$s['kind']]<$p['budget'][$s['kind']],'Exact kind cap');if($s['role']==='create')pc_require(!$state['created']&&$state['collision_zero'],'CREATE collision0/no replay');elseif($s['role']==='create_trigger')pc_require($state['created']&&!$state['trigger_created'],'Trigger CREATE once on own table');elseif($s['role']==='drop_trigger')pc_require($state['created']&&$state['trigger_created']&&$state['drop_proof'],'Own trigger cleanup proof');elseif($s['role']==='drop_table')pc_require($state['created']&&$state['table_drop_proof'],'Own table cleanup proof');elseif($s['kind']==='DDL'||$s['kind']==='DML')pc_require($state['created'],'Only proven-created own object');}
function pc_physical($rows){foreach($rows as &$r)unset($r['clock_raw'],$r['clock0'],$r['clock6']);unset($r);return $rows;}
function pc_original_types($types){foreach($types as &$r)unset($r['clock_raw'],$r['clock0'],$r['clock6']);unset($r);return $types;}
function pc_digest($rows,$types,$p){$hashes=[];foreach($rows as $i=>$r){$v=[];$t=[];foreach(array_map('strtolower',$p['columns'])as $k){$v[$k]=$r[$k];$t[$k]=$types[$i][$k];}$j=json_encode(['values'=>$v,'native_types'=>$t],JSON_UNESCAPED_UNICODE|JSON_PRESERVE_ZERO_FRACTION);pc_require($j!==false,'Full10 stream/native-type digest encoding');$hashes[(string)$r['id']]=hash('sha256',$j);}return ['rows'=>$hashes,'all_rows_sha256'=>hash('sha256',json_encode($hashes))];}
function pc_snapshot($rows,$ids,$phase,$p){pc_require(count($rows)===count($ids)&&count($rows)<=4,'Exact own row set');foreach($rows as $i=>$r){pc_require(count($r)===23,'All10 native/stream fields and13 helpers');foreach(array_map('strtolower',$p['columns'])as $k)pc_require(array_key_exists($k,$r),'Every original native column');pc_require((string)$r['id']===(string)$ids[$i]&&$r['lease_id']===$p['marker'],'Exact own ID/lease');foreach(['id','meal_order_id','user_id']as $k)pc_require($r['h_'.$k]===(string)$r[$k],'Server exact integer text');foreach(['lease_id','meal_order_no','update_by']as $k)pc_require(is_string($r[$k])&&$r['h_'.$k]===($r[$k]===''?null:strtoupper(bin2hex($r[$k]))),'Full VARCHAR bytes; observed DM empty HEX is NULL and raw empty stays empty');pc_require(($r['raw_request_a']===null||is_string($r['raw_request_a']))&&$r['r_null']===($r['raw_request_a']===null?'1':'0'),'CLOB full stream and native NULL/empty distinction');foreach(['expire_time','create_time','update_time']as $k){$f=$r['f_'.$k];pc_require(is_string($f)&&preg_match('/^\d{4}-\d\d-\d\d \d\d:\d\d:\d\d\.\d{6}$/D',$f)===1,'Exact full source FF6');if($phase===0)pc_require($r[$k]===substr($f,0,19)&&substr($f,-6)==='000000','Actual fsp0 native19/zero fraction');else pc_require($r[$k]===$f||(substr($f,-6)==='000000'&&$r[$k]===substr($f,0,19)),'Retain original fsp6 bytes; legal zero representation classified only');}pc_require(preg_match('/^\d{4}-\d\d-\d\d \d\d:\d\d:\d\d$/D',$r['clock0'])===1,'Local clock0');pc_require(preg_match('/^\d{4}-\d\d-\d\d \d\d:\d\d:\d\d\.\d{6}$/D',$r['clock6'])===1,'Local FF6 clock');pc_require(is_string($r['clock_raw'])&&strpos($r['clock_raw'],' +08:00')!==false,'Original CURRENT_TIMESTAMP including timezone retained');}}
function pc_equal_value($a,$b){return is_int($b)?(string)$a===(string)$b:$a===$b;}
function pc_values($row,$values){foreach($values as $key=>$v)pc_require(pc_equal_value($row[strtolower($key)],$v),'Exact expected physical value '.$key);}
function pc_clock_value($v,$before,$after){return $v>=$before[0]['clock0']&&$v<=$after[0]['clock0'];}
function pc_transition($before,$after,$bt,$at,$label,$role,$success,$errorInfo,$p){pc_require(count($before)===4&&count($after)===4,'Complete4 transition');pc_require(pc_physical(array_slice($before,1))===pc_physical(array_slice($after,1))&&pc_original_types(array_slice($bt,1))===pc_original_types(array_slice($at,1)),'Other3 full native rows/types protected');if(!$success){pc_require($role==='mutation'&&$label==='EXPLICIT_NULL_CHANGED'&&isset($errorInfo[1])&&(int)$errorInfo[1]===-6609,'Only diagnosed original NOTNULL single-row error may continue');pc_require(pc_physical($before)===pc_physical($after)&&pc_original_types($bt)===pc_original_types($at),'Failed statement full native atomicity');return;}$c=null;foreach($p['cases']as $candidate)if($candidate['label']===$label)$c=$candidate;pc_require($c!==null,'Known case');if($role==='reset'){$v=array_combine(array_slice($p['columns'],1),array_slice($c['reset_binds'],0,9));$v['ID']=1;pc_values($after[0],$v);return;}
 $allow=['update_time'];$v=[];if($label==='CAS4'){$allow=array_merge($allow,['meal_order_id','meal_order_no','user_id','update_by']);$v=['meal_order_id'=>7,'meal_order_no'=>'CDXPPUT261011S1_ORDER','user_id'=>8,'update_by'=>'miniapp'];}elseif($label==='VARCHAR_CASE'){$allow[]='update_by';$v=['update_by'=>'leasea'];}elseif(strpos($label,'CLOB_')===0){$allow[]='raw_request_a';$v=['raw_request_a'=>$c['binds'][0]];}elseif(strpos($label,'EXPLICIT_')===0){$allow[]='meal_order_id';$v=['meal_order_id'=>7];}pc_values($after[0],$v);foreach(array_map('strtolower',$p['columns'])as $k)if(!in_array($k,$allow,true))pc_require($before[0][$k]===$after[0][$k]&&$bt[0][$k]===$at[0][$k],'Independent unchanged row1 native value/type '.$k);
 $ut=$after[0]['update_time'];$old=$before[0]['update_time'];if(in_array($label,['NOOP_SCALAR','CLOB_SAME','ALL9_SELF','EXPLICIT_SELF_CHANGED'],true))pc_require($ut===$old,'Physical source noop/self anchor');elseif($label==='EXPLICIT_VALUE_CHANGED')pc_require($ut==='2001-01-01 09:07:26','Original .720472 rounds to26');elseif($label!=='EXPLICIT_NULL_CHANGED')pc_require(pc_clock_value($ut,$before,$after),'Actual automatic/default whole second in local clock');
}
function pc_seed($before,$after,$bt,$at,$s,$p){$id=$s['seed_id'];pc_require(pc_physical($before)===pc_physical(array_slice($after,0,$id-1))&&pc_original_types($bt)===pc_original_types(array_slice($at,0,$id-1)),'INSERT preserves all existing values/types');$r=$after[$id-1];if($id<=3){$v=array_combine($p['columns'],$s['binds']);foreach(['EXPIRE_TIME','CREATE_TIME','UPDATE_TIME']as $k){$raw=$v[$k];$canonical=strlen($raw)===19?$raw.'.000000':$raw;pc_require($r['f_'.strtolower($k)]===$canonical,'Initial actual fsp6 retains original explicit fraction');unset($v[$k]);}pc_values($r,$v);}else{pc_values($r,['ID'=>4,'LEASE_ID'=>$p['marker'],'MEAL_ORDER_ID'=>0,'MEAL_ORDER_NO'=>'','USER_ID'=>0,'UPDATE_BY'=>'','RAW_REQUEST_A'=>null,'EXPIRE_TIME'=>'2000-01-01 00:00:00']);pc_require(pc_clock_value($r['create_time'],$before,$after)&&pc_clock_value($r['update_time'],$before,$after),'Omitted defaults after ALTER generated local seconds');}}
function pc_alter_rows($before,$after,$bt,$at,$p){pc_require(count($before)===3&&count($after)===3,'ALTER retains own3 rows');foreach($before as $i=>$old){foreach(array_map('strtolower',$p['columns'])as $k){if(in_array($k,['expire_time','create_time','update_time'],true)){$expected=$i===0?($k==='expire_time'?'2000-01-01 00:00:00':'2001-01-01 00:00:00'):($i===1?'2001-01-01 01:01:01':'2001-01-01 01:01:02');pc_require($after[$i][$k]===$expected&&$after[$i]['f_'.$k]===$expected.'.000000','Explicit .499999/.500000 actual ALTER rounding');}else pc_require($after[$i][$k]===$old[$k]&&$at[$i][$k]===$bt[$i][$k],'ALTER keeps other native values/types');}}}
function pc_schema_fingerprint($schema){$out=$schema;$keep=['table_name','column_name','data_type','data_type_mod','data_type_owner','data_length','data_precision','data_scale','nullable','column_id','default_length','data_default','character_set_name','char_col_decl_length','char_length','char_used'];foreach($out['columns']as &$r)$r=array_intersect_key($r,array_flip($keep));unset($r);return $out;}
function pc_schema($s,$phase,$trigger,$p){pc_require(array_column($s['columns'],'column_name')===$p['columns'],'Exact10 own columns/order');$types=['INT','VARCHAR','BIGINT','VARCHAR','BIGINT','VARCHAR','CLOB','DATETIME','DATETIME','DATETIME'];$defaults=[null,null,'0',"''",'0',"''",null,"'2000-01-01 00:00:00'",$phase===6?'CURRENT_TIMESTAMP':'CURRENT_TIMESTAMP(0)',$phase===6?'CURRENT_TIMESTAMP':'CURRENT_TIMESTAMP(0)'];foreach($s['columns']as $i=>$c){pc_require($c['data_type']===$types[$i]&&(int)$c['column_id']===$i+1&&$c['nullable']===($i===6?'Y':'N'),'Exact mapped physical type/order/nullability');$d=$c['data_default'];pc_require($defaults[$i]===null?$d===null:preg_replace('/\s+/','',strtoupper((string)$d))===preg_replace('/\s+/','',strtoupper($defaults[$i])),'Every original default');if($i>=7)pc_require((int)$c['data_scale']===$phase,'Actual declared fsp');if(in_array($i,[1,3,5],true))pc_require((int)$c['char_length']===32&&(int)$c['data_length']===128&&$c['char_used']==='C','Exact CHAR length and octet capacity');}
 pc_require(count($s['indexes'])===1&&$s['indexes'][0]['uniqueness']==='UNIQUE'&&$s['indexes'][0]['table_name']==='CDX_PPUT261011_S1','Exact own PK backing index');pc_require(count($s['index_columns'])===1&&$s['index_columns'][0]['column_name']==='ID','PK exact column');pc_require(count($s['constraints'])===1&&$s['constraints'][0]['constraint_type']==='P'&&$s['constraints'][0]['constraint_name']===$p['pk'],'Exact own primary constraint');pc_require(count($s['constraint_columns'])===1&&$s['constraint_columns'][0]['column_name']==='ID','Exact primary constraint field');pc_require($s['foreign_keys']===[],'Visible incoming/outgoing FK0');pc_require(count($s['table_ddl'])===1&&is_string($s['table_ddl'][0]['ddl']),'Full original GET_DDL table');$found=[];foreach($s['objects']as $o){pc_require($o['status']==='VALID','Native owned object VALID');$found[$o['object_name']]=$o['object_type'];}pc_require(isset($found['CDX_PPUT261011_S1'])&&$found['CDX_PPUT261011_S1']==='TABLE','Own native TABLE/VALID');if(!$trigger){pc_require($s['triggers']===[]&&$s['dependencies']===[]&&!isset($found[$p['trigger']]),'Before/after own trigger no visible dependency');}else{pc_require(count($s['triggers'])===1,'One own trigger');$t=$s['triggers'][0];pc_require($t['trigger_name']===$p['trigger']&&$t['table_name']==='CDX_PPUT261011_S1'&&$t['table_owner']==='ZHCT_APP'&&$t['status']==='Y'&&$t['triggering_type']==='BEFORE ROW'&&$t['triggering_event']==='UPDATE','Actual Y/BEFORE ROW/UPDATE owned trigger');pc_require(isset($found[$p['trigger']])&&$found[$p['trigger']]==='TRIGGER','Native TRIGGER/VALID');foreach($s['dependencies']as $d)pc_require(in_array($p['trigger'],array_values($d),true),'Only own trigger may depend on own table');pc_require(count($s['trigger_ddl'])===1&&is_string($s['trigger_ddl'][0]['ddl']),'Full original trigger GET_DDL');pc_trigger($s['trigger_ddl'][0]['ddl'],$t['trigger_body'],pc_reference()['create_trigger']);}}
function pc_tokens($sql){preg_match_all('~\x27(?:\x27\x27|[^\x27])*\x27|"(?:""|[^"])*"|--[^\r\n]*|[A-Za-z_][A-Za-z0-9_$]*|(?:<>|:=|<=|>=)|[^\s]~u',$sql,$m);$out=[];foreach($m[0]as $t){if(substr($t,0,2)==='--')continue;$out[]=($t[0]===chr(39)||$t[0]===chr(34))?$t:strtoupper($t);}return $out;}
function pc_trigger($ddl,$body,$approved){$extract=static function($s){pc_require(preg_match('/FOR\s+EACH\s+ROW\b/i',$s,$m,PREG_OFFSET_CAPTURE)===1,'Full original FOR EACH ROW trigger');return trim(substr($s,$m[0][1]+strlen($m[0][0])));};$header=static function($s){pc_require(preg_match('/FOR\s+EACH\s+ROW\b/i',$s,$m,PREG_OFFSET_CAPTURE)===1,'Complete original trigger header');$tokens=pc_tokens(substr($s,0,$m[0][1]+strlen($m[0][0])));$out=[];foreach($tokens as $t){if($t==='OR'||$t==='REPLACE')continue;$out[]=$t[0]===chr(34)?strtoupper(substr($t,1,-1)):$t;}return $out;};pc_require($header($approved)===$header($ddl)&&$header($approved)===$header($body),'Full owned owner/name/table/event/row header tokens');$a=$extract($approved);$d=$extract($ddl);$b=$extract($body);pc_require(pc_tokens($a)===pc_tokens($d)&&pc_tokens($a)===pc_tokens($b),'Complete literal-preserving trigger body token equality');return ['approved_body_sha256'=>hash('sha256',$a),'GET_DDL_body_sha256'=>hash('sha256',$d),'USER_TRIGGERS_body_sha256'=>hash('sha256',$b),'body_byte_exact'=>$a===$d&&$a===$b,'body_token_exact'=>true,'header_token_exact'=>true];}
function pc_append($h,$event){$j=json_encode($event,JSON_UNESCAPED_UNICODE|JSON_PRESERVE_ZERO_FRACTION);pc_require($j!==false,'Raw event JSON encoding');pc_require(fwrite($h,$j."\n")===strlen($j)+1&&fflush($h),'Append-before/result evidence flush');}
function pc_materialize($rows){$types=[];$keys=[];$streams=[];$bits=[];foreach($rows as $i=>&$row){$keys[$i]=array_keys($row);$native=[];$stream=[];$float=[];foreach($row as $k=>&$v){$name=strtolower($k);$native[$name]=gettype($v);if(is_float($v))$float[$name]=bin2hex(pack('d',$v));if(is_resource($v)){$v=stream_get_contents($v);pc_require(is_string($v),'Full native CLOB/DDL stream read');$stream[$name]=['bytes'=>strlen($v),'sha256'=>hash('sha256',$v)];}}unset($v);$row=array_change_key_case($row,CASE_LOWER);$types[$i]=$native;$streams[$i]=$stream;$bits[$i]=$float;}unset($row);return [$rows,$types,$keys,$streams,$bits];}
function pc_execute($p,$sha,$runnerSha){pc_require(getenv('PP_C_ROOT_APPROVAL_SHA')===$sha&&getenv('PP_C_ROOT_APPROVAL_RUNNER_SHA')===$runnerSha,'Separate exact Root approval before config/PDO');$dir=$p['runtime_directory'];pc_require(!file_exists($dir)&&!is_link($dir),'Fresh exact own runtime; no resume/replay');pc_require(mkdir($dir,0700),'Private own runtime');$h=fopen($dir.'/events.jsonl','x');pc_require($h!==false,'Exclusive own journal');chmod($dir.'/events.jsonl',0600);$state=['cursor'=>0,'read'=>0,'DML'=>0,'DDL'=>0,'created'=>false,'trigger_created'=>false,'collision_zero'=>false,'drop_proof'=>false,'table_drop_proof'=>false];$meta=[];$last=[];$lastTypes=[];$before=[];$beforeTypes=[];$pending=null;$identity=null;$version=null;$alterBefore=null;$alterTypes=null;$stmt=null;
 try{$file=$p['connection']['config_path'];pc_require(realpath($file)===$file&&!is_link($file),'Exact original C config path');$cfg=(static function($path){return require $path;})($file);pc_require($cfg['hostname']==='127.0.0.1'&&(string)$cfg['hostport']==='5237'&&$cfg['database']==='ZHCT_APP','Original loopback/nonprod5237/ZHCT_APP config');pc_require(getenv('POC_HOST')==='127.0.0.1'&&getenv('POC_PORT')==='5237'&&getenv('POC_SCHEMA')==='ZHCT_APP','Original parent loopback identity');$db=new PDO('dm:host=127.0.0.1;port=5237;schema=ZHCT_APP',$cfg['username'],$cfg['password'],[PDO::ATTR_ERRMODE=>PDO::ERRMODE_EXCEPTION,PDO::ATTR_CASE=>PDO::CASE_LOWER,PDO::ATTR_STRINGIFY_FETCHES=>false,PDO::ATTR_EMULATE_PREPARES=>false]);unset($cfg);pc_append($h,['event'=>'start','plan_sha256'=>$sha,'runner_sha256'=>$runnerSha,'source_hashes'=>$p['source_hashes'],'lane'=>'C','utc'=>gmdate('c')]);
 foreach($p['steps']as $s){pc_gate_step($p,$s,$state);++$state[$s['kind']];pc_append($h,['event'=>'sent','step'=>$s,'utc'=>gmdate('c'),'microtime'=>sprintf('%.6F',microtime(true))]);$stmt=null;
  if($s['kind']==='DML'){$pending=['step'=>$s,'before'=>$before,'before_native_types'=>$beforeTypes,'ok'=>false,'rowCount'=>null,'error'=>null,'errorInfo'=>null,'phase'=>'prepare'];try{$stmt=$db->prepare($s['SQL']);$pending['phase']='bind';foreach($s['binds']as $i=>$v)pc_require($stmt->bindValue($i+1,$v,$s['PDO_types'][$i]),'Native exact binding');$pending['phase']='execute';$pending['ok']=$stmt->execute();$pending['rowCount']=$stmt->rowCount();$pending['errorInfo']=$stmt->errorInfo();}catch(Throwable $e){$pending['errorInfo']=$stmt?$stmt->errorInfo():null;$pending['error']=['class'=>get_class($e),'code'=>$e->getCode(),'message'=>$e->getMessage(),'errorInfo'=>$pending['errorInfo']];}pc_append($h,['event'=>'DML-original-result','data'=>$pending]);}
  else{$stmt=$db->prepare($s['SQL']);foreach($s['binds']as $i=>$v)pc_require($stmt->bindValue($i+1,$v,$s['PDO_types'][$i]),'Native exact binding');pc_require($stmt->execute(),'Original native execute success');if($s['kind']==='DDL'){if($s['role']==='create')$state['created']=true;if($s['role']==='create_trigger')$state['trigger_created']=true;if($s['role']==='drop_trigger')$state['trigger_created']=false;if($s['role']==='drop_table')$state['created']=false;pc_append($h,['event'=>'DDL-original-result','label'=>$s['label'],'ok'=>true,'rowCount'=>$stmt->rowCount(),'errorInfo'=>$stmt->errorInfo()]);}
   else{$nativeRows=$stmt->fetchAll(PDO::FETCH_ASSOC);pc_require(count($nativeRows)<=128,'Bounded own/catalog rows');list($rows,$nativeTypes,$nativeKeys,$streams,$bits)=pc_materialize($nativeRows);pc_append($h,['event'=>'read-original-result','label'=>$s['label'],'rows'=>$rows,'native_types'=>$nativeTypes,'native_keys'=>$nativeKeys,'native_streams'=>$streams,'native_float_bits'=>$bits,'float_byte_order'=>bin2hex(pack('L',1)),'full10_digests'=>$s['read_query']==='snapshot'?pc_digest($rows,$nativeTypes,$p):null,'errorInfo'=>$stmt->errorInfo()]);$role=$s['role'];$q=$s['read_query'];
    if($role==='identity'){pc_require($rows===[['schema_name'=>'ZHCT_APP']],'Actual native C schema');$identity=$rows;}
    elseif($role==='version'){pc_require(array_column($rows,'banner')===$p['connection']['expected_version_banners'],'Exact approved DM build/version');$version=$rows;}
    elseif($role==='collision'){pc_require($rows===[],'Exact own collision0');if($q==='dependencies')$state['collision_zero']=true;}
    elseif($role==='trigger_collision')pc_require($rows===[],'Own trigger fresh collision0 immediately before CREATE');
    elseif(in_array($role,['created_schema','altered_schema','final_schema','cleanup_schema','after_trigger_drop_schema'],true)){$meta[$role][$q]=$rows;$end=($role==='final_schema'||$role==='cleanup_schema')?'trigger_ddl':'table_ddl';if($q===$end){$current=$meta[$role];pc_schema($current,$s['phase'],$role==='final_schema'||$role==='cleanup_schema',$p);
     if($role==='altered_schema'){$old=$meta['created_schema'];foreach(['indexes','index_columns','constraints','constraint_columns','triggers','objects','foreign_keys','dependencies']as $k)pc_require($current[$k]===$old[$k],'ALTER preserves original non-column structure '.$k);$oldCols=pc_schema_fingerprint($old)['columns'];$newCols=pc_schema_fingerprint($current)['columns'];foreach($oldCols as $i=>$oc){$nc=$newCols[$i];if($i>=7){foreach(['data_scale','data_default','default_length']as $k)unset($oc[$k],$nc[$k]);}pc_require($oc===$nc,'ALTER only declared time precision/default changes');}}
     if($role==='final_schema'){foreach(['columns','indexes','index_columns','constraints','constraint_columns','foreign_keys','table_ddl']as $k)pc_require(pc_schema_fingerprint($current)[$k]===pc_schema_fingerprint($meta['altered_schema'])[$k],'Trigger CREATE keeps all original table definitions '.$k);$t=$current['triggers'][0];pc_append($h,['event'=>'trigger-definition-gate','data'=>pc_trigger($current['trigger_ddl'][0]['ddl'],$t['trigger_body'],pc_reference()['create_trigger'])]);}
     if($role==='cleanup_schema'){pc_require(pc_schema_fingerprint($current)===pc_schema_fingerprint($meta['final_schema']),'Full own compiled structure/DDL/visible dependency fingerprint');pc_require($state['created']&&$state['trigger_created']&&$state['DDL']===3&&$state['DML']===28&&$pending===null,'Exact completed creation/mutation journal');$state['drop_proof']=true;}
     if($role==='after_trigger_drop_schema')pc_require(pc_schema_fingerprint($current)===pc_schema_fingerprint($meta['altered_schema']),'Only owned trigger removed; all original table/index/constraint/FK/DDL state exact');
    }}
    elseif($role==='before'){$id=isset($s['seed_id'])?$s['seed_id']:null;$ids=$id!==null?($id===1?[]:range(1,$id-1)):[1,2,3,4];pc_snapshot($rows,$ids,$s['phase'],$p);pc_require(pc_physical($rows)===pc_physical($last)&&pc_original_types($nativeTypes)===pc_original_types($lastTypes),'Full lease/protection before every DML');$before=$rows;$beforeTypes=$nativeTypes;}
    elseif($role==='after'){pc_require($pending!==null&&$s['operation_label']===$pending['step']['label'],'Original pending DML before observer');$w=$pending['step'];$id=isset($w['seed_id'])?$w['seed_id']:null;pc_snapshot($rows,$id!==null?range(1,$id):[1,2,3,4],$s['phase'],$p);if($id!==null){pc_require($pending['ok']&&$pending['rowCount']===1,'Exactly one own INSERT');pc_seed($pending['before'],$rows,$pending['before_native_types'],$nativeTypes,$w,$p);}else{if($pending['ok'])pc_require(in_array($pending['rowCount'],[0,1],true),'Native rowCount original0/1');pc_transition($pending['before'],$rows,$pending['before_native_types'],$nativeTypes,$w['case_label'],$w['role'],$pending['ok'],$pending['errorInfo'],$p);}pc_append($h,['event'=>'protected-outcome','label'=>$w['label'],'ok'=>$pending['ok'],'rowCount'=>$pending['rowCount'],'error'=>$pending['error'],'errorInfo'=>$pending['errorInfo'],'before'=>$pending['before'],'before_native_types'=>$pending['before_native_types'],'after'=>$rows,'after_native_types'=>$nativeTypes]);$last=$rows;$lastTypes=$nativeTypes;$pending=null;}
    elseif($role==='alter_before'){pc_snapshot($rows,[1,2,3],6,$p);pc_require(pc_physical($rows)===pc_physical($last)&&pc_original_types($nativeTypes)===pc_original_types($lastTypes),'Own3 protected immediately before ALTER');$alterBefore=$rows;$alterTypes=$nativeTypes;}
    elseif($role==='alter_after'){pc_snapshot($rows,[1,2,3],0,$p);pc_alter_rows($alterBefore,$rows,$alterTypes,$nativeTypes,$p);pc_append($h,['event'=>'actual-precision-mapping','before'=>$alterBefore,'after'=>$rows]);$last=$rows;$lastTypes=$nativeTypes;}
    elseif($role==='cleanup_identity')pc_require($rows===$identity,'Original C schema unchanged');elseif($role==='cleanup_version')pc_require($rows===$version,'Original exact build unchanged');
    elseif($role==='cleanup_snapshot'||$role==='after_trigger_drop_snapshot'){pc_snapshot($rows,[1,2,3,4],0,$p);pc_require(pc_physical($rows)===pc_physical($last)&&pc_original_types($nativeTypes)===pc_original_types($lastTypes),'All4 full native rows/types/SHA unchanged before DROP');if($role==='after_trigger_drop_snapshot'){$state['table_drop_proof']=$state['created']&&!$state['trigger_created']&&$state['DDL']===4&&$state['drop_proof'];}}
    elseif($role==='zero')pc_require($rows===[],'Exact final owned object/index/constraint/FK/dependency0');
   }
  }++$state['cursor'];
 }pc_require($state['cursor']===165&&$state['read']===132&&$state['DML']===28&&$state['DDL']===5&&!$state['created']&&!$state['trigger_created'],'Completed exact C ledger/owned closure');pc_append($h,['event'=>'summary','status'=>'ACTUAL_C_SHADOW_PARTIAL_REQUIRES_ROOT_REVIEW','counts'=>$state,'HTTP'=>0,'business_writes'=>0,'NULL_difference_from_B_retained'=>true]);fclose($h);echo json_encode(['status'=>'ACTUAL_C_SHADOW_PARTIAL_REQUIRES_ROOT_REVIEW','read'=>132,'DML_attempts'=>28,'DDL_attempts'=>5,'HTTP'=>0]),"\n";return 0;
 }catch(Throwable $e){pc_append($h,['event'=>'stopped_no_retry_or_automatic_cleanup','class'=>get_class($e),'code'=>$e->getCode(),'message'=>$e->getMessage(),'last_statement_errorInfo'=>$stmt?$stmt->errorInfo():null,'state'=>$state]);fclose($h);fwrite(STDERR,json_encode(['status'=>'STOPPED_ORIGINAL_OWN_STATE_RETAINED','class'=>get_class($e),'counts'=>$state,'automatic_cleanup'=>false])."\n");return 1;}
}
if(isset($_SERVER['SCRIPT_FILENAME'])&&realpath($_SERVER['SCRIPT_FILENAME'])===__FILE__){try{$raw=file_get_contents(__DIR__.'/plan.json');$p=json_decode($raw,true);pc_require(is_array($p),'Literal C plan JSON');$counts=pc_gate_plan($p);pc_require(hash_file('sha256',__DIR__.'/source-candidate-trigger.sql')===$p['source_hashes']['candidate_trigger_file_sha256'],'Root reviewed source DDL exact bytes');$sha=hash('sha256',$raw);$runnerSha=hash_file('sha256',__FILE__);$mode=isset($argv[1])?$argv[1]:'--gate';if($mode==='--gate')echo json_encode(['status'=>'PURE_C_PLAN_GATE_PASS','plan_sha256'=>$sha,'runner_sha256'=>$runnerSha,'counts'=>$counts,'DB_connections'=>0,'SQL'=>0,'HTTP'=>0]),"\n";else{pc_require($mode==='--execute','Only pure gate or separately authorized once execute');exit(pc_execute($p,$sha,$runnerSha));}}catch(Throwable $e){fwrite(STDERR,$e->getMessage()."\n");exit(1);}}
