@lannguyensi/harness 0.49.0 → 0.51.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.
- package/CHANGELOG.md +791 -0
- package/dist/cli/add/index.js +15 -3
- package/dist/cli/add/index.js.map +1 -1
- package/dist/cli/apply/apply.js +19 -3
- package/dist/cli/apply/apply.js.map +1 -1
- package/dist/cli/approve/risk.d.ts +28 -2
- package/dist/cli/approve/risk.js +14 -4
- package/dist/cli/approve/risk.js.map +1 -1
- package/dist/cli/approve/understanding.d.ts +51 -0
- package/dist/cli/approve/understanding.js +17 -2
- package/dist/cli/approve/understanding.js.map +1 -1
- package/dist/cli/diff/index.js +22 -1
- package/dist/cli/diff/index.js.map +1 -1
- package/dist/cli/doctor/claude-mcp.d.ts +14 -0
- package/dist/cli/doctor/claude-mcp.js +7 -1
- package/dist/cli/doctor/claude-mcp.js.map +1 -1
- package/dist/cli/doctor/format.js +48 -3
- package/dist/cli/doctor/format.js.map +1 -1
- package/dist/cli/doctor/index.d.ts +20 -0
- package/dist/cli/doctor/index.js +66 -2
- package/dist/cli/doctor/index.js.map +1 -1
- package/dist/cli/doctor/settings-drift.d.ts +19 -0
- package/dist/cli/doctor/settings-drift.js +189 -0
- package/dist/cli/doctor/settings-drift.js.map +1 -0
- package/dist/cli/doctor/types.d.ts +52 -0
- package/dist/cli/doctor/types.js.map +1 -1
- package/dist/cli/doctor/ug-auto-approvals.d.ts +40 -0
- package/dist/cli/doctor/ug-auto-approvals.js +116 -0
- package/dist/cli/doctor/ug-auto-approvals.js.map +1 -0
- package/dist/cli/doctor/understanding-mode-env.d.ts +10 -0
- package/dist/cli/doctor/understanding-mode-env.js +12 -0
- package/dist/cli/doctor/understanding-mode-env.js.map +1 -1
- package/dist/cli/explain-policy.d.ts +4 -1
- package/dist/cli/explain-policy.js +12 -2
- package/dist/cli/explain-policy.js.map +1 -1
- package/dist/cli/export.js +12 -1
- package/dist/cli/export.js.map +1 -1
- package/dist/cli/index.js +40 -7
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/init/templates.d.ts +1 -1
- package/dist/cli/init/templates.js +65 -1
- package/dist/cli/init/templates.js.map +1 -1
- package/dist/cli/list.js +6 -0
- package/dist/cli/list.js.map +1 -1
- package/dist/cli/loader.js +15 -0
- package/dist/cli/loader.js.map +1 -1
- package/dist/cli/pack/auto-approve-path.d.ts +118 -0
- package/dist/cli/pack/auto-approve-path.js +347 -0
- package/dist/cli/pack/auto-approve-path.js.map +1 -0
- package/dist/cli/pack/hook-codex-pre-tool-use.d.ts +9 -0
- package/dist/cli/pack/hook-codex-pre-tool-use.js +129 -10
- package/dist/cli/pack/hook-codex-pre-tool-use.js.map +1 -1
- package/dist/cli/pack/hook-post-tool-use.d.ts +6 -4
- package/dist/cli/pack/hook-post-tool-use.js.map +1 -1
- package/dist/cli/pack/hook-pre-tool-use.d.ts +11 -0
- package/dist/cli/pack/hook-pre-tool-use.js +90 -23
- package/dist/cli/pack/hook-pre-tool-use.js.map +1 -1
- package/dist/cli/remove/index.d.ts +12 -0
- package/dist/cli/remove/index.js +89 -0
- package/dist/cli/remove/index.js.map +1 -1
- package/dist/cli/validate/checks.d.ts +48 -0
- package/dist/cli/validate/checks.js +312 -0
- package/dist/cli/validate/checks.js.map +1 -1
- package/dist/cli/validate/index.js +11 -0
- package/dist/cli/validate/index.js.map +1 -1
- package/dist/policy-packs/builtin/understanding-before-execution/auto-approve.d.ts +136 -0
- package/dist/policy-packs/builtin/understanding-before-execution/auto-approve.js +224 -0
- package/dist/policy-packs/builtin/understanding-before-execution/auto-approve.js.map +1 -0
- package/dist/policy-packs/builtin/understanding-before-execution/index.d.ts +3 -2
- package/dist/policy-packs/builtin/understanding-before-execution/index.js +35 -28
- package/dist/policy-packs/builtin/understanding-before-execution/index.js.map +1 -1
- package/dist/policy-packs/builtin/understanding-before-execution/markers.js +2 -2
- package/dist/policy-packs/builtin/understanding-before-execution/markers.js.map +1 -1
- package/dist/policy-packs/builtin/understanding-before-execution/measured-permission-modes.d.ts +29 -0
- package/dist/policy-packs/builtin/understanding-before-execution/measured-permission-modes.js +82 -0
- package/dist/policy-packs/builtin/understanding-before-execution/measured-permission-modes.js.map +1 -0
- package/dist/policy-packs/builtin/understanding-before-execution/persisted-reports.d.ts +69 -8
- package/dist/policy-packs/builtin/understanding-before-execution/persisted-reports.js +100 -12
- package/dist/policy-packs/builtin/understanding-before-execution/persisted-reports.js.map +1 -1
- package/dist/policy-packs/builtin/understanding-before-execution/post-tool-use-boundary.js +6 -3
- package/dist/policy-packs/builtin/understanding-before-execution/post-tool-use-boundary.js.map +1 -1
- package/dist/policy-packs/builtin/understanding-before-execution.d.ts +23 -0
- package/dist/policy-packs/builtin/understanding-before-execution.js +36 -9
- package/dist/policy-packs/builtin/understanding-before-execution.js.map +1 -1
- package/dist/runtime/approval-signing.d.ts +22 -0
- package/dist/runtime/approval-signing.js +55 -1
- package/dist/runtime/approval-signing.js.map +1 -1
- package/dist/runtime/command-normalize.d.ts +112 -0
- package/dist/runtime/command-normalize.js +169 -55
- package/dist/runtime/command-normalize.js.map +1 -1
- package/dist/runtime/deletion-target-resolve.d.ts +28 -0
- package/dist/runtime/deletion-target-resolve.js +1055 -0
- package/dist/runtime/deletion-target-resolve.js.map +1 -0
- package/dist/runtime/index.d.ts +1 -0
- package/dist/runtime/index.js +1 -0
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/intercept.js +17 -1
- package/dist/runtime/intercept.js.map +1 -1
- package/dist/runtime/kubectl-target-parse.d.ts +16 -0
- package/dist/runtime/kubectl-target-parse.js +9 -1
- package/dist/runtime/kubectl-target-parse.js.map +1 -1
- package/dist/runtime/read-only-bash.d.ts +11 -0
- package/dist/runtime/read-only-bash.js +288 -7
- package/dist/runtime/read-only-bash.js.map +1 -1
- package/dist/runtime/risk-classifier.js +14 -1
- package/dist/runtime/risk-classifier.js.map +1 -1
- package/dist/runtime/when-eval.d.ts +11 -2
- package/dist/runtime/when-eval.js +25 -0
- package/dist/runtime/when-eval.js.map +1 -1
- package/dist/runtime/workflow-policies.d.ts +164 -0
- package/dist/runtime/workflow-policies.js +439 -0
- package/dist/runtime/workflow-policies.js.map +1 -0
- package/dist/schema/index.d.ts +24 -0
- package/dist/schema/policies.d.ts +25 -0
- package/dist/schema/policies.js +29 -0
- package/dist/schema/policies.js.map +1 -1
- package/dist/schema/risk.d.ts +6 -0
- package/dist/schema/risk.js +80 -0
- package/dist/schema/risk.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Prefix every auto-minted marker's `approvedBy` carries, distinguishing
|
|
3
|
+
* it from a human `harness approve understanding` marker (which carries
|
|
4
|
+
* the operator's own identity string, never this prefix).
|
|
5
|
+
*/
|
|
6
|
+
export declare const AUTO_APPROVED_BY_PREFIX = "auto-mode:";
|
|
7
|
+
/** The harness identifier the Claude Code PreToolUse hook mints markers for. */
|
|
8
|
+
export declare const CLAUDE_CODE_HARNESS = "claude-code";
|
|
9
|
+
/**
|
|
10
|
+
* The harness identifier the Codex PreToolUse hook mints markers for
|
|
11
|
+
* (slice 2 of the ADR: same auto path, same fail-closed conditions, a
|
|
12
|
+
* distinct `approvedBy` segment so an audit can tell the two runtimes
|
|
13
|
+
* apart). Deliberately NOT re-exported through
|
|
14
|
+
* `understanding-before-execution/index.ts`: its only consumer is
|
|
15
|
+
* `src/cli/pack/hook-codex-pre-tool-use.ts`, and widening the runtime
|
|
16
|
+
* shim's pinned public surface (tests/policy-packs/ube-export-surface.test.ts)
|
|
17
|
+
* is a separate, conscious act.
|
|
18
|
+
*/
|
|
19
|
+
export declare const CODEX_HARNESS = "codex";
|
|
20
|
+
/**
|
|
21
|
+
* Build the `approvedBy` value the hook writes into a signed auto-marker:
|
|
22
|
+
* `auto-mode:<harness>:<mode>`, for example `auto-mode:claude-code:bypassPermissions`
|
|
23
|
+
* or `auto-mode:codex:bypassPermissions` ("Audit and doctor" in the ADR).
|
|
24
|
+
* Neither `harness` nor `mode` is validated here; callers pass
|
|
25
|
+
* already-known-good values (one of the fixed harness constants above and
|
|
26
|
+
* a `when`-matched mode string).
|
|
27
|
+
*/
|
|
28
|
+
export declare function autoApprovedByFor(harness: string, mode: string): string;
|
|
29
|
+
/** Parsed shape of an `approvedBy` string minted by {@link autoApprovedByFor}. */
|
|
30
|
+
export interface ParsedAutoApprovedBy {
|
|
31
|
+
harness: string;
|
|
32
|
+
mode: string;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Parse an `approvedBy` string back into its harness/mode pair. Returns
|
|
36
|
+
* `null` for anything that is not exactly `auto-mode:<harness>:<mode>`
|
|
37
|
+
* with both segments non-empty, including a human marker's `approvedBy`
|
|
38
|
+
* (which never carries this prefix) and a malformed or truncated auto
|
|
39
|
+
* value. A slice 3 delegation suffix (`;delegated:<parent-sid>`) is
|
|
40
|
+
* tolerated: it is stripped before parsing and otherwise ignored, per
|
|
41
|
+
* the ADR's "Audit and doctor" convention that the delegation binding
|
|
42
|
+
* packs into the same field without changing the harness/mode shape.
|
|
43
|
+
*/
|
|
44
|
+
export declare function parseAutoApprovedBy(approvedBy: unknown): ParsedAutoApprovedBy | null;
|
|
45
|
+
/**
|
|
46
|
+
* Build the audit-only ledger fact the ADR's "Audit and doctor" section
|
|
47
|
+
* names: `understanding-auto-approved:<sid>`, distinct from the human
|
|
48
|
+
* `understanding-approved:<sid>` tag (`ledger.ts`), following the same
|
|
49
|
+
* `...:forced:<field>` suffix precedent the ADR cites. Ledger only, never
|
|
50
|
+
* consulted for the gate decision itself.
|
|
51
|
+
*/
|
|
52
|
+
export declare function autoApprovedLedgerTagFor(sessionId: string): string;
|
|
53
|
+
/**
|
|
54
|
+
* The harness identifiers `auto_approve.harnesses` accepts, in the order
|
|
55
|
+
* the schema and every diagnostic list them. Shared with the pack's zod
|
|
56
|
+
* `configSchema` (`../understanding-before-execution.ts`) so the lint-time
|
|
57
|
+
* enum and this runtime parser cannot drift apart.
|
|
58
|
+
*/
|
|
59
|
+
export declare const AUTO_APPROVE_HARNESS_VALUES: readonly ["claude-code", "codex"];
|
|
60
|
+
/**
|
|
61
|
+
* What `auto_approve.harnesses` resolves to when the key is ABSENT.
|
|
62
|
+
* Claude Code only, deliberately: slice 1 shipped `auto_approve` as a
|
|
63
|
+
* Claude-only opt-in, so a repo that opted in before slice 2 must keep
|
|
64
|
+
* exactly the meaning it had — adding the Codex hook to the shared body
|
|
65
|
+
* must not silently extend an existing opt-in to a second runtime
|
|
66
|
+
* (reviewer round-1 finding on slice 2). Opting Codex in is an explicit,
|
|
67
|
+
* visible config edit.
|
|
68
|
+
*/
|
|
69
|
+
export declare const DEFAULT_AUTO_APPROVE_HARNESSES: readonly string[];
|
|
70
|
+
/** Parsed, validated `auto_approve` pack-config block. */
|
|
71
|
+
export interface AutoApproveConfig {
|
|
72
|
+
/** Allowlist of `permission_mode` payload literals eligible for auto-approval. */
|
|
73
|
+
when: string[];
|
|
74
|
+
/**
|
|
75
|
+
* Allowlist of HARNESSES whose PreToolUse hook may take the auto path
|
|
76
|
+
* at all. Always non-empty: an absent key resolves to
|
|
77
|
+
* {@link DEFAULT_AUTO_APPROVE_HARNESSES}, and every malformed shape
|
|
78
|
+
* fails the whole block closed rather than defaulting.
|
|
79
|
+
*/
|
|
80
|
+
harnesses: string[];
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Parse the optional `auto_approve` pack-config block
|
|
84
|
+
* (docs/decisions/2026-08-27-ug-auto-mode-approval.md, "Option A").
|
|
85
|
+
*
|
|
86
|
+
* FAIL CLOSED, unlike {@link parseApprovalLifecycle}'s best-effort
|
|
87
|
+
* fallback: this block is an opt-IN to a hook-side signing path
|
|
88
|
+
* (hardening item 3 in the ADR's threat model (b) — `require_report:
|
|
89
|
+
* false` must be a schema error, not a silently-ignored key), so any
|
|
90
|
+
* malformed shape here means "not opted in" (`null`), never a partial
|
|
91
|
+
* or default-filled config that could still enable the auto path. The
|
|
92
|
+
* `configSchema` zod block in `../understanding-before-execution.ts` is
|
|
93
|
+
* the first line of defence (`harness validate` / `harness doctor`
|
|
94
|
+
* reject a malformed manifest at lint time); this parser is the second,
|
|
95
|
+
* defensive line for the runtime hook, which must not trust that every
|
|
96
|
+
* config it sees on disk passed the schema.
|
|
97
|
+
*
|
|
98
|
+
* `undefined` / `null` (the block is simply absent) returns `null`
|
|
99
|
+
* silently — that is the ordinary "not opted in" case, not a warning.
|
|
100
|
+
* Every other malformed shape writes exactly one stderr line and
|
|
101
|
+
* returns `null`.
|
|
102
|
+
*
|
|
103
|
+
* `label` is the stderr prefix of the calling hook, so a Codex-side
|
|
104
|
+
* warning reads `harness pack hook codex: ...` like every other line
|
|
105
|
+
* that hook writes. The default reproduces the Claude Code hook's
|
|
106
|
+
* wording byte-for-byte.
|
|
107
|
+
*/
|
|
108
|
+
export declare function parseAutoApprove(raw: unknown, stderr?: {
|
|
109
|
+
write(s: string): void;
|
|
110
|
+
} | null, label?: string): AutoApproveConfig | null;
|
|
111
|
+
/**
|
|
112
|
+
* ADR "Additional hardening to specify" item 2: `when` is an allowlist
|
|
113
|
+
* of payload literals, membership by exact string equality, no case
|
|
114
|
+
* folding, no substring, no wildcards. `mode` absent, empty, or not a
|
|
115
|
+
* string means no auto-approval, and `cfg === null` (block absent or
|
|
116
|
+
* malformed) means no auto-approval regardless of `mode`.
|
|
117
|
+
*/
|
|
118
|
+
export declare function permissionModeAllowed(cfg: AutoApproveConfig | null, mode: unknown): boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Per-harness opt-in membership, the same exact-string-equality
|
|
121
|
+
* discipline {@link permissionModeAllowed} applies to `when`. `cfg ===
|
|
122
|
+
* null` (block absent or malformed) means no auto-approval regardless of
|
|
123
|
+
* the harness, and an unlisted harness means no auto-approval regardless
|
|
124
|
+
* of `when` — the two allowlists are independent AND conditions, not
|
|
125
|
+
* alternatives.
|
|
126
|
+
*
|
|
127
|
+
* Re-exported through `understanding-before-execution/index.ts` (round-2
|
|
128
|
+
* review finding on slice 2): its call site (`src/cli/pack/auto-approve-path.ts`)
|
|
129
|
+
* imports every sibling symbol it needs (`parseAutoApprove`,
|
|
130
|
+
* `permissionModeAllowed`, ...) through the runtime shim already, so this
|
|
131
|
+
* one was pulled onto the pinned shim surface
|
|
132
|
+
* (tests/policy-packs/ube-export-surface.test.ts) to match, unlike
|
|
133
|
+
* {@link CODEX_HARNESS} which still has exactly one consumer and stays a
|
|
134
|
+
* direct import.
|
|
135
|
+
*/
|
|
136
|
+
export declare function harnessAllowed(cfg: AutoApproveConfig | null, harness: unknown): boolean;
|
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
// `auto_approve` pack-config parsing and shared conventions, split out
|
|
2
|
+
// alongside lifecycle.ts (structural sibling of the former monolithic
|
|
3
|
+
// understanding-before-execution-runtime.ts, agent-tasks 348a4d42).
|
|
4
|
+
// Implements slice 1 of docs/decisions/2026-08-27-ug-auto-mode-approval.md
|
|
5
|
+
// (agent-tasks 74b4b17d): the strict pack-config block that lets an
|
|
6
|
+
// operator opt a permission mode into the hook-written signed
|
|
7
|
+
// auto-marker path, plus the shared `approvedBy` / ledger-tag
|
|
8
|
+
// conventions the hook and doctor consume so there is one authority
|
|
9
|
+
// for the string shapes instead of each caller reimplementing them.
|
|
10
|
+
//
|
|
11
|
+
// This module owns no gate decision and no marker write: it only
|
|
12
|
+
// parses the opt-in config (fail-closed: any malformed shape is
|
|
13
|
+
// treated as "not opted in", never as a partial default) and builds /
|
|
14
|
+
// parses the string conventions the ADR's "Audit and doctor" section
|
|
15
|
+
// documents. The PreToolUse hook (auto-path condition checks) and
|
|
16
|
+
// `harness doctor` (auto-approval listing) are the consumers; both
|
|
17
|
+
// land in later slice-1 tasks and import from here.
|
|
18
|
+
/**
|
|
19
|
+
* Prefix every auto-minted marker's `approvedBy` carries, distinguishing
|
|
20
|
+
* it from a human `harness approve understanding` marker (which carries
|
|
21
|
+
* the operator's own identity string, never this prefix).
|
|
22
|
+
*/
|
|
23
|
+
export const AUTO_APPROVED_BY_PREFIX = "auto-mode:";
|
|
24
|
+
/** The harness identifier the Claude Code PreToolUse hook mints markers for. */
|
|
25
|
+
export const CLAUDE_CODE_HARNESS = "claude-code";
|
|
26
|
+
/**
|
|
27
|
+
* The harness identifier the Codex PreToolUse hook mints markers for
|
|
28
|
+
* (slice 2 of the ADR: same auto path, same fail-closed conditions, a
|
|
29
|
+
* distinct `approvedBy` segment so an audit can tell the two runtimes
|
|
30
|
+
* apart). Deliberately NOT re-exported through
|
|
31
|
+
* `understanding-before-execution/index.ts`: its only consumer is
|
|
32
|
+
* `src/cli/pack/hook-codex-pre-tool-use.ts`, and widening the runtime
|
|
33
|
+
* shim's pinned public surface (tests/policy-packs/ube-export-surface.test.ts)
|
|
34
|
+
* is a separate, conscious act.
|
|
35
|
+
*/
|
|
36
|
+
export const CODEX_HARNESS = "codex";
|
|
37
|
+
/**
|
|
38
|
+
* Build the `approvedBy` value the hook writes into a signed auto-marker:
|
|
39
|
+
* `auto-mode:<harness>:<mode>`, for example `auto-mode:claude-code:bypassPermissions`
|
|
40
|
+
* or `auto-mode:codex:bypassPermissions` ("Audit and doctor" in the ADR).
|
|
41
|
+
* Neither `harness` nor `mode` is validated here; callers pass
|
|
42
|
+
* already-known-good values (one of the fixed harness constants above and
|
|
43
|
+
* a `when`-matched mode string).
|
|
44
|
+
*/
|
|
45
|
+
export function autoApprovedByFor(harness, mode) {
|
|
46
|
+
return `${AUTO_APPROVED_BY_PREFIX}${harness}:${mode}`;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Parse an `approvedBy` string back into its harness/mode pair. Returns
|
|
50
|
+
* `null` for anything that is not exactly `auto-mode:<harness>:<mode>`
|
|
51
|
+
* with both segments non-empty, including a human marker's `approvedBy`
|
|
52
|
+
* (which never carries this prefix) and a malformed or truncated auto
|
|
53
|
+
* value. A slice 3 delegation suffix (`;delegated:<parent-sid>`) is
|
|
54
|
+
* tolerated: it is stripped before parsing and otherwise ignored, per
|
|
55
|
+
* the ADR's "Audit and doctor" convention that the delegation binding
|
|
56
|
+
* packs into the same field without changing the harness/mode shape.
|
|
57
|
+
*/
|
|
58
|
+
export function parseAutoApprovedBy(approvedBy) {
|
|
59
|
+
if (typeof approvedBy !== "string")
|
|
60
|
+
return null;
|
|
61
|
+
if (!approvedBy.startsWith(AUTO_APPROVED_BY_PREFIX))
|
|
62
|
+
return null;
|
|
63
|
+
const withoutPrefix = approvedBy.slice(AUTO_APPROVED_BY_PREFIX.length);
|
|
64
|
+
const [withoutDelegation] = withoutPrefix.split(";delegated:");
|
|
65
|
+
const segments = (withoutDelegation ?? "").split(":");
|
|
66
|
+
if (segments.length !== 2)
|
|
67
|
+
return null;
|
|
68
|
+
const [harness, mode] = segments;
|
|
69
|
+
if (!harness || !mode)
|
|
70
|
+
return null;
|
|
71
|
+
return { harness, mode };
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Build the audit-only ledger fact the ADR's "Audit and doctor" section
|
|
75
|
+
* names: `understanding-auto-approved:<sid>`, distinct from the human
|
|
76
|
+
* `understanding-approved:<sid>` tag (`ledger.ts`), following the same
|
|
77
|
+
* `...:forced:<field>` suffix precedent the ADR cites. Ledger only, never
|
|
78
|
+
* consulted for the gate decision itself.
|
|
79
|
+
*/
|
|
80
|
+
export function autoApprovedLedgerTagFor(sessionId) {
|
|
81
|
+
return `understanding-auto-approved:${sessionId}`;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The harness identifiers `auto_approve.harnesses` accepts, in the order
|
|
85
|
+
* the schema and every diagnostic list them. Shared with the pack's zod
|
|
86
|
+
* `configSchema` (`../understanding-before-execution.ts`) so the lint-time
|
|
87
|
+
* enum and this runtime parser cannot drift apart.
|
|
88
|
+
*/
|
|
89
|
+
export const AUTO_APPROVE_HARNESS_VALUES = [CLAUDE_CODE_HARNESS, CODEX_HARNESS];
|
|
90
|
+
/**
|
|
91
|
+
* What `auto_approve.harnesses` resolves to when the key is ABSENT.
|
|
92
|
+
* Claude Code only, deliberately: slice 1 shipped `auto_approve` as a
|
|
93
|
+
* Claude-only opt-in, so a repo that opted in before slice 2 must keep
|
|
94
|
+
* exactly the meaning it had — adding the Codex hook to the shared body
|
|
95
|
+
* must not silently extend an existing opt-in to a second runtime
|
|
96
|
+
* (reviewer round-1 finding on slice 2). Opting Codex in is an explicit,
|
|
97
|
+
* visible config edit.
|
|
98
|
+
*/
|
|
99
|
+
export const DEFAULT_AUTO_APPROVE_HARNESSES = [CLAUDE_CODE_HARNESS];
|
|
100
|
+
const KNOWN_AUTO_APPROVE_KEYS = new Set(["when", "harnesses", "require_report"]);
|
|
101
|
+
/**
|
|
102
|
+
* Parse the optional `auto_approve` pack-config block
|
|
103
|
+
* (docs/decisions/2026-08-27-ug-auto-mode-approval.md, "Option A").
|
|
104
|
+
*
|
|
105
|
+
* FAIL CLOSED, unlike {@link parseApprovalLifecycle}'s best-effort
|
|
106
|
+
* fallback: this block is an opt-IN to a hook-side signing path
|
|
107
|
+
* (hardening item 3 in the ADR's threat model (b) — `require_report:
|
|
108
|
+
* false` must be a schema error, not a silently-ignored key), so any
|
|
109
|
+
* malformed shape here means "not opted in" (`null`), never a partial
|
|
110
|
+
* or default-filled config that could still enable the auto path. The
|
|
111
|
+
* `configSchema` zod block in `../understanding-before-execution.ts` is
|
|
112
|
+
* the first line of defence (`harness validate` / `harness doctor`
|
|
113
|
+
* reject a malformed manifest at lint time); this parser is the second,
|
|
114
|
+
* defensive line for the runtime hook, which must not trust that every
|
|
115
|
+
* config it sees on disk passed the schema.
|
|
116
|
+
*
|
|
117
|
+
* `undefined` / `null` (the block is simply absent) returns `null`
|
|
118
|
+
* silently — that is the ordinary "not opted in" case, not a warning.
|
|
119
|
+
* Every other malformed shape writes exactly one stderr line and
|
|
120
|
+
* returns `null`.
|
|
121
|
+
*
|
|
122
|
+
* `label` is the stderr prefix of the calling hook, so a Codex-side
|
|
123
|
+
* warning reads `harness pack hook codex: ...` like every other line
|
|
124
|
+
* that hook writes. The default reproduces the Claude Code hook's
|
|
125
|
+
* wording byte-for-byte.
|
|
126
|
+
*/
|
|
127
|
+
export function parseAutoApprove(raw, stderr, label = "harness pack hook") {
|
|
128
|
+
if (raw === undefined || raw === null)
|
|
129
|
+
return null;
|
|
130
|
+
if (typeof raw !== "object" || Array.isArray(raw)) {
|
|
131
|
+
stderr?.write(`${label}: config.auto_approve ignored (expected object, got ${typeof raw})\n`);
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
const obj = raw;
|
|
135
|
+
const unknownKeys = Object.keys(obj).filter((k) => !KNOWN_AUTO_APPROVE_KEYS.has(k));
|
|
136
|
+
if (unknownKeys.length > 0) {
|
|
137
|
+
stderr?.write(`${label}: config.auto_approve ignored (unknown key(s): ${unknownKeys.join(", ")})\n`);
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
const whenRaw = obj["when"];
|
|
141
|
+
if (!Array.isArray(whenRaw) || whenRaw.length === 0) {
|
|
142
|
+
stderr?.write(`${label}: config.auto_approve.when ignored (expected a non-empty string[], got ${Array.isArray(whenRaw) ? "empty array" : typeof whenRaw})\n`);
|
|
143
|
+
return null;
|
|
144
|
+
}
|
|
145
|
+
const when = [];
|
|
146
|
+
for (const v of whenRaw) {
|
|
147
|
+
if (typeof v !== "string" || v.length === 0) {
|
|
148
|
+
stderr?.write(`${label}: config.auto_approve.when ignored (every entry must be a non-empty string, got ${typeof v})\n`);
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
when.push(v);
|
|
152
|
+
}
|
|
153
|
+
// `harnesses`: absent means the slice-1 default (Claude Code only).
|
|
154
|
+
// Present means an exact, non-empty, duplicate-free list of the known
|
|
155
|
+
// harness identifiers — anything else fails the whole block closed,
|
|
156
|
+
// like every other malformed shape here, so a typo'd entry can never
|
|
157
|
+
// widen the opt-in to a runtime the operator did not name.
|
|
158
|
+
const harnessesRaw = obj["harnesses"];
|
|
159
|
+
let harnesses = [...DEFAULT_AUTO_APPROVE_HARNESSES];
|
|
160
|
+
if (harnessesRaw !== undefined) {
|
|
161
|
+
if (!Array.isArray(harnessesRaw) || harnessesRaw.length === 0) {
|
|
162
|
+
stderr?.write(`${label}: config.auto_approve.harnesses ignored (expected a non-empty array of ${AUTO_APPROVE_HARNESS_VALUES.join(" | ")}, got ${Array.isArray(harnessesRaw) ? "empty array" : typeof harnessesRaw})\n`);
|
|
163
|
+
return null;
|
|
164
|
+
}
|
|
165
|
+
const seen = [];
|
|
166
|
+
for (const v of harnessesRaw) {
|
|
167
|
+
if (typeof v !== "string" || !AUTO_APPROVE_HARNESS_VALUES.includes(v)) {
|
|
168
|
+
stderr?.write(`${label}: config.auto_approve.harnesses ignored (every entry must be one of ${AUTO_APPROVE_HARNESS_VALUES.join(", ")}, got ${typeof v === "string" ? `"${v}"` : typeof v})\n`);
|
|
169
|
+
return null;
|
|
170
|
+
}
|
|
171
|
+
if (seen.includes(v)) {
|
|
172
|
+
stderr?.write(`${label}: config.auto_approve.harnesses ignored (duplicate entry "${v}")\n`);
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
seen.push(v);
|
|
176
|
+
}
|
|
177
|
+
harnesses = seen;
|
|
178
|
+
}
|
|
179
|
+
const requireReport = obj["require_report"];
|
|
180
|
+
if (requireReport !== true) {
|
|
181
|
+
stderr?.write(`${label}: config.auto_approve ignored (require_report must be true, got ${requireReport === false ? "false" : typeof requireReport})\n`);
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
return { when, harnesses };
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* ADR "Additional hardening to specify" item 2: `when` is an allowlist
|
|
188
|
+
* of payload literals, membership by exact string equality, no case
|
|
189
|
+
* folding, no substring, no wildcards. `mode` absent, empty, or not a
|
|
190
|
+
* string means no auto-approval, and `cfg === null` (block absent or
|
|
191
|
+
* malformed) means no auto-approval regardless of `mode`.
|
|
192
|
+
*/
|
|
193
|
+
export function permissionModeAllowed(cfg, mode) {
|
|
194
|
+
if (cfg === null)
|
|
195
|
+
return false;
|
|
196
|
+
if (typeof mode !== "string" || mode.length === 0)
|
|
197
|
+
return false;
|
|
198
|
+
return cfg.when.includes(mode);
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Per-harness opt-in membership, the same exact-string-equality
|
|
202
|
+
* discipline {@link permissionModeAllowed} applies to `when`. `cfg ===
|
|
203
|
+
* null` (block absent or malformed) means no auto-approval regardless of
|
|
204
|
+
* the harness, and an unlisted harness means no auto-approval regardless
|
|
205
|
+
* of `when` — the two allowlists are independent AND conditions, not
|
|
206
|
+
* alternatives.
|
|
207
|
+
*
|
|
208
|
+
* Re-exported through `understanding-before-execution/index.ts` (round-2
|
|
209
|
+
* review finding on slice 2): its call site (`src/cli/pack/auto-approve-path.ts`)
|
|
210
|
+
* imports every sibling symbol it needs (`parseAutoApprove`,
|
|
211
|
+
* `permissionModeAllowed`, ...) through the runtime shim already, so this
|
|
212
|
+
* one was pulled onto the pinned shim surface
|
|
213
|
+
* (tests/policy-packs/ube-export-surface.test.ts) to match, unlike
|
|
214
|
+
* {@link CODEX_HARNESS} which still has exactly one consumer and stays a
|
|
215
|
+
* direct import.
|
|
216
|
+
*/
|
|
217
|
+
export function harnessAllowed(cfg, harness) {
|
|
218
|
+
if (cfg === null)
|
|
219
|
+
return false;
|
|
220
|
+
if (typeof harness !== "string" || harness.length === 0)
|
|
221
|
+
return false;
|
|
222
|
+
return cfg.harnesses.includes(harness);
|
|
223
|
+
}
|
|
224
|
+
//# sourceMappingURL=auto-approve.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-approve.js","sourceRoot":"","sources":["../../../../src/policy-packs/builtin/understanding-before-execution/auto-approve.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,sEAAsE;AACtE,oEAAoE;AACpE,2EAA2E;AAC3E,oEAAoE;AACpE,8DAA8D;AAC9D,8DAA8D;AAC9D,oEAAoE;AACpE,oEAAoE;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jC,CAAC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,cAAc,CAAC,GAA6B,EAAE,OAAgB;IAC5E,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,KAAK,CAAC;IAC/B,IAAI,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IACtE,OAAO,GAAG,CAAC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type ApprovalSource = "marker" | "ledger" | "
|
|
1
|
+
export type ApprovalSource = "marker" | "ledger" | "none" | "recovery-commit";
|
|
2
2
|
export interface ApprovalCheckResult {
|
|
3
3
|
approved: boolean;
|
|
4
4
|
source: ApprovalSource;
|
|
@@ -6,8 +6,9 @@ export interface ApprovalCheckResult {
|
|
|
6
6
|
}
|
|
7
7
|
export { APPROVED_LEDGER_TAG_PREFIX, approvedLedgerTagFor, isPolicyDecisionRow, matchLedgerEntries, } from "./ledger.js";
|
|
8
8
|
export { APPROVAL_MARKER_DIRNAME, approvalMarkerPathFor, type ApprovalMarker, writeApprovalMarker, type MarkerCheck, type CheckApprovalMarkerOptions, checkApprovalMarker, clearApprovalMarker, } from "./markers.js";
|
|
9
|
-
export { type PersistedReport, REPORTS_DIR_ENV, defaultReportsDir, reportsDirForManifest, listPersistedReports, TOLERANT_FALLBACK_MAX_AGE_MS, TOLERANT_FALLBACK_FUTURE_SKEW_MS, type FindReportOptions, type FindReportSelection, selectReportForSession, findLatestReportForSession, type
|
|
9
|
+
export { type PersistedReport, REPORTS_DIR_ENV, defaultReportsDir, reportsDirForManifest, listPersistedReports, TOLERANT_FALLBACK_MAX_AGE_MS, TOLERANT_FALLBACK_FUTURE_SKEW_MS, type FindReportOptions, type FindReportSelection, selectReportForSession, selectNewestStrictSessionReport, findLatestReportForSession, type PersistedReportEvidence, expirePersistedReport, checkPersistedReport, } from "./persisted-reports.js";
|
|
10
10
|
export { type ApprovalLifecycle, parseApprovalLifecycle } from "./lifecycle.js";
|
|
11
|
+
export { AUTO_APPROVED_BY_PREFIX, CLAUDE_CODE_HARNESS, autoApprovedByFor, type ParsedAutoApprovedBy, parseAutoApprovedBy, autoApprovedLedgerTagFor, type AutoApproveConfig, parseAutoApprove, permissionModeAllowed, harnessAllowed, AUTO_APPROVE_HARNESS_VALUES, DEFAULT_AUTO_APPROVE_HARNESSES, } from "./auto-approve.js";
|
|
11
12
|
export { APPROVAL_MARKER_TASK_PREFIX, taskApprovalMarkerPathFor, writeTaskApprovalMarker, checkActiveClaimApprovalMarker, type OperatorMarkerApproval, checkOperatorApprovalMarkers, clearTaskApprovalMarker, } from "./task-markers.js";
|
|
12
13
|
export { DEFAULT_BASH_TOOL_NAMES, toolNameMatchesAny, bashCommandMatchesAny, extractBashCommandFromToolInput, extractTaskIdFromToolInput, extractTasksTransitionStatusFromToolInput, type PostToolUseBoundaryMatch, matchPostToolUseBoundary, type ApplyPostToolUseExpiryResult, applyPostToolUseExpiry, describePostToolUseExpiry, } from "./post-tool-use-boundary.js";
|
|
13
14
|
export { ACTIVE_CLAIM_FILENAME, activeClaimPathFor, writeActiveClaim, readActiveClaim, clearActiveClaim, } from "./active-claim.js";
|
|
@@ -1,38 +1,45 @@
|
|
|
1
1
|
// Phase 6 #4 — runtime helpers for the understanding-before-execution pack.
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
3
|
+
// Single-authority approval check that the harness-side PreToolUse
|
|
4
|
+
// blockers (Claude and Codex) consult, plus two evidence-only probes:
|
|
5
5
|
//
|
|
6
|
-
//
|
|
7
|
-
// by `harness approve understanding` from
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
//
|
|
12
|
-
//
|
|
13
|
-
//
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
// (
|
|
21
|
-
//
|
|
22
|
-
// `
|
|
23
|
-
//
|
|
24
|
-
//
|
|
25
|
-
//
|
|
26
|
-
//
|
|
6
|
+
// AUTHORITY. Filesystem marker `<generatedDir>/.approvals/<sessionId>`
|
|
7
|
+
// (or `task-<id>`) written by `harness approve understanding` from
|
|
8
|
+
// the operator's shell and HMAC-signed with the operator-side key
|
|
9
|
+
// (harness/f9485cc7). Replaces the ledger-substring check that
|
|
10
|
+
// shipped through v0.13.0 (agent-tasks/88ca4bb3): the agent has
|
|
11
|
+
// direct MCP access to the same ledger that gate path consulted, so
|
|
12
|
+
// any agent could write `understanding-approved:<sid>` itself and
|
|
13
|
+
// self-approve. Edit / Write / Bash are all gated by this same
|
|
14
|
+
// PreToolUse hook, and the configured MCP servers do not expose
|
|
15
|
+
// filesystem writes, so the marker file is reachable only from a
|
|
16
|
+
// process the operator launched; the signature is what keeps that
|
|
17
|
+
// true even if a future write primitive the blocker matcher does
|
|
18
|
+
// not cover appears. Operator-side: writeApprovalMarker below.
|
|
19
|
+
// EVIDENCE. Persisted JSON report under `.understanding-gate/reports/`
|
|
20
|
+
// (owned by `@lannguyensi/understanding-gate`). Flipped to
|
|
21
|
+
// `approved` by the same `harness approve understanding` call and to
|
|
22
|
+
// `expired` by the post-tool-use boundary hook, so the audit record
|
|
23
|
+
// tracks the marker. Until task 7402301d this was a SECOND, equal
|
|
24
|
+
// approval source, and it was unsigned: under the very threat model
|
|
25
|
+
// that motivated marker signing, one unsigned JSON write into the
|
|
26
|
+
// reports directory forged an approval with less effort than the
|
|
27
|
+
// old marker forgery (no session id, no key read). Gate-time
|
|
28
|
+
// approval authority now flows only through the signed marker; the
|
|
29
|
+
// report is consulted for the block diagnostic only
|
|
30
|
+
// (`checkPersistedReport` returns evidence, never an approval).
|
|
31
|
+
// EVIDENCE. The evidence-ledger row `understanding-approved:<sid>`,
|
|
32
|
+
// still written by `harness approve understanding` for forensics.
|
|
27
33
|
//
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
//
|
|
34
|
+
// Consequence for solo `@lannguyensi/understanding-gate` users running
|
|
35
|
+
// under harness: the package's own `understanding-gate approve` flips
|
|
36
|
+
// the report but writes no signed marker, so it no longer opens the
|
|
37
|
+
// harness gate; `harness approve understanding` is the approval path.
|
|
32
38
|
export { APPROVED_LEDGER_TAG_PREFIX, approvedLedgerTagFor, isPolicyDecisionRow, matchLedgerEntries, } from "./ledger.js";
|
|
33
39
|
export { APPROVAL_MARKER_DIRNAME, approvalMarkerPathFor, writeApprovalMarker, checkApprovalMarker, clearApprovalMarker, } from "./markers.js";
|
|
34
|
-
export { REPORTS_DIR_ENV, defaultReportsDir, reportsDirForManifest, listPersistedReports, TOLERANT_FALLBACK_MAX_AGE_MS, TOLERANT_FALLBACK_FUTURE_SKEW_MS, selectReportForSession, findLatestReportForSession, expirePersistedReport, checkPersistedReport, } from "./persisted-reports.js";
|
|
40
|
+
export { REPORTS_DIR_ENV, defaultReportsDir, reportsDirForManifest, listPersistedReports, TOLERANT_FALLBACK_MAX_AGE_MS, TOLERANT_FALLBACK_FUTURE_SKEW_MS, selectReportForSession, selectNewestStrictSessionReport, findLatestReportForSession, expirePersistedReport, checkPersistedReport, } from "./persisted-reports.js";
|
|
35
41
|
export { parseApprovalLifecycle } from "./lifecycle.js";
|
|
42
|
+
export { AUTO_APPROVED_BY_PREFIX, CLAUDE_CODE_HARNESS, autoApprovedByFor, parseAutoApprovedBy, autoApprovedLedgerTagFor, parseAutoApprove, permissionModeAllowed, harnessAllowed, AUTO_APPROVE_HARNESS_VALUES, DEFAULT_AUTO_APPROVE_HARNESSES, } from "./auto-approve.js";
|
|
36
43
|
export { APPROVAL_MARKER_TASK_PREFIX, taskApprovalMarkerPathFor, writeTaskApprovalMarker, checkActiveClaimApprovalMarker, checkOperatorApprovalMarkers, clearTaskApprovalMarker, } from "./task-markers.js";
|
|
37
44
|
export { DEFAULT_BASH_TOOL_NAMES, toolNameMatchesAny, bashCommandMatchesAny, extractBashCommandFromToolInput, extractTaskIdFromToolInput, extractTasksTransitionStatusFromToolInput, matchPostToolUseBoundary, applyPostToolUseExpiry, describePostToolUseExpiry, } from "./post-tool-use-boundary.js";
|
|
38
45
|
export { ACTIVE_CLAIM_FILENAME, activeClaimPathFor, writeActiveClaim, readActiveClaim, clearActiveClaim, } from "./active-claim.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/policy-packs/builtin/understanding-before-execution/index.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,EAAE;AACF,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/policy-packs/builtin/understanding-before-execution/index.ts"],"names":[],"mappings":"AAAA,4EAA4E;AAC5E,EAAE;AACF,mEAAmE;AACnE,sEAAsE;AACtE,EAAE;AACF,yEAAyE;AACzE,wEAAwE;AACxE,uEAAuE;AACvE,oEAAoE;AACpE,qEAAqE;AACrE,yEAAyE;AACzE,uEAAuE;AACvE,oEAAoE;AACpE,qEAAqE;AACrE,sEAAsE;AACtE,uEAAuE;AACvE,sEAAsE;AACtE,oEAAoE;AACpE,yEAAyE;AACzE,gEAAgE;AAChE,0EAA0E;AAC1E,yEAAyE;AACzE,uEAAuE;AACvE,yEAAyE;AACzE,uEAAuE;AACvE,sEAAsE;AACtE,kEAAkE;AAClE,wEAAwE;AACxE,yDAAyD;AACzD,qEAAqE;AACrE,sEAAsE;AACtE,uEAAuE;AACvE,EAAE;AACF,uEAAuE;AACvE,sEAAsE;AACtE,oEAAoE;AACpE,sEAAsE;AActE,OAAO,EACL,0BAA0B,EAC1B,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,aAAa,CAAC;AAErB,OAAO,EACL,uBAAuB,EACvB,qBAAqB,EAErB,mBAAmB,EAGnB,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAEL,eAAe,EACf,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,4BAA4B,EAC5B,gCAAgC,EAGhC,sBAAsB,EACtB,+BAA+B,EAC/B,0BAA0B,EAE1B,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,wBAAwB,CAAC;AAEhC,OAAO,EAA0B,sBAAsB,EAAE,MAAM,gBAAgB,CAAC;AAEhF,OAAO,EACL,uBAAuB,EACvB,mBAAmB,EACnB,iBAAiB,EAEjB,mBAAmB,EACnB,wBAAwB,EAExB,gBAAgB,EAChB,qBAAqB,EACrB,cAAc,EACd,2BAA2B,EAC3B,8BAA8B,GAC/B,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,2BAA2B,EAC3B,yBAAyB,EACzB,uBAAuB,EACvB,8BAA8B,EAE9B,4BAA4B,EAC5B,uBAAuB,GACxB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EACL,uBAAuB,EACvB,kBAAkB,EAClB,qBAAqB,EACrB,+BAA+B,EAC/B,0BAA0B,EAC1B,yCAAyC,EAEzC,wBAAwB,EAExB,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,gBAAgB,EAChB,eAAe,EACf,gBAAgB,GACjB,MAAM,mBAAmB,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// Session-scoped approval marker file (filesystem source
|
|
2
|
-
//
|
|
1
|
+
// Session-scoped approval marker file (the signed filesystem source that
|
|
2
|
+
// is the gate's only approval authority), split out of the former monolithic
|
|
3
3
|
// understanding-before-execution-runtime.ts (structural concentration
|
|
4
4
|
// slice 2, agent-tasks 348a4d42). Pure move: see
|
|
5
5
|
// src/policy-packs/builtin/understanding-before-execution/index.ts for
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markers.js","sourceRoot":"","sources":["../../../../src/policy-packs/builtin/understanding-before-execution/markers.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"markers.js","sourceRoot":"","sources":["../../../../src/policy-packs/builtin/understanding-before-execution/markers.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,6EAA6E;AAC7E,sEAAsE;AACtE,iDAAiD;AACjD,uEAAuE;AACvE,kCAAkC;AAElC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,+BAA+B,EAAE,MAAM,kCAAkC,CAAC;AACnF,OAAO,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AACzF,OAAO,EAAE,wBAAwB,EAAE,MAAM,iDAAiD,CAAC;AAC3F,OAAO,EAAE,aAAa,EAAE,MAAM,gCAAgC,CAAC;AAE/D,MAAM,CAAC,MAAM,uBAAuB,GAAG,YAAY,CAAC;AAEpD,0DAA0D;AAC1D,MAAM,UAAU,qBAAqB,CAAC,YAAoB,EAAE,SAAiB;IAC3E,wBAAwB,CAAC,SAAS,CAAC,CAAC;IACpC,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,uBAAuB,EAAE,SAAS,CAAC,CAAC;AACrE,CAAC;AAeD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,mBAAmB,CACjC,YAAoB,EACpB,SAAiB,EACjB,MAAsB;IAEtB,MAAM,QAAQ,GAAG,qBAAqB,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;IAChE,MAAM,MAAM,GAAG,UAAU,CAAC,YAAY,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC;IAC3D,eAAe,CAAC,QAAQ,EAAE,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACnF,OAAO,QAAQ,CAAC;AAClB,C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AAC,QAAQ,CAAC,iBAAiB,MAAM,WAAW,MAAM,kBAAkB,UAAU,GAAG;oBACzH,MAAM;oBACN,OAAO,EAAE,IAAI;oBACb,MAAM,EAAE,KAAK;iBACd,CAAC;YACJ,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO;QACL,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,uBAAuB,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,iBAAiB,UAAU,OAAO,UAAU,sBAAsB;QACxH,MAAM;QACN,OAAO,EAAE,KAAK;QACd,MAAM,EAAE,KAAK;KACd,CAAC;AACJ,CAAC;AAED,mFAAmF;AACnF,MAAM,UAAU,mBAAmB,CAAC,YAAoB,EAAE,SAAiB;IACzE,IAAI,CAAC;QACH,EAAE,CAAC,MAAM,CAAC,qBAAqB,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC,CAAC;IAC5D,CAAC;IAAC,MAAM,CAAC;QACP,kBAAkB;IACpB,CAAC;AACH,CAAC"}
|
package/dist/policy-packs/builtin/understanding-before-execution/measured-permission-modes.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export type MeasuredHarness = "claude-code" | "codex";
|
|
2
|
+
export interface MeasuredPermissionMode {
|
|
3
|
+
readonly harness: MeasuredHarness;
|
|
4
|
+
readonly permissionMode: string;
|
|
5
|
+
/** Repo-relative path under dogfood/ug-auto-mode-signals/payloads/. */
|
|
6
|
+
readonly fixture: string;
|
|
7
|
+
}
|
|
8
|
+
/** Repo-relative directory every registry fixture must live in. */
|
|
9
|
+
export declare const MEASURED_FIXTURES_DIR = "dogfood/ug-auto-mode-signals/payloads";
|
|
10
|
+
/**
|
|
11
|
+
* Which harness a fixture file under {@link MEASURED_FIXTURES_DIR} was
|
|
12
|
+
* captured from, by file-name convention: `codex-*` is Codex, anything
|
|
13
|
+
* else is Claude Code. Shared with the sync test so the convention has
|
|
14
|
+
* one definition.
|
|
15
|
+
*/
|
|
16
|
+
export declare function harnessForFixtureFile(basename: string): MeasuredHarness;
|
|
17
|
+
export declare const MEASURED_PERMISSION_MODES: ReadonlyArray<MeasuredPermissionMode>;
|
|
18
|
+
/**
|
|
19
|
+
* True when the given HARNESS has a measured fixture for this exact
|
|
20
|
+
* literal. `auto_approve.harnesses` (docs/decisions/2026-08-27-ug-auto-mode-approval.md,
|
|
21
|
+
* Slice 2) scopes which harnesses' PreToolUse hooks may take the auto
|
|
22
|
+
* path at all, so "measured" is checked per listed harness, not across
|
|
23
|
+
* the whole registry: a literal measured only for Claude Code is not
|
|
24
|
+
* evidence that Codex ever emits it. Exact string equality: no case
|
|
25
|
+
* folding, no wildcards.
|
|
26
|
+
*/
|
|
27
|
+
export declare function isMeasuredPermissionModeFor(literal: string, harness: MeasuredHarness): boolean;
|
|
28
|
+
/** Sorted, de-duplicated list of every literal measured for HARNESS. */
|
|
29
|
+
export declare function measuredPermissionModeLiteralsFor(harness: MeasuredHarness): string[];
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
// Registry of measured `permission_mode` literals for the
|
|
2
|
+
// `auto_approve.when` allowlist (docs/decisions/2026-08-27-ug-auto-mode-approval.md,
|
|
3
|
+
// Slice 2 AC 3, "Option A").
|
|
4
|
+
//
|
|
5
|
+
// RULE: an entry is added here ONLY together with a checked-in dogfood
|
|
6
|
+
// fixture (under `dogfood/ug-auto-mode-signals/payloads/`) that shows the
|
|
7
|
+
// named harness actually emitting that exact `permission_mode` string on a
|
|
8
|
+
// `PreToolUse` hook payload. `tests/policy-packs/measured-permission-modes-sync.test.ts`
|
|
9
|
+
// enforces both directions: every entry here must be backed by a fixture
|
|
10
|
+
// that carries the claimed value, and every `permission_mode` value found
|
|
11
|
+
// in any `*.PreToolUse.json` fixture must be registered for its harness.
|
|
12
|
+
// Do not add a literal "because it seems plausible": capture a fixture
|
|
13
|
+
// first, then register it.
|
|
14
|
+
//
|
|
15
|
+
// A fixture's harness is bound by its file name: `codex-*` fixtures are
|
|
16
|
+
// Codex captures, every other `*.PreToolUse.json` under the payloads
|
|
17
|
+
// directory is a Claude Code capture (`harnessForFixtureFile`). The sync
|
|
18
|
+
// test checks each entry's fixture name against the entry's `harness`, so
|
|
19
|
+
// a Claude Code fixture cannot back a Codex claim or vice versa.
|
|
20
|
+
//
|
|
21
|
+
// `harness validate` runs in the OPERATOR's repo, which has no `dogfood/`
|
|
22
|
+
// directory, so this registry ships inside the package as a constant
|
|
23
|
+
// (`checkUnderstandingBeforeExecutionAutoApproveMeasured` in
|
|
24
|
+
// `src/cli/validate/checks.ts` consults it without touching the
|
|
25
|
+
// filesystem); the sync test above is what keeps it honest against the
|
|
26
|
+
// fixtures in THIS repo.
|
|
27
|
+
/** Repo-relative directory every registry fixture must live in. */
|
|
28
|
+
export const MEASURED_FIXTURES_DIR = "dogfood/ug-auto-mode-signals/payloads";
|
|
29
|
+
const PAYLOADS_DIR = MEASURED_FIXTURES_DIR;
|
|
30
|
+
/**
|
|
31
|
+
* Which harness a fixture file under {@link MEASURED_FIXTURES_DIR} was
|
|
32
|
+
* captured from, by file-name convention: `codex-*` is Codex, anything
|
|
33
|
+
* else is Claude Code. Shared with the sync test so the convention has
|
|
34
|
+
* one definition.
|
|
35
|
+
*/
|
|
36
|
+
export function harnessForFixtureFile(basename) {
|
|
37
|
+
return basename.startsWith("codex-") ? "codex" : "claude-code";
|
|
38
|
+
}
|
|
39
|
+
export const MEASURED_PERMISSION_MODES = [
|
|
40
|
+
{
|
|
41
|
+
harness: "claude-code",
|
|
42
|
+
permissionMode: "default",
|
|
43
|
+
fixture: `${PAYLOADS_DIR}/claude-p-default.PreToolUse.json`,
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
harness: "claude-code",
|
|
47
|
+
permissionMode: "acceptEdits",
|
|
48
|
+
fixture: `${PAYLOADS_DIR}/claude-p-acceptedits.PreToolUse.json`,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
harness: "claude-code",
|
|
52
|
+
permissionMode: "bypassPermissions",
|
|
53
|
+
fixture: `${PAYLOADS_DIR}/claude-p-bypass.PreToolUse.json`,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
harness: "codex",
|
|
57
|
+
permissionMode: "bypassPermissions",
|
|
58
|
+
fixture: `${PAYLOADS_DIR}/codex-exec-default.PreToolUse.json`,
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
harness: "codex",
|
|
62
|
+
permissionMode: "default",
|
|
63
|
+
fixture: `${PAYLOADS_DIR}/codex-tui-default.PreToolUse.json`,
|
|
64
|
+
},
|
|
65
|
+
];
|
|
66
|
+
/**
|
|
67
|
+
* True when the given HARNESS has a measured fixture for this exact
|
|
68
|
+
* literal. `auto_approve.harnesses` (docs/decisions/2026-08-27-ug-auto-mode-approval.md,
|
|
69
|
+
* Slice 2) scopes which harnesses' PreToolUse hooks may take the auto
|
|
70
|
+
* path at all, so "measured" is checked per listed harness, not across
|
|
71
|
+
* the whole registry: a literal measured only for Claude Code is not
|
|
72
|
+
* evidence that Codex ever emits it. Exact string equality: no case
|
|
73
|
+
* folding, no wildcards.
|
|
74
|
+
*/
|
|
75
|
+
export function isMeasuredPermissionModeFor(literal, harness) {
|
|
76
|
+
return MEASURED_PERMISSION_MODES.some((entry) => entry.harness === harness && entry.permissionMode === literal);
|
|
77
|
+
}
|
|
78
|
+
/** Sorted, de-duplicated list of every literal measured for HARNESS. */
|
|
79
|
+
export function measuredPermissionModeLiteralsFor(harness) {
|
|
80
|
+
return Array.from(new Set(MEASURED_PERMISSION_MODES.filter((entry) => entry.harness === harness).map((entry) => entry.permissionMode))).sort();
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=measured-permission-modes.js.map
|