@hasna/hooks 0.11.7 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -224,6 +224,12 @@ console.log("packed credential-file reference, rotation and terminal failure pas
224
224
  * a runtime SDK import, and one bundled-hook run with an isolated data dir.
225
225
  */
226
226
  async function validatePackedNativeSafety(packageDir: string, smokeDir: string): Promise<void> {
227
+ const worker = join(packageDir, "bin/native-safety-entry.js");
228
+ const bytes = await readFile(worker);
229
+ // The supervisor passes the worker as one `--eval` argument; Linux refuses a
230
+ // single argument over 32 pages (131,072 bytes with 4 KiB pages), and every
231
+ // command would then fail to launch. Check it before the launch smoke tests.
232
+ if (bytes.length >= 131_072) throw new Error(`Packed native worker is ${bytes.length} bytes; one exec argument holds at most 131072`);
227
233
  const home = join(smokeDir, "native-safety-home");
228
234
  await mkdir(home, { mode: 0o700 });
229
235
  const settings = join(home, ".codex", "hooks.json");
@@ -250,12 +256,16 @@ async function validatePackedNativeSafety(packageDir: string, smokeDir: string):
250
256
  if (benign.status !== 0 || benign.stdout !== "" || benign.stderr !== "") throw new Error("Packed native benign verdict failed");
251
257
  const refused = invoke(`rm -- ${join(home, "owned-fixture")}`);
252
258
  if (refused.status !== 0 || JSON.parse(refused.stdout).hookSpecificOutput.permissionDecision !== "deny") throw new Error("Packed native missing-Trash refusal failed");
259
+ // The packed worker carries the signed-link guard for every Bash command.
260
+ const composite = invoke("gh pr view 1175 --json body");
261
+ if (composite.status !== 0 || JSON.parse(composite.stdout).hookSpecificOutput.permissionDecisionReason
262
+ !== "composite output withheld: signed-link shape; use bounded scalar projections per class disposition 799310") throw new Error("Packed native signed-link refusal failed");
263
+ const scalar = invoke("gh pr view 1175 --json headRefOid,headRefName");
264
+ if (scalar.status !== 0 || scalar.stdout !== "" || scalar.stderr !== "") throw new Error("Packed native scalar gh read was not allowed");
253
265
  const probe = join(smokeDir, "native-registration.ts");
254
266
  await writeFile(probe, `import { getRegisteredHooksForTarget } from "@hasna/hooks"; console.log(JSON.stringify(getRegisteredHooksForTarget("global", "codex")));`);
255
267
  const listed = spawnSync(runtime, [probe], { cwd: smokeDir, env, encoding: "utf8", timeout: 15_000 });
256
268
  if (listed.status !== 0 || JSON.stringify(JSON.parse(listed.stdout)) !== '["trash-guard"]') throw new Error("Packed SDK cannot recognize the compiled CLI safety registration");
257
- const worker = join(packageDir, "bin/native-safety-entry.js");
258
- const bytes = await readFile(worker);
259
269
  try {
260
270
  await writeFile(worker, Buffer.concat([bytes, Buffer.from("\n// changed fixture\n")]));
261
271
  const changed = invoke("rm -- owned-fixture");