feat(errors): add caller-safe typed error projections

This commit is contained in:
morluto
2026-07-13 11:50:49 +00:00
parent 9f3639f29f
commit 3be439cbf3
7 changed files with 261 additions and 18 deletions
+10 -1
View File
@@ -382,7 +382,16 @@ export interface ProcessExecutionPolicy {
/** Explicit authorization result; denial reasons are safe to show callers. */
export type ProcessPolicyDecision =
| { readonly allowed: true }
| { readonly allowed: false; readonly reason: string };
| {
readonly allowed: false;
readonly reason:
| "process capture is disabled"
| "host network access is not approved by operator policy"
| "executable is outside approved roots"
| "working directory is outside approved roots"
| "scenario requests an environment variable not allowed by policy"
| "filesystem root is outside approved roots";
};
const isWithin = (candidate: string, root: string): boolean =>
resolve(candidate) === resolve(root) ||