diff --git a/packages/sdk/src/engine/apply-patches.scriptTargets.test.ts b/packages/sdk/src/engine/apply-patches.scriptTargets.test.ts
new file mode 100644
index 0000000000..01cec7ef0a
--- /dev/null
+++ b/packages/sdk/src/engine/apply-patches.scriptTargets.test.ts
@@ -0,0 +1,71 @@
+import { describe, expect, it } from "vitest";
+import { parseMutable } from "./model.js";
+import { applyOverrideSet, applyPatchesToDocument } from "./apply-patches.js";
+import { serializeDocument } from "./serialize.js";
+import { openComposition } from "../session.js";
+
+// The failing shape: the script dereferences the lookup unguarded, so a removed node throws.
+const HTML = `
+
+
+`;
+
+describe("a stored delete a script looks up", () => {
+ it("leaves the live document, and serializes back hidden", () => {
+ const parsed = parseMutable(HTML);
+ applyOverrideSet(parsed, { "hf-arch": null });
+ expect(parsed.document.getElementById("arch-path")).toBeNull();
+ const out = serializeDocument(parsed);
+ expect(out).toContain('id="arch-path"');
+ expect(out).toContain("display: none");
+ expect(parsed.document.getElementById("arch-path")).toBeNull();
+ });
+
+ it("is no longer a clip once serialized, so its media is not mixed", () => {
+ const parsed = parseMutable(HTML);
+ applyOverrideSet(parsed, { "hf-aud": null });
+ const out = serializeDocument(parsed);
+ expect(out).toContain('id="narration"');
+ expect(out).not.toMatch(/id="narration"[^>]*data-start|data-start[^>]*id="narration"/);
+ expect(out).not.toContain('data-duration="9"');
+ // The audio mixer and the runtime skip [data-hidden]; display:none alone would still play the track.
+ expect(out).toMatch(/