# 0xkaz.com — Full Content > Always building something I've never done before. ## About 0xkaz (Masakazu Ohno) is a developer and real estate investor based between KL, Abu Dhabi, and Baguio. Background: founded @WIKI (wiki hosting, acquired), co-founded WEBSTA (Instagram web viewer, tens of millions of visits), early co-founder of AtCoder (competitive programming), CTO of WeaveDB (decentralized NoSQL on Arweave), DeFi protocols. Now focused on AI/LLMs, RAG systems, and the GCC market. UAE Golden Visa holder. ## Current Experiments - **GulfStraitsAI** (https://gulf-straits-ai.0xkaz.com): AI and tech deal tracker covering the Gulf and Southeast Asia corridor. - **GCC LexAI** (https://gcc-lexai.0xkaz.com): AI regulation Q&A covering all 6 GCC countries — UAE, Saudi Arabia, Bahrain, Qatar, Oman, Kuwait. RAG on Cloudflare Workers + Vectorize + D1. --- ## LLM Cost Governance for a Team of Coding Agents URL: https://0xkaz.com/writing/llm-cost-governance/ Date: 2026-07-03 I gave my team Claude Code, Codex, and Kimi — then couldn't tell who spent what. A self-hostable LiteLLM + BigQuery gateway that puts one gateway in front of every provider: per-user cost, budget caps, and honest adoption tracking instead of a productivity leaderboard. --- ## AgentClip: A Tool for Loop Engineering URL: https://0xkaz.com/writing/agentclip-loop-engineering/ Date: 2026-06-23 The most interesting part of AI agents is not the model. It is the loop. A prompt gets you an answer. A loop gets you ongoing work: read something new, compare it against everything you already know, decide if it matters, and surface it when it does. Without the loop, an agent is just a chatbot with a longer memory. With the loop, it becomes something that watches while you do other things. This idea — loop engineering — has become one of the dominant threads in agent tooling this year. The conversation has shifted from "which model is best?" to "what does the loop actually do?" People are less interested in a one-shot answer and more interested in an agent that keeps running: planning, generating, evaluating, and deciding when to stop. I built AgentClip as the inbox that triggers that loop. ### What AgentClip Does AgentClip has three pieces: - **Browser extension** — select text on any page and clip it. - **Mobile app** — share a link or paste text into AgentClip from iOS/Android. - **Agent interface** — both MCP and REST, so local AI agents can read, search, and process everything I clip. Clips go to Cloudflare Workers, are stored in D1, and are indexed for search. The agent does not need to know any of that. It calls `search_clips` or `GET /clips/search` and gets back what it needs. The point is not to build a better bookmark manager. The point is to build an inbox that agents loop over. ### From Storage to Inbox Most clipping tools ask: "How do we help the user organize what they saved?" That was never my problem. My problem was the opposite: I saved things and forgot to do anything with them. Read-later queues became graveyards. Bookmarks became folders I never opened. The bottleneck was not storage. It was processing. AgentClip treats each clip as a trigger. A clip is not "something I might want later." It is "something I want something done about." That could mean summarize, compare, find related ideas, or just tell me if it conflicts with something I already believe. The inbox is the interface. The agent is the worker. The loop is where the value is. ### What the Loop Actually Does The question everyone asks about loop engineering is: what does the loop actually do? Here is what a typical AgentClip loop looks like on my machine. It is not abstract. It is a script that runs every morning and asks four concrete questions: 1. What did I clip in the last 24 hours? 2. For each new clip, what older clips seem related? 3. Does any new clip change or contradict something I saved before? 4. Write a short digest and save it as a Markdown file. The output lands in my local notes directory as something like `2026-06-23-agentclip-ideas.md` with a few sections: - Summary of the new clip - Older clips that seem related - A tentative conclusion or open question - Suggested next searches That Markdown file becomes the trigger for the next loop. I point another local agent at it — often Claude Code or a local LLM — and ask it to expand the research, find gaps, or sketch an implementation. The first loop turns a raw clip into a structured note. The second loop turns the note into a design or a draft. I keep each loop small on purpose. The first agent does not write code. The second agent does not browse the web. Each one has a narrow job, and AgentClip is the shared inbox they both read from. Another loop runs when I start a coding session. It searches AgentClip for clips related to the current git branch name or recent file changes, then prints the top three matches. Before I write new code, the agent reminds me what I already read about the topic. ### MCP and REST MCP is the convenience layer. Claude Code, Cursor, or any MCP client can discover AgentClip and call it like a native tool. That is how I do ad-hoc exploration. REST is the control layer. When I write my own watch script, it fetches clips through `GET /clips` and passes them to an LLM on my own terms. The LLM does not need to know AgentClip exists. It just receives the data and reasons about it. I use both. MCP for interactive work. REST for scheduled loops. ### How the Loop Ends This is the part of loop engineering nobody talks about enough. If you do not design the end condition, the loop runs forever and bills forever. My loops end in one of three ways: - **Time box** — run for 15 minutes, then stop. - **Task limit** — process the five most recent clips, then stop. - **Token budget** — spend up to N tokens, then stop and wait for me. The exact condition depends on the task. A daily summary loop gets a small budget. A deep research loop gets a larger one. The important thing is that the loop never runs open-ended. An infinite loop is not engineering. It is a bug. ### Local-First The storage is in Cloudflare, but the agents are local. That distinction matters to me. The loops run on my Mac mini or laptop, usually inside tmux. They can call local tools, write local files, and cross-reference clips against code I have on disk. A cloud agent could not do that without me shipping everything outward. Keeping the loop local also means I control when it runs, what models it uses, and when it stops. It is slower to set up than a managed agent, but the boundary is clear. ### Architecture ``` Chrome Extension / Expo App │ ▼ Cloudflare Workers (Hono) │ ┌────┴────┐ ▼ ▼ D1 Vectorize (metadata) (embeddings) │ ▼ Local AI Agents via MCP + REST │ ▼ Continuous loop: read → connect → surface ``` The browser extension captures the selected text, URL, and page title. The mobile app does the same through the share sheet. Both send the clip to Workers, where it is stored in D1 and indexed. When an agent asks a question, Workers queries the index, fetches the corresponding rows from D1, and returns the result. ### What the Agents See AgentClip exposes two interfaces: **MCP tools:** - `search_clips` — search over all clips. - `get_clip` — fetch a specific clip by ID. - `list_recent_clips` — recent clips. - `add_clip` — write a note back. **REST endpoints:** - `GET /clips` — list clips with filters. - `GET /clips/search` — search clips. - `POST /clips` — create a clip. No agent sees everything at once. They ask. That keeps context windows reasonable and prevents the inbox from becoming noise. ### Multiple Agents, One Inbox I do not run one loop. I run several, each with a different model and purpose. - **Kimi** handles broad research and idea expansion. It is good at taking a single clip and generating angles I would not have thought of. - **Codex** picks up clips that involve code, APIs, or infrastructure. It can turn a documentation link into a working prototype faster than I can. - **Claude Code** does deep local work. It reads my codebase, queries AgentClip for relevant context, and iterates on implementation. - **Local LLM via llamafile** runs the cheap loops: summarization, redundancy checks, and anything I do not want to send to the cloud. They all read from the same inbox. Each one takes the clips it is good at and ignores the rest. This is cheaper and more flexible than asking one model to do everything. ### What I Tried Before This I wanted automatic processing of research and ideas, so I tried more autonomous agents — the kind that watch, learn, and act on their own. The premise is appealing: feed it clips, and let it decide what matters. In practice, I found them hard to debug and harder to trust. When an agent decides on its own what to remember and what to do, you spend as much time managing the agent as you would have spent doing the work yourself. Local coding agents with MCP — Claude Code, in particular — turned out to be a better fit. They are transparent: I can see what they read, what they call, and what they produce. They are controllable: I define the tools and the boundaries. And they compose well: I can route clips to them through AgentClip and let them decide whether to act. That is why AgentClip stays simple. The loop is not the brain. The loop is the plumbing. ### The Mobile Piece Most interesting links reach me on my phone — Twitter, newsletters, chat apps. The mobile app is Expo + React Native with the same Workers endpoint and share sheet flow. The share sheet integration matters because the moment I decide to "save this for later," friction determines whether it actually happens. If I can send it to the agent inbox in two taps, it gets processed. If it requires opening another app and deciding where to put it, it does not. ### What This Is Not AgentClip is not a team knowledge base. It is not a replacement for Notion or a bookmark manager. It is a single-user inbox designed for local agents. If multiple people need access, the design would change — permissions, workspaces, audit logs. That is a different product. This one is mine. ### What Comes Next The loop is still mostly reactive: agents process clips and surface them on a schedule. I want it to become more proactive — to notice that I am working on something and mention a connection without being prompted. That requires the agent to have a sense of what I am doing, which is a harder problem. But the inbox, the retrieval layer, and both interfaces are now in place, so the rest is loop tuning. ### Try It AgentClip is open source: - [github.com/0xkaz/agentclip](https://github.com/0xkaz/agentclip) — Chrome extension + Cloudflare Workers + MCP server + REST API - [github.com/0xkaz/agentclip-mobile](https://github.com/0xkaz/agentclip-mobile) — Expo + React Native client Both are early. The extension is usable. The mobile app is usable. The MCP server and REST API are stable enough that I run them in daily sessions across multiple agents. If you also want your agents to keep working while you are not typing at them, the pattern is worth stealing. --- ## ADGM Rental Advertising: How MADHMOUN Works in Practice URL: https://0xkaz.com/writing/adgm-madhmoun-rental-permit/ Date: 2026-04-19 Abu Dhabi and ADGM now require a government permit before any rental listing can go live. What MADHMOUN is, how the AccessRP approval works, the three-agent cap, and what it costs (AED 52.5, paid by the agent). --- ## ADGM Tech Startup License: Self-Filed UAE Entity, $1,000, No Agent URL: https://0xkaz.com/writing/adgm-tech-startup-license/ Date: 2026-03-30 I set up an ADGM Tech Startup License in 2022 without a CSP — no agent, no intermediary. What the process actually looked like, where I got stuck on office space, and what has changed since. --- ## Offline Claude Code on Mac mini M4: Local LLM, OS Sandbox, No API Calls URL: https://0xkaz.com/writing/claude-llamafile-sandbox/ Date: 2026-03-29 How I run Claude Code completely offline on a Mac mini M4 — local Qwen3 via llamafile, Safehouse OS sandbox, and --dangerously-skip-permissions made safe. Cost: $0/month in API fees. --- ## Telegram Bridges for Gemini CLI and Codex After Hitting Claude Code Limits URL: https://0xkaz.com/writing/telegram-bridges-gemini-codex/ Date: 2026-03-29 After hitting Claude Code limits, I built small Telegram bridges for Gemini CLI and Codex to get the async mobile workflow back without giving up local-first control. --- ## UAE Property Investment: Cost Structure, Rental Yield, and Market Signals URL: https://0xkaz.com/writing/uae-property-investment-cost/ Date: 2026-03-28 A real-unit breakdown from Al Reem Island (Sky Tower, 1,437 sqft): service charges, district cooling, net vs gross yield, and what happens to returns when the unit sits vacant. --- ## Abu Dhabi, UAE: Early Lease Termination at Al Reem Island During the Iran Conflict URL: https://0xkaz.com/writing/al-reem-early-termination/ Date: 2026-03-26 What actually happened when my tenant asked to leave early: ADGM's new jurisdiction over Al Reem, AccessRP, a 2-month penalty clause, a cheque that failed, and a market that went quiet overnight. --- ## Notes on JB: The Data Center Boom Next to Singapore URL: https://0xkaz.com/writing/johor-bahru-datacenter/ Date: 2026-03-25 Personal analysis. Data from Knight Frank 2024/2025 Malaysia Data Centre reports, Johor Investment Authority, TNB, and official press releases. Capacity figures as of mid-to-late 2025. March 2026. I live in Kuala Lumpur. Since 2023, it has been impossible to read Malaysian business news without encountering another data center announcement. Microsoft. ByteDance. Google. Equinix. Numbers in the billions of dollars, with Johor Bahru as the destination. I kept noting them without understanding the actual structure of what was happening. ### Why JB Singapore ran out of space. In 2019, Singapore imposed a moratorium on new data center construction. Data centers were consuming 7 percent of Singapore's electricity, and the government froze approvals on sustainability grounds. The ban was lifted in 2022, but large hyperscale projects have remained difficult to get through since. Then ChatGPT launched in November 2022 and demand for AI compute exploded — at precisely the moment Singapore's doors were closed. JB was the obvious answer. Not because it was the cheapest or most convenient in isolation, but because it is one kilometer from Singapore via the causeway. That one kilometer matters. Sub-5ms latency to Singapore makes a JB data center functionally equivalent to being in Singapore for multinationals headquartered there. Bangkok and Jakarta cannot replicate this. The distance itself is the competitive advantage. The institutional framework followed. Malaysia and Singapore signed an MOU in January 2024, and the Johor-Singapore Special Economic Zone (JS-SEZ) formal agreement was signed by both governments on January 7, 2025. ### The Scale Numbers from mid-2025: Live capacity 487MW, under construction 324MW, committed 1.4GW, pipeline 3.4GW. Total committed investment MYR182.96 billion ($41 billion). 51 approved projects. IT capacity projected to grow from ~1.5GW to 6.4GW by 2031. ### Who Is Here Developers and operators are a genuinely multilateral mix: YTL (Malaysian), Keppel/Princeton Digital/STT GDC/Nxera (Singapore-based), GDS and Bridge DC (Chinese), Yondr/Vantage/AirTrunk/Equinix (Western). Tenants are US and Chinese hyperscalers: Microsoft, ByteDance, AWS, Google, Oracle, Sea. Construction goes to Malaysian contractors (IJM won RM1.4B contract). Financing from Western institutional lenders — Yondr's campus drew IFC, DBS, Deutsche Bank, BlackRock GIP, HSBC, ING, Natixis for over $900M. ### The US-China Problem ByteDance committed $2.1B+ in Malaysian investment. In February 2025, three people were charged in Singapore for illegally reselling NVIDIA GPUs routed through Malaysia to China. The US identified Malaysia as a potential GPU transit route and began drafting export license requirements. Malaysia is structurally caught: drawing Chinese investment while being scrutinized by the US as a bypass route. ### Power, Water, and the Regulatory Shift JB has experienced blackouts and water shortages. Large data centers can consume up to 50 million liters of water per day — over 300,000 households' worth. TNB committed RM43B in grid upgrades for 2025-2027. Regulatory tightening in stages: vetting committee June 2024 (~30% rejected); Tier 1/2 approvals suspended November 2025; halt on non-AI data centers declared February 2026. The $41B committed pipeline continues executing regardless. ### Employment: The Honest Answer Construction is local and direct. Operations technicians hired locally at MYR3,500-4,000/month — below the Malaysian ICT sector median of MYR5,300/month. Engineers and management are the structural problem: Singapore's ICT median is SGD7,600/month (~MYR26,000). Crossing the causeway more than doubles the salary. 1.86 million Malaysians live abroad, 1.13 million in Singapore. ### The MYR Effect In 2025, MYR was Asia's top-performing currency — up ~9% against the dollar to 4.07. DC-related FDI is cited as structural support. Who benefits: Malaysian economy broadly, MYR-denominated asset holders, consumers. Who pays: anyone living on foreign income while spending in MYR. ### What I'm Taking From This The facilities were developed by a multinational mix. The compute is used by US and Chinese hyperscalers. The money came from Western institutional investors. The buildings were constructed by local contractors. The operational expertise comes from expatriates or Malaysian engineers who moved to Singapore. The power and water costs are borne by JB's residents. The geopolitical risk of the US-China squeeze falls on Malaysia. The regulatory shift from quantity to quality has started, but the $41 billion pipeline flows regardless. --- ## Desert and Rainforest — Why Abu Dhabi and Johor Bahru Became AI Hubs at the Same Time URL: https://0xkaz.com/writing/desert-rainforest-ai-hubs/ Date: 2026-03-25 Personal analysis. Not investment advice. Data from public sources, Knight Frank, company announcements, and US/UAE/Malaysia government releases. March 2026. The two cities have almost nothing in common on the surface. One is a desert oil state, the other an equatorial multi-ethnic nation. Yet both became concentrated destinations for global AI data center investment around the same time — and continue to be. Why did the same thing happen in such different places? And beneath the surface similarity, what is fundamentally different? ### The shared logic: both absorbed overflow demand JB's growth came from Singapore's moratorium. When Singapore effectively stopped approving new data centers in 2019, demand redirected to JB, one kilometer across the causeway. Abu Dhabi's rise has a structurally similar story. Dubai's premium areas face rising land costs and zoning constraints. Abu Dhabi offers purpose-built development zones — KEZAD and Masdar City — where land, power, and infrastructure connections are bundled together by state-backed entities, making large-scale AI campuses easier to develop. The investment dynamic was also different from JB in one important way. It was largely the UAE side — Sheikh Tahnoon bin Zayed and G42 — that actively courted US hyperscalers, and the US that responded. The result was Stargate UAE: a joint venture between G42, OpenAI, Oracle, Nvidia, and SoftBank, announced in May 2025 with both the UAE president and Donald Trump present. The planned capacity is 5GW — larger than JB's entire pipeline of 3.4GW. Both cities, in other words, were shaped by the same combination of forces: constraints at nearby established hubs, and deliberate investment attraction on their own part. ### The key difference: the type of geopolitical risk Both cities appear to face "US-China tension" as a risk, but the nature of that tension is completely different. Abu Dhabi chose a side. G42 divested from all its Chinese investments in 2023 and 2024, removed an estimated $1.7 to $2 billion worth of Huawei equipment from its data centers, and exited its stake in ByteDance. This was a direct response to US government pressure — effectively a loyalty test. In return, the US approved the export of up to 500,000 advanced NVIDIA processors annually to the UAE. The Stargate UAE campus is designed specifically for US hyperscalers, with strict KYC protocols controlling access. This is distinct from the broader UAE market: Alibaba Cloud operates a data center region in Dubai, and Huawei has cloud infrastructure in Saudi Arabia. Stargate UAE is one facility within a region where Chinese operators also have a presence — it is not a China-free zone across the UAE. Malaysia is trying not to choose. The Malaysian government actively welcomes investment from both sides. Former deputy minister Ong Kian Ming has publicly stated that JB is open to US and Chinese tech companies alike. Prime Minister Anwar maintains a non-aligned posture. The consequence of that openness has been pressure from both directions: the US scrutinized Malaysia as a potential GPU diversion route to China, and when Malaysia cooperated with US oversight requests, China criticized it for taking sides. Neither position is obviously right. But the risk profiles are different. Abu Dhabi's risk is concentrated: if its relationship with the US deteriorates for any reason, the entire model breaks. Malaysia's risk is diffuse and ongoing: either side can apply pressure at any time. ### Physical war risk In late February 2026, the US and Israel launched strikes against Iran. As of the time of writing, Abu Dhabi's data center infrastructure is exposed to real military risk. The UAE intercepted 165 ballistic missiles, two cruise missiles, and 541 drones over two days of exchanges. Thirty-five drones and five projectiles got through, hitting Jebel Ali Port and buildings in Dubai. An Amazon data center in the UAE reportedly caught fire during the strikes. "It is cheaper to attack than to defend." That is the asymmetric reality of the conflict. JB has no equivalent physical military risk. The geopolitical squeeze is real, but missiles are not flying toward Johor. For long-term infrastructure investment, that difference is not trivial. ### Power and cooling: desert versus rainforest Abu Dhabi is an oil and gas producer with abundant, stable power. Stargate UAE combines nuclear, solar, and gas in its energy design. Grid reliability is among the highest in the world. The challenge is cooling. Servers that generate large amounts of heat in 50°C desert conditions require substantial energy to cool. This pushed Abu Dhabi toward liquid cooling, reclaimed water systems, and seawater cooling years before Malaysia faced the same pressure. The Middle East confronted the "stop using potable water for cooling" problem a decade earlier than JB is confronting it now. JB sits on the equator. It is not as hot as Abu Dhabi, but high humidity reduces air cooling efficiency. Power comes from TNB's grid, and whether supply can keep pace with the 3.4GW pipeline remains genuinely uncertain. In terms of energy headroom, Abu Dhabi has a clear advantage. ### Infrastructure depth: what is buried underground In a previous piece about Abu Dhabi, I wrote about what I found when I looked into the facilities near Al Reem Island that I had walked past without thinking much about. The STEP sewage tunnel runs 41 km at depths up to 105 meters, operating entirely on gravity with no intermediate pumping stations. A power outage does not stop it. The Liwa aquifer storage project — the world's largest desalinated water ASR project — holds enough emergency supply to provide the entire city of Abu Dhabi for 90 days. Both were built over decades, largely invisible to residents. JB's infrastructure is not yet at that level. Water problems became visible because the underlying systems were too fragile to handle the sudden surge in industrial demand. Bridge DC is building a reclaimed water plant, AirTrunk is deploying liquid cooling, Microsoft is designing zero-water-evaporation facilities. These are real improvements. But they are starting in 2024 and 2025. Abu Dhabi's infrastructure depth took decades to build. ### What each city is actually building This may be the most fundamental difference. Abu Dhabi is trying to become an AI-producing country. Stargate UAE, G42's Falcon (an Arabic-language LLM), Mohamed bin Zayed University of Artificial Intelligence — Abu Dhabi is not just hosting AI infrastructure. It is trying to build the capacity to create AI. The data centers are a means, not an end. The national strategy is to use AI the way oil was used: as the foundation for the next 50 years of economic output. The Stargate UAE campus includes a science park for AI innovation. The design integrates research, development, and talent training, not just compute capacity. JB is functioning as a compute location. JB's role is primarily to serve as a cheaper extension of Singapore. Tenants are multinationals headquartered in Singapore; JB provides the backend at lower cost. Anwar's repeated insistence on economic spillover reflects his recognition that this model, if left unchanged, does not transfer much capability to Malaysia. Malaysia has a National AI Strategy (NAIES), and the ambition to use AI for economic development is genuine. But the practical reality is closer to "attract AI infrastructure and extract economic benefit" than "build AI." ### The post-oil bet Reading Abu Dhabi's AI investment purely as infrastructure misses the point. The Abu Dhabi Economic Vision 2030 was set out in 2006. Its core objective: shift from oil dependence toward a knowledge-intensive economy. By 2025, non-oil sectors already account for over 75 percent of UAE GDP — partly a policy success, partly a reflection of urgency about what comes after oil. Seen through this lens, the AI investment is a straightforward move: use oil revenues to buy the next resource. If oil was the defining resource of the 20th century, compute capacity may be the defining resource of the 21st. G42, Mubadala, ADIA, MGX — Abu Dhabi's sovereign capital concentrating in AI infrastructure reflects something more than investment return calculations. It is about securing a strategic resource before the competition locks it down. The Stargate UAE announcement framed this explicitly: a facility capable of reaching half the world's population within a 3,200 km radius. India, Pakistan, East Africa, the broader Middle East — all within that range. JB competes on "5ms from Singapore." Abu Dhabi is competing on "AI infrastructure hub for the Global South." The ambition is a different order of magnitude. ### The non-aligned legacy and its limits The UAE has historically been skilled at not choosing sides. It is a member of the Non-Aligned Movement, joined BRICS in January 2024, maintains security ties with the US, deep economic ties with China, and close trading relationships with India. This multi-alignment strategy — staying useful to all major powers — is how a small country of roughly 10 million people has punched well above its weight diplomatically and economically. That equilibrium began to fracture under AI geopolitical pressure in 2023 and 2024. G42 removing an estimated $1.7 to $2 billion worth of Huawei equipment and divesting all Chinese investments was a direct response to US pressure — a loyalty test passed. At the same time, the UAE maintained its BRICS membership, continued participating in mBridge (China's cross-border digital currency settlement platform), and kept economic relationships with Chinese firms in other sectors. The architecture being constructed is: technology aligned with the US, financial and economic relationships deliberately diversified. Whether this two-layer structure is sustainable depends on how far US-China competition intensifies. As AI infrastructure becomes a more explicit front in that competition, the space for "both sides" shrinks. Abu Dhabi is trying to hold the non-aligned identity while having already made the harder choice at the technology layer. Malaysia's Anwar is attempting the same thing at a different level of commitment. Neither will find it easy if the competition continues to escalate. ### Strengths and risks Abu Dhabi's strengths: State-designed stability. Oil revenues underwrite power and water infrastructure. Clear US alignment secures chip supply. Infrastructure depth provides long-term reliability. Abu Dhabi's risks: Direct physical exposure to the Iran conflict. Having chosen a side completely, there is no fallback if the US relationship changes. JB's strengths: The irreplaceable proximity to Singapore via the causeway. The flexibility to attract both US and Chinese investment. Malaysia's economic growth momentum. JB's risks: Continuous US-China pressure from both directions. Power and water infrastructure that is still catching up. The structural risk of remaining a "compute location" without becoming more. ### Same phenomenon, different futures Abu Dhabi's data center buildup started earlier — Microsoft opened Azure regions there in 2019, and the hyperscale investment wave accelerated through the early 2020s. JB's rapid expansion began around 2023, following the ChatGPT moment. Both pipelines now extend well into the 2030s. On the surface it looks like the same story. Underneath, the design logic is fundamentally different. Ten to twenty years from now, the divergence will likely be clearer. Abu Dhabi will have become a genuine AI-producing hub in deep partnership with the US — or the long war in the Middle East will have disrupted that ambition. JB will have absorbed Singapore's overflow demand steadily and pragmatically — or newer competitors like Batam will have eroded its advantage. The reasons to watch both are specific: Abu Dhabi for the depth of its state-backed infrastructure and its firm US alignment; JB for the proximity to Singapore that no other city can replicate. Those are entirely different reasons — which is precisely the point. Having once lived in Abu Dhabi, now on MM2H in Malaysia with property on Al Reem, I have had an unusually direct view of both. Related terms: Stargate UAE, G42, MGX (Abu Dhabi AI investment vehicle), STEP (Abu Dhabi deep sewer tunnel), ASR (Aquifer Storage and Recovery), JS-SEZ, NAIES (Malaysia's National AI Strategy). --- ## What I Found Underground in Abu Dhabi While Reading About Iran's Attacks on Gulf Desalination Plants URL: https://0xkaz.com/writing/abu-dhabi-underground-infrastructure/ Date: 2026-03-25 Personal analysis. Not investment advice. Geopolitical data from Wikipedia, Al Jazeera, Xinhua. Infrastructure data from DEWA, ADSSC, WaterWorld, MEED. March 2026. On February 28, 2026, the US and Israel launched strikes against Iran. From the start, the conflict went in an unexpected direction. Targets were not just military sites — desalination plants started getting hit. On March 7, a plant on Iran's Qeshm Island was attacked (Iran blamed the US; the US and Israel denied it). The next day, an Iranian drone struck a desalination facility in Bahrain. In Fujairah, UAE, the port and oil storage facilities took direct hits, triggering fires and suspending oil operations. One researcher put it plainly: "Oil built the Persian Gulf. Desalinated water keeps it alive." That infrastructure is now part of the conflict. ### The "Dubai loses water in one strike" claim Social media has been circulating a story that Dubai is one attack away from a water crisis, because everything depends on Jebel Ali. The concern is not completely unfounded. Jebel Ali holds a Guinness World Record as the world's largest single-site desalination facility, producing 490 million imperial gallons of water per day. It covers most of Dubai's water and electricity supply. But "one strike and it's over" is an exaggeration. Jebel Ali is actually made up of 43 MSF (Multi-Stage Flash) distillation units plus 2 reverse osmosis plants, spread across stations D, E, G, K, L, and M. A single explosion cannot take all of them down simultaneously. Dubai also has additional smaller plants, and there is a wider water transmission grid across the UAE that allows inter-emirate supply in emergencies. On top of that, DEWA had been working toward a 90-day emergency underground water reserve at Jebel Ali, targeting a storage capacity of 6,000 million imperial gallons when complete. There is real risk here. But it is not a single point of failure. ### What I actually wanted to write about: Abu Dhabi's infrastructure While going through all of this, I ended up down a rabbit hole about Abu Dhabi's water and sanitation systems — and found some things I had not expected. I invest in property on Al Reem Island, so I have walked past various utility buildings and facilities there without thinking much about them. I had no idea what was actually inside them, or what was happening underneath. ### Why does Abu Dhabi flood when it rains? Abu Dhabi gets rain maybe once or twice a year. When it does, roads stay flooded for half a day. For one of the wealthiest cities in the world, the drainage seems oddly inadequate. The reasoning is straightforward: cost versus frequency. Building a billion-dollar stormwater drainage network for rain that comes two days a year makes no economic sense. In a desert environment, drainage pipes also face constant problems — sand clogging and salt corrosion make maintenance expensive. So roads temporarily flooding is accepted as a minor inconvenience. What is not accepted as an inconvenience is the water supply failing. That is treated as an existential problem, and the spending reflects it. ### The Liwa underground water reserve About 160 km southwest of Abu Dhabi city, beneath the Liwa sand dunes, sits the world's largest desalinated water Aquifer Storage and Recovery (ASR) project. The concept: pump surplus desalinated water into the underground sand aquifer during periods of high production, then recover it when needed. Abu Dhabi started feasibility studies in 2001, ran pilots from 2003 to 2009, built the full facility from 2009 to 2016, and has been running large-scale injection since 2015. Total investment was around $350 million. Storage capacity is approximately 26 million cubic meters, with recovery efficiency of 85–95%. The target: supply the entire city of Abu Dhabi for 90 days from this reserve alone. This is not something you see mentioned in real estate brochures. But it is sitting under the desert. ### A sewer tunnel that goes 105 meters underground This is the part I found most surprising. Abu Dhabi has a deep gravity sewer system called STEP — the Strategic Tunnel Enhancement Programme. Total cost: approximately $1.9 billion. The main tunnel runs 41 km from Abu Dhabi island through the mainland to a treatment facility at Al Wathba. An additional 43 km of link sewers feed into it, making the total network around 84 km. The depth is what stands out. The tunnel starts at around 27 meters below ground on Abu Dhabi island. As it reaches the mainland it descends to 80 meters. At the deepest point — the Al Wathba pumping station — it reaches 105 meters underground. The reason for going that deep is straightforward engineering: the system runs on gravity alone for nearly its entire length. To move wastewater by gravity over 35+ km without intermediate pumping stations, you need a continuous downward slope, which means digging deeper as you go. This design eliminated 35 existing pump stations across the network, removing a significant number of failure points. The treated output does not go to waste. Wastewater collected through STEP is 100% recycled and used for irrigation — the parks, grass, and trees you see around Abu Dhabi are kept green with reclaimed water that traveled 105 meters underground before being cleaned and distributed. One detail worth noting: in some areas of Al Reem Island, vacuum trucks still collect sewage the old way. The deep tunnel infrastructure and the vacuum truck coexist. That gap is a reasonable picture of where the city's infrastructure priorities sit. ### The cooling risk that doesn't get talked about Al Reem Island has its own water supply and district cooling infrastructure — including a 57,000-refrigerant-ton cooling plant serving the Shams development. District cooling is the dominant air conditioning model across the UAE. Instead of individual outdoor units on each building, a central plant produces chilled water and distributes it through underground pipes to connected buildings. It is more energy-efficient and makes sense at urban scale. For Al Reem, this means the island has a degree of self-sufficiency. Even if cut off from the mainland, it can continue producing cooling, at least while the island's plants are running. But here is the structural weak point. Water can be piped over long distances. Chilled water cannot. Heat loss over long pipe runs makes it impractical to supply district cooling from far away. If the cooling plant on the island were damaged or shut down, there is no quick way to route cooling from the Abu Dhabi mainland. In a city where summer temperatures exceed 50°C, losing air conditioning is not just uncomfortable. It makes a building uninhabitable within hours. By that measure, the real infrastructure vulnerability in the UAE is not water — it's cooling supply continuity. ### What actually determines a city's asset value In a world where physical infrastructure attacks are no longer hypothetical, I think what determines the long-term value of urban real estate is what you cannot see from the street. Not the towers. Not the mall. Not the view. - A sewer tunnel buried 105 meters underground, built to last 100 years - 90 days of emergency drinking water stored in an aquifer 160 km away - Nine geographically distributed desalination plants connected by 3,500 km of pipelines - An island-level cooling system that can run independently if needed These are the things a national government spends billions on over decades, quietly, without much fanfare. "How impressive does it look from above" is a reasonable thing to evaluate. But "how robust is what's below" is probably more relevant when you're thinking about what happens if things get difficult. --- ## UAE Solar Is Cheaper Than Qatar's Gas. Notes on Gulf AI Infrastructure Power. URL: https://0xkaz.com/writing/uae-solar-ai-infrastructure/ Date: 2026-03-25 Personal analysis, not investment advice. Data from public sources: Masdar newsroom, DEWA, EWEC, PV Tech, Data Center Dynamics, KAHRAMAA. March 2026. Iran's strikes on Gulf gas infrastructure since late February have accelerated a conversation that was already happening in GCC energy circles. The Ras Laffan disruption — Qatar's LNG processing complex, the largest in the world, taking direct hits — made a structural question suddenly urgent: what happens to Gulf AI infrastructure plans when the power supply isn't physically secure? Here's what makes that question interesting for infrastructure builders: Iran's strikes didn't cause this, but they made it visible. UAE solar auction prices fell below Qatar's subsidized gas electricity rate years ago — not recently. The two facts are unrelated in cause but connected in what they mean. ### The price inversion that already happened (years ago) Starting around 2019 and accelerating through 2025, UAE wholesale solar got cheaper than Qatar's subsidized gas grid. This didn't happen because of the current conflict. It happened because of solar cost economics. UAE solar auction prices are now $0.014–0.024/kWh. Qatar's business electricity rate (KAHRAMAA, subsidized gas) is $0.036/kWh. That's a 33–60% gap — in the wrong direction from what most people assume about GCC energy. Dubai's MBR Solar Park Phase 3 cleared at $0.0299/kWh in 2017. Phase 5 hit $0.01653/kWh. Phase 6 (DEWA, 1.8 GW, Masdar as developer) cleared at $0.01622/kWh and went operational in Q4 2024. Abu Dhabi's Al Khazna IPP (EWEC, 1.5 GW, Engie + Masdar) was awarded in 2025 at $0.01459/kWh — the lowest utility-scale solar price in the region. Even the 2019 Noor Abu Dhabi price ($0.0242/kWh) was 33% cheaper than Qatar's current gas rate. Price trajectory: $0.0242 (2019) → $0.01653 → $0.01622 → $0.01459 (2025). About 40% down over six years. Driven by Chinese panel manufacturing scale, better project financing, and Abu Dhabi's high solar irradiance (~2,200 kWh/kWp/year). The inversion happened well before any geopolitical disruption. Iran's attacks didn't create it. They made it matter to a different audience. ### What the Ras Laffan disruption changes Qatar's Ras Laffan industrial city is not just an LNG processing hub. It is Qatar's power generation supply chain. The country runs on gas. Gas processing happens at Ras Laffan. The grid follows from there. Iran's strikes surfaced a concentration risk that Gulf infrastructure planners always knew was there but treated as low-probability. The deterrence assumption — that attacking Qatar's LNG would invite overwhelming response — is now being tested. For AI infrastructure planning, this matters in a specific way. Long-duration GPU infrastructure has a 5–10 year capital horizon. Decisions made in 2026 pick power supply arrangements running into the 2030s. "Low-probability geopolitical risk" looks different once it's been realized once. The failure mode difference: a Ras Laffan attack disrupts Qatar's entire power generation supply chain — one geographic concentration. An attack on UAE solar farms is damaging but not systemically crippling — panels are distributed across large areas, replaceable from a global supply chain, and Barakah nuclear plants are hardened, dispersed facilities. Abu Dhabi saw drone and missile strikes in January 2022. The point is that a gas-monoculture grid and a solar+nuclear grid have structurally different failure modes. ### The post-ceasefire thesis Once this ceasefire holds, the conversation shifts. During active conflict the story is: "Qatar's LNG is disrupted, energy prices are elevated, Gulf data center plans are on hold." The post-ceasefire question is different: which GCC country came out with its infrastructure thesis intact? Qatar's answer is complicated. Ras Laffan will be repaired. The LNG reserves aren't going anywhere. But the event happened. The concentrated risk got actualized. For sovereign funds and hyperscalers allocating 10-year infrastructure capital, that actualization changes the probability weighting on something they previously treated as near-zero. UAE's answer is simpler. The energy infrastructure being built — solar, storage, nuclear — was being built anyway, for economic reasons that predate the conflict. The Masdar 5.2 GW Round-the-Clock project didn't get faster or slower because of Iran's attacks. Barakah's output didn't change. What the conflict did is make the structural difference legible to people who weren't tracking Gulf energy economics. The UAE's deliberate move away from gas dependency will look different in retrospect — not because it changed, but because what gas dependency means just got demonstrated in a neighbor's backyard. ### The intermittency problem nobody lets you skip Cheap solar at $0.014/kWh is not cheap AI power. Not yet. Data centers need power 24/7. Solar delivers 8–12 hours a day, peaking around noon and dropping hard after 4pm. A GPU cluster doing model training doesn't care that the sun is down. UAE retail electricity ($0.082–0.095/kWh for business customers) is a blended rate: cheap solar when the sun is up, gas peakers at night. Large data centers negotiate direct PPA terms at scale — but even a direct solar PPA leaves the nighttime problem unsolved. The project that changes this is now funded and under construction. ### Masdar's round-the-clock project In January 2025, Masdar and EWEC announced a 5.2 GW solar PV + 19 GWh battery storage complex designed to deliver 1 GW of firm, 24/7 power. Numbers: $6B capital cost. EPC: PowerChina + Larsen & Toubro. Panels: Jinko Solar + JA Solar. Batteries: CATL. Groundbreaking: October 2025. Target operational: 2027. The math: 5.2 GW at Abu Dhabi capacity factors generates ~11,000 GWh/year. That's ~1.25 GW average across 8,760 hours. The 19 GWh of storage bridges the overnight gap (roughly 4–6 hours at 1 GW discharge rate). EWEC and Masdar have been explicit: the target use case is AI data center baseload power. Not a grid-balancing project — a project designed for the power consumption profile of large-scale GPU clusters. At $6/W of firm capacity, the upfront cost is higher than combined-cycle gas ($1–1.5/W). But marginal fuel cost is zero and supply chain risk is manufacturing, not commodity or geopolitical. If the 2027 target holds, this lands exactly when the Stargate UAE cluster needs firm renewable power. ### What UAE data centers actually run on today Khazna AUH6 (G42, Masdar City): 31.8 MW AI-ready facility, operational. Has a dedicated 7 MWp direct solar PPA through Emerge (Masdar + EDF joint venture). Stargate UAE (1 GW cluster, Abu Dhabi) power stack: - Nuclear: Barakah (4 × ~1.4 GW APR-1400, online 2020–2024) — the UAE is the only Arab country with operating nuclear power. - Solar/storage: Masdar 5.2 GW RTC project (2027 target). - Gas bridge: TAQA + EWEC 1 GW OCGT, $980M, operational December 2025. The ADQ + ECP $25B deal is for US data center power generation — UAE sovereign capital investing in US energy markets, not a UAE domestic project. ### UAE vs Qatar: the trajectory | Metric | Qatar (today) | UAE (2024) | UAE (2027) | |--------|--------------|-----------|-----------| | Cheapest power | Gas $0.036/kWh | Solar PPA $0.014/kWh | Solar+storage $0.014/kWh firm | | 24/7 firm renewable | No | No | Yes (Masdar RTC) | | Nuclear baseload | No | Yes (Barakah) | Yes | | Gas dependency | Very high | Declining | Lower | | LNG concentration risk | Ras Laffan (actualized 2026) | Distributed | More distributed | ### What I'm taking from this The energy economics argument against UAE for long-duration AI infrastructure — "it's hot, solar is intermittent, gas backup is expensive" — is getting structurally dismantled. The sequence: 1. Solar auction prices below Qatar's subsidized gas rate. Already done. 2. Barakah nuclear: always-on low-carbon baseload no other GCC state has. Operational now. 3. Masdar 5.2 GW RTC: 1 GW firm solar power with no gas dependency, if it delivers in 2027. 4. OCGT gas bridge covers the gap until then. 5. Ras Laffan disruption: priced gas-grid concentration risk in a way it wasn't priced before. What the conflict didn't change: GPU export controls (still the main GCC AI friction), data sovereignty requirements, talent density. What it did change: the probability weighting on energy supply chain risk for anyone allocating 5–10 year infrastructure capital. The UAE's pre-existing solar+nuclear trajectory now has an external validation event it didn't ask for. Variables worth tracking: Masdar RTC construction progress through 2026–2027; whether EWEC offers direct PPA terms below Stargate-scale (10–100 MW); GPU export control trajectory for UAE under the current US administration. --- ## Naive RAG Is Dead. Production RAG Is Not. URL: https://0xkaz.com/writing/naive-rag-vs-production-rag/ Date: 2026-03-25 The "RAG is dead" camp has been getting louder. Gemini 3 Pro has a 10 million token context window. Llama 4 Scout matches it. Agents using grep and regex are reportedly outperforming vector search. Here's my take after running a RAG pipeline in production on GCC LexAI — a regulatory Q&A assistant over 205 documents: the critics are right about naive RAG. They're wrong that retrieval is over. ### Where the critics are right **Chunking destroys document structure.** Split a legal regulation into 512-token chunks and you lose the hierarchy — clauses that modify earlier clauses, tables that reference definitions three pages back. Standard RAG treats documents as bags of fragments. That's genuinely bad. **RAG pipelines fail through cascading errors.** Chunk → embed → retrieve → rerank → generate: each step can go wrong and errors compound. A bad chunking decision makes the right document unretrievable. The failure surface is large. **Agents outperform naive vector search on reasoning tasks.** An agent that can follow references and navigate document structure handles multi-hop questions better than flat vector similarity. ### Where the conclusion is wrong The critics conflate "naive RAG is broken" with "retrieval is unnecessary." These are different claims. The real debate in 2026 is not RAG vs. no RAG. It's naive RAG vs. intelligent retrieval. Intelligent retrieval keeps the core insight — don't send everything to the LLM every time — while fixing the broken parts. ### 1. Cost — 400× difference at 1K queries/day GCC LexAI has 205 documents, ~8,000 tokens each — about 1.6 million tokens of content. Within Gemini 3 Pro's 10M window. | Approach | Input tokens/query | Cost at 1K queries/day | |----------|-------------------|------------------------| | Full context (1.6M tokens) | ~1,600,000 | ~$120–$480/day | | RAG (top-12 chunks, ~4K tokens) | ~4,000 | ~$0.30–$1.20/day | Full context at 1K queries/day costs $3,600–$14,400/month. RAG costs under $36/month. That 400× gap doesn't close when you scale up — it widens. ### 2. Advertised context ≠ effective context Most models degrade before their advertised limit. A model claiming 200K reliable tokens often drops off around 130K, and not gradually — it falls off a cliff. At 1–10M tokens, this is near-certain. The "lost in the middle" problem the critics use against RAG actually hits full-context harder. With RAG you hand the model the relevant passage. With full context you ask it to find a needle in millions of tokens. ### 3. Latency Processing 1.6M tokens adds 5–20 seconds of time-to-first-token latency. Our RAG pipeline: 300–500ms. For a chat interface, the difference between half a second and fifteen seconds determines whether the product feels usable. ### 4. Structured pre-filtering When a user asks "What are SAMA's 2024 AI guidelines?" we filter to Saudi Arabia + issuing_body=SAMA + year=2024 before any semantic search: ```typescript const results = await env.VECTORIZE.query(queryEmbedding, { topK: 12, filter: { country: { $eq: "SAU" }, issuing_body: { $eq: "SAMA" } } }); ``` Full-context can't do this. You send everything and hope the LLM selects correctly. Structured filtering is exact, instant, and free. ### 5. The corpus grows past any window GCC LexAI adds documents every month. Legal tools, knowledge bases, product docs — they all grow. You'll eventually outrun any fixed context window. RAG scales horizontally. Full context has a hard ceiling. ### 6. Verifiable citations In a regulatory tool, users need to check their sources. RAG makes retrieval explicit: every answer links to the exact chunk it came from. Full-context generation loses this. The model synthesizes across documents with no auditable trail. In legal and financial contexts, that matters. ### What this means for how you build RAG in 2026 The criticisms of naive RAG are legitimate. The right response is to fix the broken parts: - Instead of flat chunking → structure-aware segmentation that preserves document hierarchy - Instead of pure vector search → layer in metadata filters and reranking - Instead of blind top-K → verify that retrieved chunks actually answer the question - Instead of single-pass → iterative retrieval for multi-hop questions This is what "Agentic RAG" means in practice. Not the death of retrieval — the maturation of it. | Claim | Verdict | |-------|---------| | "Context windows replace retrieval" | False at production scale — 400× cost difference | | "Chunking destroys structure" | True for naive RAG. Solvable. | | "Cascading failures in RAG pipelines" | True. Agentic RAG reduces the surface. | | "Agents outperform naive vector search" | True for multi-hop. Both can coexist. | | "RAG is dead" | Naive RAG is dying. Production retrieval is evolving. | Built on Cloudflare Workers + Vectorize + D1. --- ## Building a Website from My Phone with Claude Code + Telegram URL: https://0xkaz.com/writing/building-with-claude-code-telegram/ Date: 2026-03-23 I built 0xkaz.com almost entirely from my phone. My machine runs at home in KL. I was in a café in KL, or traveling in Baguio or Abu Dhabi — opening Telegram, typing what I wanted, and watching the site change. The mechanism is Claude Code's Telegram channel plugin. You run Claude Code on a machine at home, install the plugin, point it at your repo, and from that point your Telegram chat becomes a terminal. Claude can read files, edit code, run shell commands, and deploy — all triggered by a message. Location stops mattering. ### How the loop actually works The setup is straightforward. Install the plugin, configure your bot token, and set `TELEGRAM_STATE_DIR` in `.claude/settings.json` to a directory inside the repo rather than `~/.claude/`. That one setting matters: it keeps the bot state version-controlled alongside the project instead of floating loose in your home directory. ```json { "env": { "TELEGRAM_STATE_DIR": "/path/to/repo/.claude/channels/telegram" } } ``` From that point, the interaction is just messaging. I'd send "add a dark mode toggle to the nav" and Claude would read the relevant components, make the edits, and reply with what it changed. I'd send "deploy" and it would run the build and push to Cloudflare Pages. ### Skills make it one-command The real productivity gain came from creating skills — small SKILL.md files that define slash commands for common operations. I have /commit, /push, /deploy, and /feedback. Each one tells Claude exactly what to run and what to report back. Sending /deploy from Telegram and getting back a live URL two minutes later, without touching a laptop, doesn't get old. ### The feedback form got built this way too The most satisfying part: the feedback form at the bottom of each article on this site was designed, implemented, and wired up entirely through Telegram. I described what I wanted — Cloudflare Worker receiving submissions, D1 for storage, Resend for email confirmation, Telegram notification back to me when someone submits — and Claude built the whole stack. Wrangler commands to create the database, migration SQL, the Worker code, the form component in Next.js, the wiring between them. ### What works well **Full async development.** This is the actual unlock. You don't have to sit there watching a terminal. Send the message, go do something else, come back to results. For side projects where you have 20 minutes here and there, this changes the math completely. **No context switching.** One thread. Claude maintains context across the session. **Ship-it decisions are frictionless.** "Commit and push this." One message. Done. ### What to watch **No visual feedback.** You can't see the rendered site in Telegram. For layout and CSS work this is a real limitation. **Session limits.** Long tasks can hit context limits or time out. For anything complex, ask Claude to commit frequently. **Credentials need care.** `.claude/settings.local.json` (gitignored) for sensitive tokens, not the tracked file. ### How close to fully automated? Close, but not there. The loop handles execution well — once you know what you want, Claude can build it. The part that still requires a human is direction. What feature to add next, whether a design choice feels right, whether the copy says the right thing. The risk isn't that Claude does things wrong — it's that it does things confidently in a direction you didn't quite intend. Catching that requires enough technical understanding to read a diff and recognize when something is off. You don't need to write all the code, but you need to know what good looks like. Think of it as a skilled contractor who needs clear briefs. The less specific your direction, the more the output reflects Claude's defaults rather than your intent. Technical fluency makes your briefs better. The site you're reading this on was built this way. --- ## Building RAG on Cloudflare Workers + Vectorize URL: https://0xkaz.com/writing/cloudflare-rag-workers-vectorize/ Date: 2026-03-20 I've been building GCC LexAI — a Q&A tool over UAE and Saudi Arabia AI regulation documents — on Cloudflare Workers + Vectorize + D1. Here's what I'd tell myself before starting. ### The thing that genuinely surprised me Everything runs in one file. Query comes in → embed via Workers AI → nearest-neighbor search via env.VECTORIZE.query() → structured filter via env.DB.prepare().bind().all() on D1 → LLM generation → response. No separate services, no API keys for a vector DB, no managing another instance. On AWS this would be Lambda + OpenSearch + RDS + API Gateway, wired together. On Cloudflare it's one Worker with three bindings. TypeScript types work across all of them. `wrangler deploy` and it's live on the edge. That's the pitch. It holds up. ### D1 + Vectorize: split the work clearly Early on I tried to do too much with Vectorize's metadata filters. It only supports equality — `country = "UAE"` works, `year >= 2022` or partial string matches don't. Once I hit that wall, the right split became obvious: - Vectorize: pure vector similarity search, retrieve more than you need (topK × 3–4) - D1: structured filters, JOIN, WHERE clauses — everything that needs SQL Fetch wide from Vectorize, then narrow in D1. This pattern is clean and fast. The only setup cost: Vectorize doesn't assign vector IDs automatically. You generate UUIDs yourself, store them in D1 (chunks.vector_id), and use that join key everywhere. ### What'll bite you **upsert is eventually consistent.** Push vectors, immediately query — you'll get nothing. Wait a minute, it appears. Not a bug, just how it works. Budget this into your ingestion flow. **topK disappears after filtering.** Set topK=8, apply a D1 WHERE clause, end up with 0 results. The vectors are there; the filter is too narrow. Set topK higher than you think you need, filter downstream. **You can't test Vectorize locally.** `wrangler dev` doesn't support it. Every integration test requires a deploy to staging. This slows iteration more than you'd expect if you're used to fast local loops. **Vector dimensions are immutable.** Configure an index with 768 dimensions, decide to switch embedding models later — you rebuild the entire index from scratch. Pick your embedding model before you index anything. ### Who this is good for Cloudflare's RAG stack is the fastest path from idea to working product if you're building at small-to-medium scale, want minimal infrastructure overhead, and are already in the Cloudflare ecosystem. The binding model makes the stack feel native in a way that stitching together managed services doesn't. If you need complex metadata filtering, multi-tenancy, or billions of vectors, look elsewhere. But for a focused RAG product where you control the data model, this is hard to beat. --- ## Crawling GCC Government Documents: What Blocked Me URL: https://0xkaz.com/writing/crawling-gcc-government-docs/ Date: 2026-03-17 Personal analysis. Building GCC LexAI meant ingesting AI regulation documents from UAE and Saudi Arabia government websites. The tech stack worked fine. The websites did not always cooperate. ### Saudi .gov.sa blocks non-Saudi traffic entirely cst.gov.sa, cma.gov.sa, sdaia.gov.sa, and their subdomains return connection timeouts. Not 403s, not redirects — timeouts. Tried from Japan, Malaysia, and the US. Same result every time. The problem isn't the origin country; it's that Saudi government sites appear to block all non-Saudi IP ranges at the network level. Changing your crawler's location doesn't help. Proxies in GCC countries are the theoretical fix, but the practical one is to not depend on primary government URLs at all. **What worked:** Some agencies publish via CDN subdomains (cdn.nca.gov.sa), which resolve from outside Saudi Arabia. For agencies without CDN mirrors, documents hosted by OECD, law firms, and academic institutions — the same PDFs, just not from the primary .gov.sa domain. ### sca.gov.ae returns HTML where you expect a PDF The Securities and Commodities Authority's PDF URLs respond with Content-Type: text/html and serve a webpage. Not a redirect, not an error — a 200 response with HTML content at what looks like a PDF path. Detection fix: check the first four bytes of the response body for %PDF. If the content-type says PDF but the bytes don't, discard it and find another source. VARA (the virtual assets regulator) hosts its rulebooks on a CDN with clean, stable URLs — that became the fallback for SCA content. ### Lessons **Don't rely on official URLs as your primary source for government documents.** .gov domains optimize for human browsers, not automated access. CDN mirrors and secondary hosts are often more reliable for programmatic use. **Treat PDF availability as data you need to verify.** A URL that returns 200 isn't necessarily a PDF. A PDF URL that works today may return HTML tomorrow. Build verification into the ingestion pipeline, not as an afterthought. **Geo-blocking is a real constraint in the GCC.** UAE government sites were accessible. Saudi ones were not. Design your data sources with this asymmetry in mind if you're building anything cross-GCC. --- ## Sitemap - https://0xkaz.com/sitemap.xml ## Links - GitHub: https://github.com/0xkaz - LinkedIn: https://www.linkedin.com/in/masakazuohno/ - Email: hi@0xkaz.com - Site: https://0xkaz.com