{
  "task": "HRMS_FEISHU_READONLY_TOKEN_CACHE_REFRESH_APPLY_PACK_Z5C",
  "generated_at": "2026-06-03T17:05:38+08:00",
  "status": "failed_or_blocked",
  "backup_or_no_backup_reason": "No broad DB backup executed; write scope limited to feishu_tenant_token_cache through existing provider. Existing token values were never printed.",
  "pre_apply_token_metadata": {
    "ok": true,
    "token_cache_status": "token_cache_expired",
    "token_metadata_status": "token_cache_expired",
    "cache_source": "feishu_tenant_token_cache",
    "token_type": "",
    "expires_at": "2026-05-12T15:49:49.701271+08:00",
    "ttl_seconds": -1905348,
    "readonly_scope_declared": true,
    "write_scope_detected": false,
    "last_refresh_at": "2026-05-12 14:16:38.701305+08:00",
    "provider_usable": false,
    "snapshot_schema_ready": true,
    "next_gate": "FEISHU_READONLY_TOKEN_CACHE_REMEDIATION_PREVIEW_GATE",
    "provider_rework_reason": "token_endpoint_response_shape_code_data_msg_parser_gap"
  },
  "pre_apply_readiness_endpoint_status": 200,
  "pre_apply_snapshot_row_counts": {
    "feishu_readonly_snapshot_runs": 0,
    "feishu_user_snapshots": 0,
    "feishu_department_snapshots": 0,
    "provider_rework_reason": "token_endpoint_response_shape_code_data_msg_parser_gap"
  },
  "pre_apply_master_data_row_counts": {
    "departments": 0,
    "positions": 0,
    "employees": 0,
    "permission_subjects": 0,
    "employee_role_assignments": 0,
    "feishu_user_mappings": 0,
    "provider_rework_reason": "token_endpoint_response_shape_code_data_msg_parser_gap"
  },
  "token_refresh_execution_summary_metadata_only": {
    "executed": true,
    "status": "invalid_response",
    "method": "backend.services.feishu_tenant_token_service.call_tenant_token_endpoint",
    "metadata_only": true,
    "systemd_env_keys_loaded": [
      "FEISHU_APP_ID",
      "FEISHU_APP_SECRET",
      "FEISHU_TENANT_TOKEN_ENDPOINT",
      "HRMS_DATABASE_URL",
      "HRMS_ENABLE_FEISHU_JSAPI"
    ],
    "env_key_presence": {
      "FEISHU_APP_ID": true,
      "FEISHU_APP_SECRET": true,
      "FEISHU_TENANT_TOKEN_ENDPOINT": true,
      "HRMS_ENABLE_FEISHU_JSAPI": true,
      "HRMS_DATABASE_URL": true,
      "provider_rework_reason": "token_endpoint_response_shape_code_data_msg_parser_gap"
    },
    "result_metadata": {
      "ok": false,
      "status": "invalid_response",
      "error_code": "FEISHU_TENANT_TOKEN_RESPONSE_INVALID",
      "response_keys": [
        "code",
        "data",
        "msg"
      ],
      "real_jsapi_enabled": null,
      "token_plaintext_returned": false,
      "tenant_token_cache": {
        "cache_id_present": false,
        "token_plaintext_returned": null,
        "token_source": null,
        "token_status": null,
        "expires_at": null,
        "updated_at": null,
        "provider_rework_reason": "token_endpoint_response_shape_code_data_msg_parser_gap"
      },
      "provider_rework_reason": "token_endpoint_response_shape_code_data_msg_parser_gap"
    },
    "ok": false,
    "provider_rework_reason": "token_endpoint_response_shape_code_data_msg_parser_gap"
  },
  "post_apply_token_metadata": {
    "ok": true,
    "token_cache_status": "token_cache_expired",
    "token_metadata_status": "token_cache_expired",
    "cache_source": "feishu_tenant_token_cache",
    "token_type": "",
    "expires_at": "2026-05-12T15:49:49.701271+08:00",
    "ttl_seconds": -1905350,
    "readonly_scope_declared": true,
    "write_scope_detected": false,
    "last_refresh_at": "2026-05-12 14:16:38.701305+08:00",
    "provider_usable": false,
    "snapshot_schema_ready": true,
    "next_gate": "FEISHU_READONLY_TOKEN_CACHE_REMEDIATION_PREVIEW_GATE",
    "provider_rework_reason": "token_endpoint_response_shape_code_data_msg_parser_gap"
  },
  "post_apply_provider_readiness": false,
  "post_apply_token_cache_metadata_readiness": false,
  "post_apply_required_scope_readiness": true,
  "post_apply_app_install_permission_readiness": true,
  "post_apply_readiness_endpoint_status": 200,
  "post_apply_contract_endpoint_status": 200,
  "post_apply_snapshot_row_counts": {
    "feishu_readonly_snapshot_runs": 0,
    "feishu_user_snapshots": 0,
    "feishu_department_snapshots": 0,
    "provider_rework_reason": "token_endpoint_response_shape_code_data_msg_parser_gap"
  },
  "post_apply_master_data_row_counts": {
    "departments": 0,
    "positions": 0,
    "employees": 0,
    "permission_subjects": 0,
    "employee_role_assignments": 0,
    "feishu_user_mappings": 0,
    "provider_rework_reason": "token_endpoint_response_shape_code_data_msg_parser_gap"
  },
  "refresh_dry_run_endpoint_gap_still_exists": true,
  "privacy_validation": {
    "token_secret_leak_check": "passed",
    "token_output": false,
    "app_secret_output": false,
    "credential_output": false,
    "env_value_output": false,
    "authorization_header_output": false,
    "raw_token_response_output": false,
    "real_employee_sensitive_field_output": false,
    "public_outputs_metadata_only": true,
    "provider_rework_reason": "token_endpoint_response_shape_code_data_msg_parser_gap"
  },
  "redline_checks": {
    "snapshot_refreshed": false,
    "snapshot_rows_written": false,
    "master_data_tables_written": false,
    "real_employee_imported": false,
    "staging_entered": false,
    "employee_draft_created": false,
    "permission_subject_created": false,
    "employee_role_assignment_created": false,
    "real_trial_assignment_created": false,
    "feishu_write_api_called": false,
    "feishu_writeback_executed": false,
    "refresh_dry_run_endpoint_executed": false,
    "active_permission_rule_modified": false,
    "formal_algorithm_executed": false,
    "business_effective_result_generated": false,
    "people_action_executed": false,
    "schema_migration_executed": false,
    "alter_drop_truncate_executed": false,
    "service_restarted": false,
    "nginx_systemd_postgresql_modified": false,
    "token_or_secret_output": false,
    "provider_rework_reason": "token_endpoint_response_shape_code_data_msg_parser_gap"
  },
  "next_gate": "FEISHU_READONLY_TOKEN_PROVIDER_REWORK_GATE",
  "next_task": "HRMS_FEISHU_READONLY_TOKEN_PROVIDER_RESPONSE_PARSER_REWORK_PACK_Z5D",
  "url_validation": [
    {
      "url": "https://hrms.yuechongjia.com/hrms-feishu-readonly-token-cache-refresh-apply.html",
      "status": 200,
      "ok": true,
      "provider_rework_reason": "token_endpoint_response_shape_code_data_msg_parser_gap"
    },
    {
      "url": "https://hrms.yuechongjia.com/outputs/hrms_feishu_readonly_token_cache_refresh_apply_summary_v1.json",
      "status": 200,
      "ok": true,
      "provider_rework_reason": "token_endpoint_response_shape_code_data_msg_parser_gap"
    },
    {
      "url": "https://hrms.yuechongjia.com/outputs/hrms_feishu_readonly_token_cache_refresh_validation_v1.json",
      "status": 200,
      "ok": true,
      "provider_rework_reason": "token_endpoint_response_shape_code_data_msg_parser_gap"
    },
    {
      "url": "https://hrms.yuechongjia.com/outputs/hrms_feishu_readonly_token_cache_metadata_after_refresh_v1.json",
      "status": 200,
      "ok": true,
      "provider_rework_reason": "token_endpoint_response_shape_code_data_msg_parser_gap"
    },
    {
      "url": "https://hrms.yuechongjia.com/outputs/hrms_feishu_readonly_readiness_after_token_refresh_v1.json",
      "status": 200,
      "ok": true,
      "provider_rework_reason": "token_endpoint_response_shape_code_data_msg_parser_gap"
    },
    {
      "url": "https://hrms.yuechongjia.com/outputs/hrms_feishu_readonly_token_cache_refresh_privacy_validation_v1.json",
      "status": 200,
      "ok": true,
      "provider_rework_reason": "token_endpoint_response_shape_code_data_msg_parser_gap"
    },
    {
      "url": "https://hrms.yuechongjia.com/outputs/hrms_feishu_readonly_token_cache_refresh_next_gate_v1.json",
      "status": 200,
      "ok": true,
      "provider_rework_reason": "token_endpoint_response_shape_code_data_msg_parser_gap"
    }
  ],
  "provider_rework_reason": "token_endpoint_response_shape_code_data_msg_parser_gap"
}
