From b3318d6bed723ab66b0de746ec7f5ba49bc13a60 Mon Sep 17 00:00:00 2001 From: Dotta Date: Mon, 5 Oct 2026 20:21:34 -0500 Subject: [PATCH] fix(e2e): preserve existing directory watch coverage and exact memory prompt --- .../2026-10-02-pi-production-readiness.md | 21 +++++++++++ tests/runner-e2e/README.md | 7 ++++ tests/runner-e2e/catalog.ts | 2 +- tests/runner-e2e/pi-controls-evidence.test.ts | 4 +-- tests/runner-e2e/pi-native-cases.test.ts | 13 ++++++- tests/runner-e2e/pi-native-cases.ts | 2 +- .../runner-e2e/remote-native-fixtures.test.ts | 36 ++++++++++++++++--- tests/runner-e2e/remote-native-fixtures.ts | 6 +++- 8 files changed, 81 insertions(+), 10 deletions(-) diff --git a/doc/plans/2026-10-02-pi-production-readiness.md b/doc/plans/2026-10-02-pi-production-readiness.md index 024f7023a5e..aeb0a9fcbe2 100644 --- a/doc/plans/2026-10-02-pi-production-readiness.md +++ b/doc/plans/2026-10-02-pi-production-readiness.md @@ -15,6 +15,27 @@ failures remain retained. The Mac file-edit correction also passes. ### Latest boundary fixes — 2026-10-05 +The next fixture correction preserves the same `f5024863e` shipping inputs. +The observer now accepts a directory notification only for the same device/inode +with an already registered recursive watch; every event still counts. An actual +generated-observer regression fails before the correction and passes afterward, +including nested transient writes. New directories, replacement inodes, symlinks, +unknown notifications, and recycled process identities remain failures. +This reproduces a fixture defect, but does not identify the missing original +restart terminal snapshot's exact cause. A corrected live result is still needed. + +Pi native definition v13 removes the competing bare nonce from the memory +instructions. Its sole JSON content specification still decodes to 33 bytes with +one final LF. Frozen native parser/validator/write/read preserve those bytes +without provider calls. The failed run's native input contained 33 bytes while +its native read returned 32; original managed content was not captured. No byte +conversion was found in the wrapper or public file API. The prompt correction +addresses a copying ambiguity; it does not establish a product byte-loss cause. +The missing-LF negative control and exact saved/readback assertions stay in place. +All 207 focused fixture regressions and the harness typecheck pass. One unrelated +Copilot bootstrap prompt assertion remains a preserved failure in the broader +support run. The affected live cases remain pending until their new receipts close. + Current shipping artifacts are bound to `f5024863e9ed014e2661e6d7f23fc0e6b32e0911` and profile 15. The normal public ARM graph verifies 722 packages and 79,373 files with zero mismatches. Full build and recursive typecheck pass. Normal diff --git a/tests/runner-e2e/README.md b/tests/runner-e2e/README.md index 5f318966d40..87e387e7c4f 100644 --- a/tests/runner-e2e/README.md +++ b/tests/runner-e2e/README.md @@ -1595,6 +1595,13 @@ as unverified metadata; the remote process is bound through the exact sandbox, run ID, lifecycle, process group and executable digest. Same-UID observer isolation is not an adversarial operating-system sandbox test. +Directory notifications remain counted. A notification for an existing directory +preserves completeness only when its device/inode still match an already +registered recursive watch. Newly created directories, replacements, symlinks, +and unknown notifications remain incomplete. Pi native definition v13 also gives +memory content a single JSON representation, including the required final LF; +the exact managed bytes and fresh-task readback assertions remain unchanged. + `--suite rich-acp-warm-continuity` adds six explicit cells: all three providers on local and Daytona. Three browser-driven turns must preserve native session, provider session, runner instance, PID/start identity and project workspace. diff --git a/tests/runner-e2e/catalog.ts b/tests/runner-e2e/catalog.ts index 0006c46833d..fd57d701f0c 100644 --- a/tests/runner-e2e/catalog.ts +++ b/tests/runner-e2e/catalog.ts @@ -1114,7 +1114,7 @@ export const runnerSuites: readonly RunnerSuiteFixture[] = [ groups: ["native"], profiles: extendedHarnessProfiles.filter(profile => profile.qualificationCandidate === "pi"), environments: runnerEnvironments, tasks: piNativeTasks, expectedMatrixSize: 10, excludedExecutionIds: ["pi-native.runner-acpx-pi.daytona.restrictive-denial", "pi-native.runner-acpx-pi.local.native-pending-provider-death"], - definitionMetadata: { version: 12, qualification: "pending", scheduling: "explicit-only", profileVersion: QUALIFIED_ACPX_PROFILES.pi.agentProfileVersion, agentMemoryContent: "utf8-nonce-plus-final-lf", agentMemoryPrompt: "ordered-memory-adjacent-internal-qualifier-and-fenced-content", taskPromptTransport: "fenced-markdown-paste-and-multiline-literal-escapes", nativeFinish: "current-contract-objective-evidence-refs", providerDeath: "daytona-exact-pi-child-pidfd-production-expiry", providerFaultExecutable: "stable-preinstalled-runner-link-and-snapshot-node-inode-with-held-bootstrap-fd-3-or-7", remoteBootstrapApproval: "exact-published-native-read-public-accept-once-v1", remoteDenyAll: "unsupported-native-bootstrap-read-is-denied", remoteEvidence: "owned-lease-sealed-observer", pendingControllerRestart: "same-live-native-request-trusted-ancestry-cleanup" }, + definitionMetadata: { version: 13, qualification: "pending", scheduling: "explicit-only", profileVersion: QUALIFIED_ACPX_PROFILES.pi.agentProfileVersion, agentMemoryContent: "utf8-nonce-plus-final-lf", agentMemoryPrompt: "ordered-memory-single-json-content-including-final-lf", taskPromptTransport: "fenced-markdown-paste-and-multiline-literal-escapes", nativeFinish: "current-contract-objective-evidence-refs", providerDeath: "daytona-exact-pi-child-pidfd-production-expiry", providerFaultExecutable: "stable-preinstalled-runner-link-and-snapshot-node-inode-with-held-bootstrap-fd-3-or-7", remoteBootstrapApproval: "exact-published-native-read-public-accept-once-v1", remoteDenyAll: "unsupported-native-bootstrap-read-is-denied", remoteEvidence: "owned-lease-sealed-observer", pendingControllerRestart: "same-live-native-request-trusted-ancestry-cleanup" }, }, { id: "native-active-stop", label: "Stop an unanswered native permission", manualOnly: true, diff --git a/tests/runner-e2e/pi-controls-evidence.test.ts b/tests/runner-e2e/pi-controls-evidence.test.ts index e2892b85d19..aaf04f0495c 100644 --- a/tests/runner-e2e/pi-controls-evidence.test.ts +++ b/tests/runner-e2e/pi-controls-evidence.test.ts @@ -189,7 +189,7 @@ describe("Pi controls catalog admission", () => { // Extended v3 states the strict file oracle's task-wide Bash limit. const pi = runnerMatrix.find(c => c.profile.qualificationCandidate === "pi")!.profile; expect(pi.modelQualification?.qualificationId).toBe("pi:0.0.33:1.0.0:openrouter"); - expect(runnerSuites.find(s => s.id === "pi-native")!.definitionMetadata).toMatchObject({ version: 12, profileVersion: 15, agentMemoryContent: "utf8-nonce-plus-final-lf", agentMemoryPrompt: "ordered-memory-adjacent-internal-qualifier-and-fenced-content", taskPromptTransport: "fenced-markdown-paste-and-multiline-literal-escapes", nativeFinish: "current-contract-objective-evidence-refs", providerFaultExecutable: "stable-preinstalled-runner-link-and-snapshot-node-inode-with-held-bootstrap-fd-3-or-7" }); + expect(runnerSuites.find(s => s.id === "pi-native")!.definitionMetadata).toMatchObject({ version: 13, profileVersion: 15, agentMemoryContent: "utf8-nonce-plus-final-lf", agentMemoryPrompt: "ordered-memory-single-json-content-including-final-lf", taskPromptTransport: "fenced-markdown-paste-and-multiline-literal-escapes", nativeFinish: "current-contract-objective-evidence-refs", providerFaultExecutable: "stable-preinstalled-runner-link-and-snapshot-node-inode-with-held-bootstrap-fd-3-or-7" }); expect(runnerSuites.find(s => s.id === "pi-controls")!.definitionMetadata).toMatchObject({ version: 8, profileVersion: 15, remoteProcessIdentity: "observer-pid-startTicks-bootId", controlPlaneSettlement: "required-scoped-result-and-terminal-after-runner" }); @@ -200,7 +200,7 @@ describe("Pi controls catalog admission", () => { } const hashes = Object.fromEntries(runnerSuites.filter(s => ["pi-native", "native-active-stop", "extended-harnesses", "rich-acp-warm-continuity"].includes(s.id)).map(s => [s.id, suiteDefinitionHash(s)])); expect(hashes).toEqual({ - "pi-native": "7ba2ea4e0007667ef59694c4bdde8f448bbc72f50c705ada64e49ebe69bc943f", + "pi-native": "8ac5fa3e8dc75486c56a92364b1c9e141011ae1bd04a431d6c3ae2f237f99b58", "native-active-stop": "99682b2b106d816a011834fae5a944ed7729958893709d5b83a19b6f595e7e4d", "rich-acp-warm-continuity": "036c0faebc2f6eee5cd22ea38887c9c22650a83561fd08ee83473a565b11bb00", "extended-harnesses": "121f4cf75267bcdb003e5ed59e165755b2ac0c3d31c82dc217a62c8abe3d1b4d", diff --git a/tests/runner-e2e/pi-native-cases.test.ts b/tests/runner-e2e/pi-native-cases.test.ts index 227255d9fd0..1b40545d041 100644 --- a/tests/runner-e2e/pi-native-cases.test.ts +++ b/tests/runner-e2e/pi-native-cases.test.ts @@ -1,10 +1,21 @@ import { describe, expect, it } from "vitest"; -import { gradePiNativeAnswers, hasFailedPiWrite, hasPiCrossRootDenial, piNativeTasks } from "./pi-native-cases.js"; +import { gradePiNativeAnswers, hasFailedPiWrite, hasPiCrossRootDenial, piNativeMemoryPrompt, piNativeTasks } from "./pi-native-cases.js"; import { runnerMatrix, runnerSuites } from "./catalog.js"; import { buildRunnerE2EProcessEnvironment } from "./harness-env.js"; import { parseRunnerSelectors, selectRunnerExecutions } from "./selectors.js"; describe("Pi native Product qualification", () => { + it("gives memory content one authoritative JSON representation with its final LF", () => { + const nonce = "0123456789abcdef0123456789abcdef"; + const prompt = piNativeMemoryPrompt(nonce, "/unassigned/denied.txt"); + expect(prompt.split(nonce)).toHaveLength(2); + const encoded = /```json\n(.*?)\n```/s.exec(prompt)![1]!; + const content = JSON.parse(encoded).content; + expect(content).toBe(`${nonce}\n`); + expect(Buffer.byteLength(content)).toBe(33); + expect(Buffer.from(content).at(-1)).toBe(10); + expect(prompt).toContain("Do not trim or repeat the memory write"); + }); it("selects five local and five remote Pi cases without changing the basic extended matrix", () => { const suite = runnerSuites.find(row => row.id === "pi-native")!; expect(suite.manualOnly).toBe(true); expect(suite.expectedMatrixSize).toBe(10); diff --git a/tests/runner-e2e/pi-native-cases.ts b/tests/runner-e2e/pi-native-cases.ts index b0150455078..baa98f65bd6 100644 --- a/tests/runner-e2e/pi-native-cases.ts +++ b/tests/runner-e2e/pi-native-cases.ts @@ -26,7 +26,7 @@ export function piNativeMemoryPrompt(nonce: string, outsidePath?: string): strin return [ "Follow these steps in order. Use native file tools; do not use bash or the instructions API.", "1. Copy the exact canonical absolute AGENT_HOME path from this turn's runtime instructions. Native file paths do not expand $AGENT_HOME. Do not use a remembered path or reconstruct any directory name.", - `2. Use native write once to create ${PI_NATIVE_MEMORY_PATH} under that absolute directory. This is personal memory, not a task deliverable. Set content to the ${Buffer.byteLength(nonce, "utf8")} UTF-8 bytes of ${nonce}, followed by exactly one line-feed byte (U+000A). Copy the content value from this JSON; its escaped newline denotes the final byte, not two literal characters. Do not edit AGENTS.md or a project file.`, + `2. Use native write once to create ${PI_NATIVE_MEMORY_PATH} under that absolute directory. This is personal memory, not a task deliverable. Decode the following JSON and pass its content value unchanged to native write. This is the only content specification: ${Buffer.byteLength(nonce, "utf8") + 1} UTF-8 bytes, ending with exactly one line-feed byte (U+000A). The escaped newline is part of the content; do not omit it or write two literal backslash-and-n characters. Do not edit AGENTS.md or a project file.`, "```json", JSON.stringify({ content: `${nonce}\n` }), "```", diff --git a/tests/runner-e2e/remote-native-fixtures.test.ts b/tests/runner-e2e/remote-native-fixtures.test.ts index 35dd55b33f6..6757b5b20b9 100644 --- a/tests/runner-e2e/remote-native-fixtures.test.ts +++ b/tests/runner-e2e/remote-native-fixtures.test.ts @@ -381,7 +381,7 @@ describe("actual generated observer state machine", () => { const handlers: Array<(socket: any) => void> = [], children: any[] = []; const missing = () => { throw Object.assign(new Error("missing"), { code: "ENOENT" }); }; const fds = new Map(); let nextFd = 50, runtimeInode = 4n; - const symbolicLinks = new Set(); + const symbolicLinks = new Set(), directoryInodes = new Map(); const directories = new Set(["/tmp", "/workspace", "/workspace/.paperclip-runtime", "/workspace/.paperclip-runtime/paperclip-runner", "/workspace/.paperclip-runtime/paperclip-runner/sessions"]); if (!deferStartup) directories.add(config.root); const listeners = new Map void>(); @@ -405,10 +405,10 @@ describe("actual generated observer state machine", () => { lstatSync(path: string) { const directory = directories.has(path); if (!directory && !files.has(path) && !symbolicLinks.has(path)) return missing(); - return { dev: 1n, ino: path === config.root ? 2n : path === "/workspace/.paperclip-runtime/paperclip-runner" ? runtimeInode : 3n, mtimeNs: 4n, ctimeNs: 5n, isDirectory: () => directory, isFile: () => !directory, isSymbolicLink: () => symbolicLinks.has(path), size: files.get(path)?.length ?? 0 }; + return { dev: 1n, ino: directoryInodes.get(path) ?? (path === config.root ? 2n : path === "/workspace/.paperclip-runtime/paperclip-runner" ? runtimeInode : 3n), mtimeNs: 4n, ctimeNs: 5n, isDirectory: () => directory, isFile: () => !directory, isSymbolicLink: () => symbolicLinks.has(path), size: files.get(path)?.length ?? 0 }; }, realpathSync: (path: string) => path, - readdirSync(path: string) { if (path === "/proc") return [...proc.keys()].map(String); if (path === "/workspace") return [".paperclip-runtime", ...[...files.keys(), ...symbolicLinks].filter(p => p.startsWith("/workspace/") && !p.slice(11).includes("/")).map(p => p.slice(11))]; if (path === "/workspace/.paperclip-runtime") return ["reusable-sandbox-lease.json", "paperclip-runner", ...[...files.keys()].filter(p => p.startsWith(path + "/") && !p.slice(path.length + 1).includes("/") && !p.endsWith("reusable-sandbox-lease.json")).map(p => p.slice(path.length + 1))]; if (path.startsWith("/workspace/.paperclip-runtime/paperclip-runner")) throw new Error("excluded runtime must not be traversed"); return []; }, + readdirSync(path: string) { if (path === "/proc") return [...proc.keys()].map(String); if (path.startsWith("/workspace/.paperclip-runtime/paperclip-runner")) throw new Error("excluded runtime must not be traversed"); return [...new Set([...files.keys(), ...directories, ...symbolicLinks].filter(p => p.startsWith(path + "/") && !p.slice(path.length + 1).includes("/")).map(p => p.slice(path.length + 1)))]; }, watch(path: string, options: unknown, callback?: (_kind: string, name: string | null) => void) { const entry = { path, callback: (callback ?? options) as (_kind: string, name: string | null) => void, closed: false }; watches.push(entry); return Object.assign(new EventEmitter(), { close: () => { entry.closed = true; } }); @@ -449,8 +449,36 @@ describe("actual generated observer state machine", () => { const replies: any[] = [], socket = Object.assign(new EventEmitter(), { end: (value: string) => replies.push(JSON.parse(value)), destroy: vi.fn() }); handlers[0]!(socket); socket.emit("data", Buffer.from(JSON.stringify({ op, nonce: config.nonce, ...args }) + "\n")); return replies; } - return { request, proc, files, watches, fs, intervals, timers, config, handlers, children, faultSpawn, symbolicLinks, context, server, directories, listeners, install: h.calls.find(c => c.request.op === "install")!, replaceRuntimeRoot() { runtimeInode = 999n; } }; + return { request, proc, files, watches, fs, intervals, timers, config, handlers, children, faultSpawn, symbolicLinks, directoryInodes, context, server, directories, listeners, install: h.calls.find(c => c.request.op === "install")!, replaceRuntimeRoot() { runtimeInode = 999n; } }; } + it("keeps existing watched directory notifications complete without losing nested mutations", async () => { + const o = await observerHarness(true); + o.directories.add(o.config.root); o.files.set(`${o.config.root}/observer.cjs`, Buffer.from(o.install.request.source)); + o.directories.add("/workspace/existing"); + new Script(o.install.request.source).runInNewContext(o.context); + // Linux emits a parent notification when chmod changes a child's directory + // attributes. Its inode and registered recursive watch remain unchanged. + for (const w of o.watches) if (w.path === "/workspace") w.callback("change", "existing"); + expect(o.request("snapshot")[0].result.complete).toBe(true); + o.fs.writeFileSync("/workspace/existing/transient.txt", "changed", { flag: "wx" }); + o.files.delete("/workspace/existing/transient.txt"); + o.watches.find(w => w.path === "/workspace/existing")!.callback("rename", "transient.txt"); + const final = o.request("snapshot")[0].result; + expect(final.complete).toBe(true); expect(final.watcher.workspaceMutationCount).toBe(3); + expect(final.workspace["existing/transient.txt"]).toBeUndefined(); + }); + it.each(["new", "replacement", "symlink", "unknown"])("rejects %s directory notifications", async variant => { + const o = await observerHarness(true); + o.directories.add(o.config.root); o.files.set(`${o.config.root}/observer.cjs`, Buffer.from(o.install.request.source)); + if (variant !== "new") o.directories.add("/workspace/existing"); + new Script(o.install.request.source).runInNewContext(o.context); + if (variant === "new") o.directories.add("/workspace/existing"); + if (variant === "replacement") o.directoryInodes.set("/workspace/existing", 999n); + if (variant === "symlink") o.symbolicLinks.add("/workspace/existing"); + for (const w of o.watches) if (w.path === "/workspace") w.callback("change", variant === "unknown" ? null : "existing"); + const reply = o.request("snapshot")[0]; + expect(reply.ok && reply.result.complete).toBe(false); + }); it("executes the actual observer fault phase once with a closed environment and exact identity", async () => { for (const published of [false, true]) { const rejected = await observerHarness(); diff --git a/tests/runner-e2e/remote-native-fixtures.ts b/tests/runner-e2e/remote-native-fixtures.ts index ae8eba2c5fa..7c87669ddce 100644 --- a/tests/runner-e2e/remote-native-fixtures.ts +++ b/tests/runner-e2e/remote-native-fixtures.ts @@ -175,7 +175,11 @@ function snapshot(){guard();verifyWorkspaceWatchRoots();const processes=sample() for(const name of config.targets){const p=path.join(config.binding.remoteCwd,name);if(fs.realpathSync(path.dirname(p))!==path.dirname(p))throw Error('target_parent_symlink');targets.set(name,{path:p,watch:watchTarget(path.dirname(p),path.basename(p),{watch:fs.watch,lstatSync:fs.lstatSync})})} if(config.crossRoot){const p=path.join(config.root,'cross-root-target');fs.writeFileSync(p,config.crossRoot.initialText,{flag:'wx',mode:0o600});targets.set('@cross-root',{path:p,watch:watchTarget(config.root,'cross-root-target',{watch:fs.watch,lstatSync:fs.lstatSync})})} let workspaceMutationCount=0;const directoryWatches=[]; -function watchDirectory(directory,prefix=''){if(directoryWatches.length>=512)throw Error('watch_directory_bound');const before=fs.lstatSync(directory,{bigint:true});if(!before.isDirectory()||before.isSymbolicLink())throw Error('watch_directory_identity');const handle=fs.watch(directory,(_kind,name)=>{if(name===null){complete=false;return}const relative=prefix+String(name);if(relative===config.runtimeRelative)return;if(relative===config.actionFile){try{if(!publishedHash||file(path.join(config.binding.remoteCwd,config.actionFile)).sha256!==publishedHash)complete=false}catch{complete=false}return}workspaceMutationCount++;if(workspaceMutationCount>4096)complete=false;try{if(fs.lstatSync(path.join(directory,String(name))).isDirectory())complete=false}catch(e){if(e.code!=='ENOENT')complete=false}});handle.on('error',()=>{complete=false});directoryWatches.push({directory,before,handle});for(const name of fs.readdirSync(directory)){const rel=prefix+name;if(rel===config.runtimeRelative)continue;const full=path.join(directory,name),s=fs.lstatSync(full);if(s.isSymbolicLink())throw Error('workspace_symlink');if(s.isDirectory())watchDirectory(full,rel+'/')}} +// Existing directory attribute notifications do not create an observation gap: +// accept only the same inode with an already registered recursive watch. New +// directories and replacements remain incomplete because their writes can race +// watch installation. Every notification still counts as a workspace mutation. +function watchDirectory(directory,prefix=''){if(directoryWatches.length>=512)throw Error('watch_directory_bound');const before=fs.lstatSync(directory,{bigint:true});if(!before.isDirectory()||before.isSymbolicLink())throw Error('watch_directory_identity');const handle=fs.watch(directory,(_kind,name)=>{if(name===null){complete=false;return}const relative=prefix+String(name);if(relative===config.runtimeRelative)return;if(relative===config.actionFile){try{if(!publishedHash||file(path.join(config.binding.remoteCwd,config.actionFile)).sha256!==publishedHash)complete=false}catch{complete=false}return}workspaceMutationCount++;if(workspaceMutationCount>4096)complete=false;try{const changed=path.join(directory,String(name)),st=fs.lstatSync(changed,{bigint:true});if(st.isSymbolicLink())complete=false;else if(st.isDirectory()){const watched=directoryWatches.find(item=>item.directory===changed);if(!watched||st.dev!==watched.before.dev||st.ino!==watched.before.ino)complete=false}}catch(e){if(e.code!=='ENOENT')complete=false}});handle.on('error',()=>{complete=false});directoryWatches.push({directory,before,handle});for(const name of fs.readdirSync(directory)){const rel=prefix+name;if(rel===config.runtimeRelative)continue;const full=path.join(directory,name),s=fs.lstatSync(full);if(s.isSymbolicLink())throw Error('workspace_symlink');if(s.isDirectory())watchDirectory(full,rel+'/')}} watchDirectory(config.binding.remoteCwd); const workspaceWatch={close(){for(const item of directoryWatches)item.handle.close()}}; function verifyWorkspaceWatchRoots(){for(const item of directoryWatches){const after=fs.lstatSync(item.directory,{bigint:true});if(after.dev!==item.before.dev||after.ino!==item.before.ino||!after.isDirectory()||after.isSymbolicLink())throw Error('workspace_watch_root_replaced')}}