repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by bugabinga

fix(the-system): allow external path edits

445aa30e2064020c812306fc0973ba0c84194a2e

Oliver Jan Krylow <oliver@bugabinga.net> ·

unsigned

Browse filesCompare with HEAD

Changed files (2)

extensions/the-system/__tests__/system.test.ts

Modified
85 85 describe("runtime bundle governance", () => {
86 + it("does not govern mutations outside the detected project root", async () => {
87 + const project = root();
88 + const outside = path.join(path.dirname(project), "outside.md");
90 + assert.equal(
91 + (
92 + await preflightFileMutation(
93 + project,
94 + "write",
95 + { path: outside, content: "outside" },
96 + approval(),
97 + )
98 + )?.block,
99 + undefined,
100 + );
101 + });
86 103 it("allows valid new index candidates and blocks invalid layouts and metadata before approval", async () => {
87 104 const project = root();
88 105 assert.equal(

extensions/the-system/system.ts

Modified
289 289 `The System cannot resolve project ownership: ${error instanceof Error ? error.message : String(error)}`,
292 + const candidate = path.resolve(cwd, input.path);
293 + const candidateRelative = path.relative(root, candidate);
294 + if (
295 + candidateRelative === ".." ||
296 + candidateRelative.startsWith(`..${path.sep}`) ||
297 + path.isAbsolute(candidateRelative)
299 + return undefined;
292 300 let target: string;
294 - target = resolveGovernedPath(root, path.resolve(cwd, input.path));
302 + target = resolveGovernedPath(root, candidate);
295 303 } catch (error) {
296 304 return blocked(
297 305 `The System rejected the governed path: ${error instanceof Error ? error.message : String(error)}`,