<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Farchide on Medium]]></title>
        <description><![CDATA[Stories by Farchide on Medium]]></description>
        <link>https://medium.com/@farchide?source=rss-3571df7c598d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*0XLZOxykBlB65Nsv</url>
            <title>Stories by Farchide on Medium</title>
            <link>https://medium.com/@farchide?source=rss-3571df7c598d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 27 Nov 2026 21:23:05 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@farchide/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Shift-Left Was Designed for Human Typing Speed: Why Validation Must Move Inside the Agent’s Loop…]]></title>
            <link>https://medium.com/@farchide/shift-left-was-designed-for-human-typing-speed-why-validation-must-move-inside-the-agents-loop-49c48e5c88f4?source=rss-3571df7c598d------2</link>
            <guid isPermaLink="false">https://medium.com/p/49c48e5c88f4</guid>
            <category><![CDATA[ai-coding]]></category>
            <dc:creator><![CDATA[Farchide]]></dc:creator>
            <pubDate>Fri, 21 Aug 2026 16:00:05 GMT</pubDate>
            <atom:updated>2026-08-21T16:00:05.445Z</atom:updated>
            <content:encoded><![CDATA[<h3>Shift-Left Was Designed for Human Typing Speed: Why Validation Must Move Inside the Agent’s Loop (Shift Left Left)</h3><blockquote><strong>What is Shift Left Left?</strong></blockquote><p>For fifteen years, “shift-left” was the defining paradigm of secure software development. It took security and quality gates that historically lived in staging, pre-release pentests, or production incident response, and moved them into the CI/CD pipeline. SAST in the build, dependency scanning on the pull request, secrets detection on push — this was a massive, necessary advance.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2DCQ9Khwzg7SeEsip9BSFQ.png" /><figcaption>Shift Left Left, Validation on the Developer Machine</figcaption></figure><p>But shift-left rested on a foundational assumption: a human writes the code, and therefore, a pipeline checks it afterward.</p><p>That assumption is now obsolete. AI coding agents write the code, and the CI/CD pipeline has become the slowest component in the development loop. The instinct of most engineering organizations is to optimize the pipeline — parallelizing scanners, caching dependency graphs, shaving minutes off build times. This is a red herring. It solves a symptom while ignoring the disease.</p><p>The gap is no longer scan duration. The gap is that the validation gate still fires after the work is finished, and “finished” no longer means what it meant when a human was typing.</p><p><strong>The Collapse of the Pipeline Paradigm</strong></p><p>To understand why traditional pipelines are breaking, we have to look at throughput differentials. A coding agent can produce a working subsystem in the time it takes a human to read a Jira ticket. However, review capacity, CI concurrency, and AppSec headcount did not experience a corresponding 50x multiplier.</p><p>When one station on a production line runs orders of magnitude faster than the station after it, the standard result is a queue. In software engineering, this queue manifests as “approval theater.” Human reviewers begin rubber-stamping AI-authored diffs they did not write and cannot fully evaluate, simply because the alternative is becoming the bottleneck for the entire engineering organization. The pipeline hasn’t accelerated delivery; it has merely created a pressure valve that bypasses inspection.</p><p><strong>The Core Problem: Context Decay and Loop Latency</strong></p><p>The more insidious issue is not throughput, but context decay.</p><p>While an AI agent is mid-task, it holds a complete, high-fidelity picture of the work: the user’s intent, the broader file graph, the specific interfaces it just modified, and the reasoning behind why it chose a specific library. If you hand that agent a structural flaw at that exact moment, the correction is trivial. It edits the line it wrote thirty seconds ago and moves on.</p><p>Hand it the same finding forty minutes later — after the context window has been cleared, the task has been marked complete, and three subsequent tasks have altered the state of the codebase — and you have not reported a defect. You have created an entirely new task. A human or an agent must now reload the problem, reverse-engineer why the code is shaped the way it is, and attempt a fix without the generative reasoning that produced it.</p><p>In the AI era, the cost of a fix is not strictly a function of the severity of the defect; it is a function of how much context has been lost since the defect was introduced.</p><p>This leads to a conclusion that should reorganize how engineering leaders think about tooling investments: **feedback-loop latency now matters more than scanner accuracy.**</p><p>Consider the math: A validation check that is 95% accurate and returns in two seconds, inside the agent’s loop, prevents more defects from shipping than a check that is 99% accurate and returns after the agent has moved on. Why? Because the 95% check triggers an immediate, zero-cost fix. The 99% check triggers a context-reload task that may never actually be executed, or may be executed poorly. That trade-off would have been indefensible in 2015. It is the mathematically correct trade-off today.</p><p><strong>The Mirage of AI Self-Review</strong></p><p>Most teams adopting AI coding tools eventually attempt a seemingly obvious workaround: asking the model to check its own work via a secondary system prompt. This provides marginal improvement but is structurally incapable of solving the problem for two fundamental reasons.</p><p>First, the training cutoff is a hard epistemic boundary. A model only knows the vulnerabilities that existed before its training data was assembled. CVEs are published daily. If a dependency pulled in last week has a critical advisory filed nine days ago, the model will review the code and confidently declare it secure. It is not being careless; it physically lacks the mechanism to know otherwise. This is why live vulnerability feeds synced at runtime are not a premium feature — they are a baseline requirement for any tool touching AI-generated code.</p><p>Second, self-review is not independent review. When a model evaluates its own output, it applies the exact same priors, weights, and heuristics that generated the output. If a flawed assumption produced the code, that assumption remains resident when the model grades itself. You do not get a second opinion; you get the same opinion delivered with the false confidence of an independent audit. This is worse than no review at all, as it manufactures assurance.</p><p><strong>Defining “Shift-Left-Left”</strong></p><p>We need a new positional concept for validation. We call it **Shift-Left-Left**: validation that runs continuously while an AI coding agent writes, in the editor, on the developer’s machine, returning findings to the agent as structured input it can act on immediately, before the code is ever saved as a commit.</p><p>This is not a faster CI pipeline. It is not a pre-commit hook, which still fires on a completed, finalized artifact. It is a different position on the timeline: concurrent with generation rather than subsequent to it. The unit of work changed from “the developer wrote a function” to “the agent wrote a subsystem.” Validation must attach to the new unit.</p><p>In practice, the mechanics look like this:<br>1. A deterministic validation engine runs locally, observing the workspace via file watchers while the agent works.<br>2. When the agent generates code that fails a check — a tainted path to a sink, a dependency with a live advisory, a hardcoded credential — the finding is generated instantly.<br>3. The finding is returned to the agent as structured data (e.g., JSON), not to a human as a Jira ticket. The agent still holds the context. It corrects the code in place.<br>4. Clean code reaches the pull request.</p><p>The result is a restoration of the PR’s intended purpose: a design conversation, rather than a defect-triage queue. No context switch for the developer, no CI round-trip, no three-day-old finding arriving against code nobody remembers writing.</p><p><strong>A New Taxonomy of Defects</strong></p><p>Because agents write code differently than humans, a Shift-Left-Left engine cannot just wrap legacy SAST tools. It must evaluate across eight foundational pillars — Security, Compliance, Safety, Operational readiness, FinOps, Coherence, Teamwork, and Bias. Treating AI-generated code purely as a security problem is how teams end up with code that is not exploitable, but is also not correct, not affordable, and not coherent with the rest of the system.</p><p>More importantly, agents introduce entirely new categories of defects that conventional scanners were never built to look for:<br>- <strong>Prompt injection paths</strong> in agent-facing code.<br>- <strong>Agent-to-agent contract violations</strong> (e.g., Agent A expecting JSON, Agent B returning markdown, leading to silent system failures).<br>- <strong>Missing human-in-the-loop (HITL) checkpoints</strong> on privileged actions.<br>- <strong>Multi-agent deadlock conditions</strong>.<br>- <strong>Unbounded LLM cost in generated call paths. </strong>This last point often surprises teams until they receive their first invoice. An agent that writes an unchecked retry loop around a proprietary model call has not just written a bug; it has written a financial liability. No traditional SAST tool on the market classifies this as a finding.</p><p><strong>The Case for Local Execution</strong></p><p>For Shift-Left-Left to function, the validation engine must run locally on the developer’s machine. There are three non-negotiable reasons for this:</p><p>1. <strong>Latency</strong>: Physics dictates that a remote check cannot be truly “in the loop.” Round-tripping to a cloud service introduces variable latency, putting you right back in the position of validating a finished artifact.<br>2. <strong>Confidentiality</strong>: Source code never leaves the machine. There are no uploads, no telemetry, no shadow APIs. For enterprise procurement, this eliminates the single longest approval cycle. <br>3. <strong>Cost Determinism</strong>: The engine must rely on deterministic analysis (graph traversal, pattern matching, AST parsing), not model inference. There can be no token cost per scan and no per-seat inference bill that scales unpredictably with how much code your agents generate.</p><p><strong>Boundary Conditions: What Shift-Left-Left Is Not</strong></p><p>To maintain architectural clarity, we must define the hard boundaries of Shift-Left-Left. It is strictly static validation of generated code.</p><p>It does <strong>not</strong> tell you whether the agent you built will behave correctly once it has real tool access and real authority — that is <strong>behavioral validation</strong>, which must be done pre-production using mathematical methods and adversarial testing, rather than one model grading another.</p><p>It also does <strong>not</strong> tell you whether the application is exploitable in the specific environment you are about to release it into — that is <strong>deployment validation</strong>, executed against the pre-release build in a staging environment.</p><p>These are three distinct questions: <strong>Code, Behavior, and Deployment.</strong> Answering one does not answer the others, and vendors who imply otherwise are selling a partial picture wrapped in a whole-picture narrative.</p><p><strong>Where to Start</strong></p><p>The easiest way to validate this thesis is empirical. Pick one repository your team has been building with an AI coding assistant. Run a validator against it that checks live vulnerability data rather than relying on model memory. Filter the results specifically for anything with an advisory date after your model’s training cutoff.</p><p>That list is the definitive argument for why Shift-Left-Left is no longer optional.</p><p><em>(Note: For teams looking to test this immediately, </em><a href="https://gadriel.ai/code-security"><em>Gadriel AI Code Assurance</em></a><em> provides this full local engine free forever for individual developers — no trial, no credit card. It requires a simple `npm` install on Linux, macOS, or Windows, and takes roughly five minutes to generate a first fixed finding. Companies requiring centralized reporting, SSO, shared policy, and CI/CD enforcement can access team tiers.)</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49c48e5c88f4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Getting Your Database Out of Lovable Cloud: A Field Guide to Migrating to Your Own Supabase]]></title>
            <link>https://medium.com/@farchide/getting-your-database-out-of-lovable-cloud-a-field-guide-to-migrating-to-your-own-supabase-c7408427e209?source=rss-3571df7c598d------2</link>
            <guid isPermaLink="false">https://medium.com/p/c7408427e209</guid>
            <category><![CDATA[supabase]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[lovable]]></category>
            <dc:creator><![CDATA[Farchide]]></dc:creator>
            <pubDate>Tue, 04 Aug 2026 01:49:46 GMT</pubDate>
            <atom:updated>2026-08-04T01:49:46.125Z</atom:updated>
            <content:encoded><![CDATA[<h3>Why we were doing this at all</h3><p>We were brought in to work with a company that wanted to use <strong>Gadriel AI</strong> to run behavioral validation on their AI agents — to prove, before shipping, that what their agents <em>do</em> matches what they’re supposed to do. Gadriel’s AI Behavioral Assurance validates agent behavior in pre-production: same input, same output, measured mathematically rather than judged by another model. That was the goal.</p><p>Their product had been built up over the last couple of years entirely inside Lovable, backed by <strong>Lovable Cloud</strong> — Lovable’s managed backend, which is Supabase under the hood but owned and operated by Lovable on your behalf. And that is exactly where we hit the first wall.</p><p>You cannot validate what you cannot reach. Behavioral validation needs direct, programmatic access to the system: the database, the auth model, the functions, the data the agents read and write. Lovable Cloud does not give you that. There is no direct API connection to a Lovable Cloud database, no connection string you control, no SQL editor, no service-role key in your own account. The backend is real Supabase, but it lives behind Lovable’s management plane, not yours.</p><p>So the first step of the engagement wasn’t validation at all. It was extraction. <strong>Before we could assure the agents’ behavior, we had to move the database out of Lovable Cloud and into a Supabase project the company actually owned.</strong> This post is the field guide to doing that — starting from the high-level shape of the problem and getting progressively, painfully specific, because the specifics are where this goes wrong.</p><p>Everything below is drawn from a real migration of a mature, two-year-old application: ~1,128 tables, ~2,700 RLS policies, ~720 database functions, 106 cron jobs, 1,600+ users, thousands of storage objects, and a live user base. If your project is a weekend prototype, most of this won’t bite you. If it’s a real product, all of it will.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BOQAOvgmJupLqcvjfamg2Q.png" /></figure><h3>Part 1 — The high-level picture</h3><h3>What “Lovable Cloud” actually is</h3><p>Lovable Cloud is a Supabase project that Lovable provisions and manages inside their own organization. You get the capabilities of Supabase — Postgres, Auth, Storage, Edge Functions, RLS — without ever touching a Supabase dashboard. Lovable runs the migrations, deploys the functions, and holds the keys.</p><p>That is a genuinely good deal while you’re building. It’s also the reason leaving is a <em>re-platform</em>, not a toggle. The thing you want to take with you lives in an account you don’t control.</p><h3>The one sentence that governs the whole migration</h3><p><strong>A Lovable Cloud project cannot be transferred to your own Supabase account automatically. You recreate the schema, move the data, and re-point the app — manually.</strong> Supabase and Lovable both say this plainly. As of mid-2026 Lovable added official <em>Export</em>, <em>Pause</em>, and <em>Remove</em> controls (Cloud → Advanced settings), which give you a real pg_dump-based export as the input to the move — but the export is where the easy part ends, not where the work does.</p><h3>The four things you’re actually moving</h3><p>People think “migrate the database” and picture copying rows. There are four distinct payloads, and they fail in four different ways:</p><ol><li><strong>Schema</strong> — tables, views, functions, triggers, RLS policies, grants, sequences, extensions. This is the skeleton. A data-only load assumes it already exists on the target.</li><li><strong>Data</strong> — the rows. Large, slow, and the part everyone plans for.</li><li><strong>Auth</strong> — users, identities, password hashes, MFA factors. Lives in the auth schema, has its own rules, and is the part that silently corrupts if you&#39;re careless.</li><li><strong>Everything Postgres doesn’t carry</strong> — Edge Functions, their secrets, storage objects, cron schedules, and — critically — <em>any platform-side configuration that was set at deploy time and never lived in your repo or your database.</em></li></ol><p>That fourth category is the one that ends careers. Hold onto it; it’s the theme of this entire post.</p><h3>The mental model that keeps you honest</h3><p>The single most useful frame we used: <strong>a data-only load carries values, not configuration.</strong> Anything that was a <em>setting</em> rather than a <em>row</em> — a function’s deploy-time flag, an SMTP sender, a project-level secret, a JWT-verification toggle — does not travel in a dump. It was configured against the Lovable-managed project, and it stays there. On the new project, every one of those settings reverts to its default, and the default is usually “off” or “empty” in a way that fails <em>silently, later, when something finally runs.</em></p><p>If you take one thing from this post: <strong>the migration doesn’t fail loudly at copy time. It fails quietly, days later, on the first execution of something that depended on a setting the dump couldn’t see.</strong> Your entire verification strategy has to be built around finding those before your users do.</p><h3>Part 2 — The strategy, before any commands</h3><h3>Rehearse, then freeze, then cut</h3><p>The shape that worked:</p><ul><li><strong>Rehearse.</strong> Do a full dry run into a throwaway target. Time the copy, the restore, the index builds. You need real numbers, measured against your <em>largest</em> tables, not a sample — a sample-based estimate is a guess wearing a number.</li><li><strong>Decide your consistency boundary.</strong> You have two choices for a live app: copy while live and reconcile a delta at the end, or freeze writes <em>before</em> the bulk copy and take one longer downtime window. We chose <strong>freeze-first</strong>, and you probably should too — see below for why the delta approach is a trap on a mature schema.</li><li><strong>Freeze, copy, verify, cut over, verify again, then reopen.</strong> The reversible point is the freeze. Everything before writes reopen on the new backend is recoverable; everything after is not.</li></ul><h3>Why we killed the “delta reload” idea</h3><p>The tempting plan is: copy everything while the app is live, then at cutover just re-copy “what changed.” It does not work on a real schema, for two reasons that are worth internalizing:</p><ul><li><strong>You can’t find the changed rows.</strong> In our case, roughly half the tables had no updated_at column. A timestamp scan can&#39;t detect a change it has no column to detect.</li><li><strong>You can’t find the deleted rows at all.</strong> Nothing tracks deletes. A delta pass adds and updates; it cannot remove a row that was deleted on the source after your copy. Those phantoms survive into production.</li></ul><p>A per-table <em>row-count</em> check won’t save you either — it catches neither an in-place update nor an equal-count churn. So “the counts match, we’re good” is a weaker statement than it sounds.</p><p>The honest fix is to <strong>freeze writes before the bulk copy</strong>, so there is no delta to reconcile. It costs a longer maintenance window. It buys correctness you can actually prove.</p><h3>Pick your region deliberately (and before you create anything)</h3><p>The move is to a brand-new project, so it’s also your one free chance to change region. A live Supabase project can’t change region in place — but since you’re migrating anyway, choosing a different region costs nothing extra <em>operationally</em>.</p><p>It can cost you a great deal <em>legally</em>. If you’re moving EU users’ personal data onto US infrastructure, that changes your data-residency posture: you likely need a transfer basis (Standard Contractual Clauses), and your privacy policy probably names a region today. This is special-category-data territory if you hold anything sensitive. <strong>Decide residency in writing before you create the target project</strong> — it’s far cheaper to pick the region correctly once than to migrate twice. Treat it as a gate, not a note. And be aware it has exactly two clean answers: everything in one region, or everything in another. “Some tables here, some there” is a different architecture, not a region toggle.</p><h3>Part 3 — The migration, phase by phase</h3><p>Here’s the sequence that survived contact with reality. Each phase has a verification gate; you do not advance until the gate is green <em>for the right reason.</em></p><h3>Phase 0 — Preparation (no downtime)</h3><ul><li>Create the target Supabase project in the <strong>confirmed</strong> region. Size it with a compute add-on, not base tier — a thousand-plus tables with pg_cron, pg_net, and pgvector will make an undersized instance produce a misleadingly slow dry run.</li><li>Store the target’s Postgres connection string, project URL, and <strong>service-role key</strong> as secrets.</li><li>Run the full dry run. Measure the copy, the constraint validation, and the vector-index builds against your largest real tables.</li></ul><h3>Phase 1 — Schema, and move storage live</h3><ul><li>Take the export (Cloud → Advanced settings → Export data).</li><li>Load the schema in dependency order: extensions, tables, functions, triggers, RLS policies, grants. <strong>Do not build vector indexes yet</strong> — building them before the data lands means re-indexing on every insert, which is catastrophically slow.</li><li><strong>Move storage now, while the app is still live.</strong> Storage objects are append-mostly and addressed by path, so a live copy is safe, and it pulls the single largest variable-time item out of your downtime window. What remains for the window is a small diff, not a full transfer. (Diff by hash/etag, not by count — a file <em>replaced in place</em> has the same path and possibly the same size; only a content hash catches it.)</li><li><strong>Gate:</strong> don’t settle for a column-level diff. Diff the <em>bodies</em> — all RLS policy predicates, all grants, function-body hashes. A column diff proves nothing about whether a policy’s USING clause survived.</li></ul><h3>Phase 2 — Freeze, then load data and auth</h3><ul><li>Put the app in maintenance. Writes stop. Everything after this is inside the window.</li><li>Load public data with session_replication_role = replica so FK triggers don&#39;t fire mid-load and ordering stops mattering.</li><li><strong>Load auth from the same source snapshot as public</strong>, in the same transaction. This is the one that silently corrupts users — details in Part 4.</li><li>Because nothing was enforced during the load, run an <strong>explicit orphan pass</strong>: for each foreign key, a LEFT JOIN ... WHERE parent IS NULL. This answers the integrity question without the lock cost of re-validating every constraint. Reserve the heavier NOT VALID + VALIDATE CONSTRAINT for FKs where the join actually finds an orphan.</li><li>Reset sequences (against the real owning column via pg_get_serial_sequence(); copy last_value directly for any standalone sequence). <em>Then</em> build vector indexes.</li></ul><h3>Phase 3 — Storage catch-up (short)</h3><ul><li>Re-manifest the source, diff against the target by hash, transfer only what changed since the Phase 1 live copy. One ledger row per file with a status, so a timeout is resumable and you always know the exact remaining set.</li></ul><h3>Phase 4 — Functions, secrets, schedules</h3><ul><li>Deploy Edge Functions to the target. Triage them by <strong>reference, not by config</strong>: a function absent from config.toml may still be called by a cron job, a webhook, or client code. Grep the entire surviving surface for every function name; anything referenced anywhere is live and ships. &quot;Not in config&quot; is not &quot;dead.&quot;</li><li>Re-enter every secret. <strong>This is not optional and it is not carried by any dump.</strong> Stripe keys, the webhook signing secret, email-provider keys, and any Vault secrets — Vault ciphertext is encrypted with a project-specific key and is unreadable on the new project, so those come across as plaintext re-entry, not a copy.</li><li>Recreate cron jobs — <strong>with their URLs rewritten.</strong> In our migration, 87 of 108 cron jobs had the old project reference baked into the URL they call. Left alone, every one would have kept calling the dead backend. Grep every job body for the old project ref and confirm zero before you trust them.</li></ul><h3>Phase 5 — Cutover and verification</h3><ul><li>Re-point the app: the client/env values, plus any hard-coded references the framework won’t rewrite for you (more on this in Part 4 — the auth storage key is a landmine).</li><li>Move the Stripe webhook endpoint and signing secret <strong>before</strong> traffic resumes.</li><li>Verify as a <strong>real signed-in user under RLS</strong>, never as service-role. The whole point of preserving user IDs and RLS policies is that a user sees their own rows and <em>only</em> their own. Prove it: sign in, read, confirm zero foreign rows. Send a <em>signed</em> payment webhook and assert the database side-effect actually lands — a “returns 400 on unsigned request” check proves the function booted, not that the signing secret is correct.</li><li>Only then bring the maintenance gate down. Only then unpause crons — in waves, watching between each.</li></ul><h3>Part 4 — The traps that actually cost us time</h3><p>Everything above is the plan. This is what the plan doesn’t tell you, learned the hard way. If you skim one section, skim this one.</p><h3>Trap 1: The restore that reports success while destroying most of your data</h3><p>The standard pg_restore --disable-triggers path emits ALTER TABLE ... DISABLE TRIGGER ALL, which needs superuser to touch Postgres&#39;s internal referential-integrity triggers. <strong>On Supabase, </strong><strong>postgres is not superuser.</strong> So on a data-only load, every foreign-key-bearing table&#39;s rows get <em>refused</em> — and depending on how you&#39;re counting errors, the tool cheerfully reports a near-clean run.</p><p>In our migration this presented as <strong>“2 failures” on a run that had actually rejected 1,884 statements and left 183 tables completely empty — 62% of all rows gone.</strong> The restore’s own failure counter counted only the two tables named in its summary, not the eighteen hundred per-statement rejections underneath.</p><p>Two lessons, both permanent:</p><ul><li><strong>Load with </strong><strong>SET session_replication_role = replica held across one piped </strong><strong>psql session</strong> — the supported equivalent that doesn&#39;t need superuser. Not --disable-triggers.</li><li><strong>Never trust a tool’s self-reported success. Verify row counts per table against the source.</strong> The only reason we caught the 62% loss is that parity was checked against source counts, not against the restore’s green checkmark. This single discipline is the difference between a clean migration and a catastrophe that ships.</li></ul><h3>Trap 2: Auth corruption that reconciles to a matching count</h3><p>The naive auth migration is INSERT ... ON CONFLICT (id) DO NOTHING into the target&#39;s auth.users. If the target already holds users from a rehearsal, this <strong>adds new users and silently keeps stale ones.</strong> Any user who changed their email or password, or was deleted, since the rehearsal is now <em>wrong</em> on the new backend — and the row count still reconciles, so nothing flags it.</p><p>The failure is invisible and it targets your <em>active</em> users specifically — the ones who did something recently are exactly the ones whose state changed. It surfaces days later as “some users can’t log in” or “a user sees someone else’s data,” with no failed check pointing at it.</p><p>The fix: <strong>delete and reload the auth tables clean, from the same source snapshot as your public data, in the same transaction.</strong> DO NOTHING is the worst possible conflict resolution here because it converts staleness into silence. And note that hashes <em>do</em> migrate — the export carries auth.users with encrypted_password — so a forced password reset for every user is usually avoidable. (But see Trap 8; you may end up resetting for a different reason.)</p><p>Also: copy auth.users, auth.identities, and auth.mfa_factors. <strong>Do not</strong> copy auth.sessions, auth.refresh_tokens, or auth.flow_state — those are keyed to the old project and you&#39;re invalidating all sessions at cutover anyway. Copying them just resurrects dead login attempts.</p><h3>Trap 3: The hard-coded project reference that signs everyone out</h3><p>Client SDKs often store the auth token under a key derived from the project ref — e.g. sb-&lt;projectref&gt;-auth-token. If that key is hard-coded in your app (we found it in a Capacitor storage config), then at cutover your client authenticates against the <em>new</em> backend while reading and writing the token under the <em>old</em> key. Every session breaks in a way a password reset can&#39;t fix.</p><p>Sweep the entire repo for the old project ref — not just .env and the generated client, but redirect URLs, function URLs, realtime channel names, and framework storage keys. Confirm zero occurrences before you cut over.</p><h3>Trap 4: Schema changes made after the rehearsal that a data-only load can’t carry</h3><p>Your rehearsal copies the schema at a point in time. Any schema change made <em>between</em> the rehearsal and cutover — a new function, an altered policy, a redefined view — is invisible to a data-only load, because a data load only carries rows.</p><p>We caught this with an <strong>md5 sweep of all ~720 function bodies, source vs. target</strong>, run <em>after</em> everything else was green. It found check_message_deliverable — the exact function that gates whether user-facing messages are safe to send — still carrying an old, permissive version, missing five resolvers added days earlier. Had we not swept, the first batch of user-facing jobs would have fired through a deliverability gate stuck in &quot;deliver anything&quot; mode.</p><p><strong>Before you call the migration done, diff the definitions of every logic object the live app invokes</strong> — function bodies, trigger functions, active RLS policies, column defaults, view bodies — source vs. target. The data-only load silently drops every logic change made in the rehearsal-to-cutover gap. One will have slipped through. There may be more.</p><h3>Trap 5: The deploy-time-configuration class (this is the big one)</h3><p>This is the theme of the whole post, made concrete. <strong>Any function that got its credentials or configuration from a deploy-time setting — a </strong><strong>verify_jwt flag, a </strong><strong>current_setting() GUC, a project-level secret — broke at cutover and fails only when it runs.</strong></p><p>We found this <em>five separate times</em>, each a different mechanism, each caught by a different sweep:</p><ul><li><strong>Five functions ran </strong><strong>verify_jwt = false on the source</strong> — a deploy-time setting never captured in config.toml. They redeployed with the default verify_jwt = true and started rejecting their own cron secret with 401s.</li><li><strong>Two user-facing send jobs built their auth header from </strong><strong>current_setting(&#39;app.settings.service_role_key&#39;)</strong> — which is NULL on the new project. Every run failed with a JSON syntax error. One of them was a weekly job that hadn&#39;t fired yet, so it hadn&#39;t announced itself.</li><li><strong>Two more</strong> — including a daily account-purge job — built a cron secret from the same NULL GUC and were silently dead since cutover.</li></ul><p>The dangerous members of this class are the <em>rare</em> ones: a monthly reconciler, a weekly sweep, a quarterly cleanup. They’re dead now and won’t fail visibly until their schedule arrives, unwatched.</p><p><strong>Find them by pattern, not by waiting.</strong> Grep every function body and every SQL-dispatched cron job for current_setting( used in credential construction, and for any auth-header construction that bypasses your central dispatch path. Enumerate the whole set so you have a <em>known denominator</em> — in our case: literal-key jobs, no-auth jobs, Vault-backed jobs, and the GUC-backed ones that broke. The class is closed when the count adds up, not when you stop finding things.</p><p>The root-cause sentence to write in your own runbook: <strong>deploy-time settings do not survive a data-only load.</strong> Everything in this trap is a corollary.</p><h3>Trap 6: Your tooling may be writing to the dead project and reporting success</h3><p>The worst hazard of the migration, and the least obvious. In our sandbox, the <strong>default database connection — bare </strong><strong>psql, the </strong><strong>PG* environment variables, and the migration tool itself — resolved to the old, dead source project.</strong> We applied a fix through the migration tool; it reported success; the target function body was unchanged. It had patched the corpse.</p><p>Once you find this, you cannot trust <em>any</em> prior “success” from that path. We had to audit every DDL change applied since cutover and re-read each object <em>from the target</em> to see where it actually landed. Several had gone to the dead source with a green checkmark.</p><p>Two permanent rules came out of this, and they outlive the migration:</p><ul><li><strong>Assume the default connection points at the source. Connect explicitly to the target by name for every write, and read the object back from the target to confirm it landed.</strong> A reported success against an unverified connection is worthless.</li><li><strong>Verifications carry the same burden as writes.</strong> If you run “is it fixed?” against the wrong project, you’ll see a fix you accidentally applied there earlier and believe a live problem is closed.</li></ul><h3>Trap 7: Lovable regenerates your backend binding — permanently</h3><p>Even after cutover, <strong>Lovable Cloud regenerates </strong><strong>.env and the generated client file back toward the old project ref.</strong> This is not a one-time cleanup; it&#39;s a standing property of running on a Lovable-managed binding. We watched .env revert to the dead ref inside a two-minute window, more than once.</p><p>The durable fix is to <strong>stop reading the mutable file for the backend ref at build time.</strong> We pinned the three client values via define in vite.config.ts — which Lovable does <em>not</em> regenerate — so Vite&#39;s build-time constant wins over whatever .env currently says. We proved it hostilely: poisoned .env with the dead ref, bypassed the guard, ran the build, and confirmed the shipped bundle still contained only the live ref.</p><p>As belt-and-braces, wire an assertion into the build itself that fails the build on a dead ref, and verify the <em>shipped bundle</em> — grep the actual deployed chunk for the live ref and confirm zero occurrences of the old one. Not .env, not the preview: the bundle real users download. And verify the binding <em>at runtime</em> — force one real auth call from production and confirm the request goes to the live backend, not the corpse. Config reading correct is not the same as the running app doing the right thing.</p><h3>Trap 8: The email sender the migration silently didn’t bring</h3><p>Right before sending password-reset comms to the whole user base, we checked the auth mailer on the new project. It was on Supabase’s <strong>built-in testing sender: 2 emails per hour.</strong> The custom SMTP sender (Resend) the source had was never migrated — smtp_host was null, the auth hooks were disabled, the API key was present in the environment but not <em>wired</em> to the auth mailer. Every signup, recovery, and confirmation email on production was already rate-limited to a trickle, and a blast to 1,600+ users would have drained at 2/hour — over a month — while silently failing for real users the whole time.</p><p>This is Trap 5 wearing a different hat: <strong>email sender configuration is platform-side and doesn’t travel in a dump.</strong> Same for anything else configured in the Supabase dashboard rather than stored as data or code — auth providers, redirect URLs, email templates, rate limits.</p><p>The fix is real work, not a toggle: wire the SMTP sender, raise the rate limit to match your recipient count (raising the limit does nothing without an active sender behind it), and <strong>prove a real email lands in a real inbox</strong> — not that the config reads correct. Use an <em>invite</em> to an address with no account rather than a <em>recovery</em> on one that doesn’t exist, because /recover on a missing account returns 200 and sends nothing: the exact false-green this whole migration teaches you to distrust. And check the spam folder — a fresh sender subdomain lands in junk until SPF/DKIM/DMARC are set, and a reset email in everyone&#39;s spam is a failed launch that looks like a successful one.</p><h3>Part 5 — The discipline that made it work</h3><p>Strip away the specifics and the whole migration reduces to one operating principle:</p><p><strong>Never trust a green. Verify the surface, not the report.</strong></p><p>Every single thing that would have broken this launch was caught the same way — by checking the actual artifact instead of believing a success message:</p><ul><li>The restore that ate 62% of the rows reported “2 failures.” <em>Row counts against source caught it.</em></li><li>The failure parser said “2” on 1,884 rejections. <em>Reading the raw log caught it.</em></li><li>The migration tool wrote fixes to the dead project and reported success. <em>Reading the object back from the target caught it.</em></li><li>The deliverability gate errored on a phantom table name. <em>A forced test, not the passing cron, caught it.</em></li><li>The purge job was about to fire into a broken erasure path. <em>Reading its </em><em>active state instead of assuming caught it.</em></li><li>The maintenance page was still up in production while every report said “gate down.” <em>Loading the real URL caught it.</em></li><li>The reset email would have gone out through a mailer that couldn’t send. <em>Checking the sender before the blast caught it.</em></li></ul><p>None of those was luck. Each was a deliberate refusal to accept a claim in place of evidence. On a weekend prototype you can skip all of it. On a real product with real users, this discipline <em>is</em> the migration — the copying is the easy 20%.</p><h3>The checklist, distilled</h3><ol><li><strong>Rehearse and measure</strong> against your largest tables, not a sample.</li><li><strong>Freeze before the bulk copy.</strong> Don’t try to reconcile a delta on a schema without reliable updated_at and no delete tracking.</li><li><strong>Decide residency in writing before creating the target.</strong></li><li><strong>Load data via </strong><strong>session_replication_role = replica, not </strong><strong>--disable-triggers</strong> — and verify row counts per table against source.</li><li><strong>Reload auth clean</strong> from the same snapshot, in the same transaction. Never ON CONFLICT DO NOTHING.</li><li><strong>Sweep for the deploy-time-config class</strong> — current_setting(), verify_jwt, project secrets — and close it to a known denominator.</li><li><strong>Diff every logic object’s definition</strong> (functions, policies, triggers, defaults, views) source vs. target, after everything else is green.</li><li><strong>Rewrite cron URLs</strong> and grep for the old project ref everywhere — jobs, function bodies, client code.</li><li><strong>Re-enter every secret and Vault value</strong> by hand; none of it is in the dump.</li><li><strong>Pin the backend ref at build time</strong> so Lovable’s regeneration can’t reship the dead project. Verify the shipped bundle and a runtime call.</li><li><strong>Wire and prove the email sender</strong> — real email, real inbox, not config.</li><li><strong>Assume your tooling points at the dead project</strong> until the connection names the target and you’ve read the result back.</li><li><strong>Verify as a real user under RLS</strong> — own rows only, zero foreign rows.</li><li><strong>Cut over behind a maintenance gate; unpause crons in waves; keep the old project as a frozen forensic reference,</strong> not a rollback target — once traffic resumes on the new backend, rolling back means losing everything written since.</li></ol><h3>Coda: why the extraction was step one</h3><p>We came in to do behavioral validation with Gadriel. We couldn’t start until the company owned its own backend, because you cannot assure a system you can’t reach through an API you control. Getting the database out of Lovable Cloud wasn’t a detour from the validation work — it was the precondition for it.</p><p>And the migration itself turned out to be a validation exercise in miniature: at every step, the question was the same one Gadriel asks of an AI system before it ships — <em>does the thing actually do what the green checkmark claims?</em> The restore claimed success and had destroyed most of the data. The tool claimed it applied the fix and had patched a dead project. The config claimed the mailer worked and it couldn’t send an email. The discipline that gets a database safely out of Lovable Cloud is the same discipline that keeps an AI agent honest in production: <strong>validate behavior against evidence, not against the report the system gives you about itself.</strong></p><p>Own your backend. Then prove it works. In that order.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c7408427e209" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[We Ran Gadriel AI Code Assurance Across 50 Real Repos and 50 Agent Skills. Zero False Positives.]]></title>
            <link>https://medium.com/@farchide/we-ran-gadriel-ai-code-assurance-across-50-real-repos-and-50-agent-skills-zero-false-positives-b559c05ab2ec?source=rss-3571df7c598d------2</link>
            <guid isPermaLink="false">https://medium.com/p/b559c05ab2ec</guid>
            <category><![CDATA[claude-code]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[ai-agent]]></category>
            <dc:creator><![CDATA[Farchide]]></dc:creator>
            <pubDate>Mon, 27 Jul 2026 23:06:06 GMT</pubDate>
            <atom:updated>2026-07-27T23:06:06.794Z</atom:updated>
            <content:encoded><![CDATA[<p><em>A field report on what AI Code Assurance looks like under real load — 10 languages, a new agentic-skills pillar, and reproducible results you can audit.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8ueXW9aLqFk3UtQtf4Gdgg.png" /><figcaption>Gadriel Code Assurance (GCA)</figcaption></figure><p>Gadriel is the AI System Assurance platform. We validate what AI writes — <strong>AI Code Assurance (GCA)</strong> — and what AI does — <strong>AI Behavior Assurance (GBA)</strong> — across eight pillars: Security, Compliance, Safety, Operational, FinOps, Coherence, Teamwork, and Bias. Both are pre-production validation, and both are built to hold up on real, messy, large-scale code, not curated demos.</p><p>So we put GCA to the test. We built the CLI fresh, added a brand-new pillar for validating agentic <em>skills</em> — the packaged instructions that let AI coding agents extend themselves — and pointed it at a hundred real targets at once.</p><p>Here’s what it did.</p><h3>The setup</h3><p>We ran the scanner, unmodified, against:</p><ul><li><strong>50 real open-source repositories</strong> across 10 languages — Python, JavaScript, TypeScript, Go, Rust, Java, C, C++, Ruby, and PHP. Express, Redis, ripgrep, Zod, okhttp, Sinatra, and dozens more — active, non-trivial codebases.</li><li><strong>50 agentic skill packages</strong> — 30 benign helpers, and 20 inert derivatives of published attack classes (command-and-control loaders, dependency confusion, YAML execution, typosquatting, zero-width Unicode smuggling, and more), all de-fanged so nothing could execute.</li></ul><p>Every repo ran the full pipeline in a single package: static analysis (SAST), software composition analysis (SCA), secrets detection, misconfiguration checks, container and infrastructure-as-code scanning, and — new this cycle — the agentic-skills pillar. One tool, replacing what an enterprise usually stitches together from six.</p><h3>Result 1: it doesn’t lie</h3><p>Across all 100 targets, GCA produced <strong>zero false positives on benign code.</strong></p><p>That’s the number that matters most. A validation platform that flags clean code as dangerous burns developer trust in a week — and one that calls dangerous code clean is worse. We measured stability and precision separately, on purpose, because a tool you can’t trust to be <em>right</em> is a tool nobody keeps running.</p><p><strong>Findings surfaced: 205, across all 10 languages.</strong> Every language produced real, actionable security signal — from a handful in tightly-scoped Rust and C++ libraries to double digits in larger Java and JavaScript trees.</p><h3>Result 2: the new skills pillar held its precision gate</h3><p>Agentic skills are the newest surface in the AI development pipeline, and almost nobody is validating them. A skill package is just code with a friendlier name — and code with a friendlier name is exactly where attackers look first.</p><p>Across all 50 skill packages, GCA emitted <strong>zero false positives on the 30 benign skills</strong> — including skills whose written descriptions <em>talk about</em> attacks, which is the hardest precision case there is. The scanner validated the behavior, not the prose.</p><p>On the malicious derivatives, it correctly caught the classes that matter: C2 callbacks, staged loaders, dependency-confusion installs, prototype pollution, typosquatting, YAML-exec payloads, zero-width smuggling, and identity-clone patterns. Same input, same output, every time.</p><h3>Result 3: reproducible, not a vibe check</h3><p>This is the part that separates AI Code Assurance from “we used an LLM to grade the code.” Every result in this run is deterministic. Run it again, get the same answer. That’s what makes the output audit-defensible — evidence a security or governance team can actually stand behind, not a probabilistic opinion that changes on the next pass.</p><p>Runs local, too: code scans execute on the developer’s own machine. No source upload. No telemetry. No token cost, no latency — the scan happens while the code is being written, before it ever reaches review, CI, or a security gate three sprints behind.</p><h3>Why this matters now</h3><p>Every AI coding assistant on the market can now write — and install — code faster than any human review process can keep up with. That’s the entire premise behind AI Code Assurance: validate what AI writes <em>while it’s being written</em>, across all eight pillars, before it becomes someone’s incident.</p><p>Ten languages. A hundred targets. A brand-new attack surface. Zero false positives, and results you can reproduce line for line. That’s what pre-production validation is supposed to look like — and it’s what GCA delivers on real code, at real scale.</p><p><strong>Gadriel is the AI System Assurance platform: AI Code Assurance (GCA) validates what AI writes, and AI Behavior Assurance (GBA) validates what AI runs — both pre-production, across the same eight pillars.</strong></p><p>GCA runs locally, inside your coding tools, with no source upload and no telemetry — and individual developers can start for <strong>one month free</strong>.</p><p>→ <a href="https://gadriel.ai/code-security">See how AI Code Assurance works</a> → <a href="https://gadriel.ai/docs">Read the docs</a> → <a href="https://app.gadriel.ai/developers/">Start your free month</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b559c05ab2ec" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>