fix: harden PTY events and configured roots

This commit is contained in:
N0zoM1z0
2026-07-14 15:21:39 +08:00
parent 2575b30dfc
commit 31b40f39e4
14 changed files with 180 additions and 40 deletions
+20 -2
View File
@@ -34,12 +34,16 @@ const fixture = async (parent: string, name: string): Promise<string> => {
return root;
};
const importTree = (root: string, approvedRoot: string, signal?: AbortSignal) =>
const importTree = (
root: string,
approvedRoot: string | readonly string[],
signal?: AbortSignal,
) =>
importReferenceSource({
root,
caller: "reference-import-test",
policy: {
roots: [approvedRoot],
roots: typeof approvedRoot === "string" ? [approvedRoot] : approvedRoot,
secretPatterns: [".env", ".env.*"],
...limits,
},
@@ -153,6 +157,20 @@ describe("reference source import", () => {
}
});
it("uses a valid reference root when another configured root is missing", async () => {
const parent = await mkdtemp(join(tmpdir(), "rea-reference-roots-"));
try {
const root = await fixture(parent, "tree");
const imported = await importTree(root, [
join(parent, "missing"),
parent,
]);
expect(imported).toMatchObject({ ok: true });
} finally {
await rm(parent, { recursive: true, force: true });
}
});
it("records bounded local Git state without invoking Git", async () => {
const parent = await mkdtemp(join(tmpdir(), "rea-reference-git-"));
try {