@lannguyensi/harness 0.51.0 → 0.52.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 +139 -0
- package/dist/cli/approve/understanding.d.ts +46 -0
- package/dist/cli/approve/understanding.js +50 -22
- package/dist/cli/approve/understanding.js.map +1 -1
- package/dist/cli/audit.d.ts +29 -0
- package/dist/cli/audit.js +130 -17
- package/dist/cli/audit.js.map +1 -1
- package/dist/cli/delegate/index.d.ts +63 -0
- package/dist/cli/delegate/index.js +313 -0
- package/dist/cli/delegate/index.js.map +1 -0
- package/dist/cli/doctor/auto-approve-mode.d.ts +37 -0
- package/dist/cli/doctor/auto-approve-mode.js +80 -0
- package/dist/cli/doctor/auto-approve-mode.js.map +1 -0
- package/dist/cli/doctor/codex-config-drift.d.ts +28 -0
- package/dist/cli/doctor/codex-config-drift.js +240 -0
- package/dist/cli/doctor/codex-config-drift.js.map +1 -0
- package/dist/cli/doctor/format.js +32 -1
- package/dist/cli/doctor/format.js.map +1 -1
- package/dist/cli/doctor/index.js +51 -7
- package/dist/cli/doctor/index.js.map +1 -1
- package/dist/cli/doctor/settings-drift.d.ts +6 -0
- package/dist/cli/doctor/settings-drift.js +20 -6
- package/dist/cli/doctor/settings-drift.js.map +1 -1
- package/dist/cli/doctor/types.d.ts +43 -0
- package/dist/cli/doctor/types.js.map +1 -1
- package/dist/cli/doctor/ug-delegations.d.ts +26 -0
- package/dist/cli/doctor/ug-delegations.js +112 -0
- package/dist/cli/doctor/ug-delegations.js.map +1 -0
- package/dist/cli/doctor/understanding-mode-env.d.ts +2 -0
- package/dist/cli/doctor/understanding-mode-env.js +5 -2
- package/dist/cli/doctor/understanding-mode-env.js.map +1 -1
- package/dist/cli/index.js +89 -1
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/pack/approve-escape.js +16 -7
- package/dist/cli/pack/approve-escape.js.map +1 -1
- package/dist/cli/pack/auto-approve-path.d.ts +17 -0
- package/dist/cli/pack/auto-approve-path.js +56 -3
- package/dist/cli/pack/auto-approve-path.js.map +1 -1
- package/dist/cli/pack/hook-pre-tool-use.d.ts +25 -0
- package/dist/cli/pack/hook-pre-tool-use.js +336 -3
- package/dist/cli/pack/hook-pre-tool-use.js.map +1 -1
- package/dist/cli/pack/transcript-report-scan.d.ts +71 -0
- package/dist/cli/pack/transcript-report-scan.js +359 -0
- package/dist/cli/pack/transcript-report-scan.js.map +1 -0
- package/dist/cli/smoke/index.d.ts +18 -1
- package/dist/cli/smoke/index.js +54 -0
- package/dist/cli/smoke/index.js.map +1 -1
- package/dist/policy-packs/builtin/understanding-before-execution/auto-approve.d.ts +76 -2
- package/dist/policy-packs/builtin/understanding-before-execution/auto-approve.js +139 -2
- package/dist/policy-packs/builtin/understanding-before-execution/auto-approve.js.map +1 -1
- package/dist/policy-packs/builtin/understanding-before-execution/delegation-markers.d.ts +223 -0
- package/dist/policy-packs/builtin/understanding-before-execution/delegation-markers.js +633 -0
- package/dist/policy-packs/builtin/understanding-before-execution/delegation-markers.js.map +1 -0
- package/dist/policy-packs/builtin/understanding-before-execution/index.d.ts +2 -1
- package/dist/policy-packs/builtin/understanding-before-execution/index.js +9 -1
- package/dist/policy-packs/builtin/understanding-before-execution/index.js.map +1 -1
- package/dist/policy-packs/builtin/understanding-before-execution.d.ts +19 -0
- package/dist/policy-packs/builtin/understanding-before-execution.js +29 -0
- package/dist/policy-packs/builtin/understanding-before-execution.js.map +1 -1
- package/dist/runtime/approval-signing.js +28 -0
- package/dist/runtime/approval-signing.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/audit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../../src/cli/audit.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,gBAAgB,GAGjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,eAAe,EACf,mBAAmB,GAEpB,M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AC,EAAE,EAAE,CAAC,oBAAoB,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,QAAQ,CACrD,CAAC;IACJ,CAAC;IAED,MAAM,aAAa,GACjB,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,mCAAmC,KAAK,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IAC/F,yEAAyE;IACzE,sEAAsE;IACtE,oCAAoC;IACpC,MAAM,aAAa,GACjB,oBAAoB,KAAK,SAAS;QAChC,CAAC,CAAC,4BAA4B,oBAAoB,IAAI;QACtD,CAAC,CAAC,SAAS,CAAC,MAAM,KAAK,CAAC;YACtB,CAAC,CAAC,EAAE;YACJ,CAAC,CAAC,gBAAgB,eAAe,CAAC,SAAS,CAAC,EAAE,CAAC;IAErD,MAAM,MAAM,GAAG,IAAI,CAAC,IAAI;QACtB,CAAC,CAAC,GAAG,IAAI,CAAC,SAAS,CACf;YACE,SAAS;YACT,SAAS,EAAE,QAAQ;YACnB,SAAS;YACT,GAAG,CAAC,oBAAoB,KAAK,SAAS,IAAI,EAAE,oBAAoB,EAAE,CAAC;SACpE,EACD,IAAI,EACJ,CAAC,CACF,IAAI;QACP,CAAC,CAAC,GAAG,aAAa,GAAG,aAAa,EAAE,CAAC;IACvC,OAAO;QACL,MAAM;QACN,SAAS,EAAE,QAAQ;QACnB,SAAS;QACT,GAAG,CAAC,oBAAoB,KAAK,SAAS,IAAI,EAAE,oBAAoB,EAAE,CAAC;KACpE,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { Manifest } from "../../schema/index.js";
|
|
2
|
+
import { type LoaderOptions } from "../loader.js";
|
|
3
|
+
/** Default delegation lifetime when neither `--ttl` nor the pack's `approval_lifecycle.max_age` is set (ADR "TTL, cwd, and subagents"). */
|
|
4
|
+
export declare const DEFAULT_DELEGATION_TTL_SECONDS = 3600;
|
|
5
|
+
/** Default ledger `source` tag for the audit-only fact this verb writes (ADR "Audit and doctor"). */
|
|
6
|
+
export declare const DEFAULT_DELEGATE_LEDGER_SOURCE = "harness-delegate-cli";
|
|
7
|
+
/** Ceiling for an explicit `--ttl` when the applied pack sets no `approval_lifecycle.max_age` (L4 fix, agent-tasks 37ad0b05: an unbounded `--ttl` would otherwise let a caller mint a delegation that outlives any lifetime the pack's own policy intends). */
|
|
8
|
+
export declare const MAX_DELEGATION_TTL_SECONDS: number;
|
|
9
|
+
/** The exact usage message the ADR pins for a delegation with no binding (AC 1). Shared so the CLI's early usage check and this function's own refusal read identically. */
|
|
10
|
+
export declare const NO_BINDING_MESSAGE = "a delegation must bind a cwd or a task";
|
|
11
|
+
export interface IssueDelegationOptions extends LoaderOptions {
|
|
12
|
+
/** Session id of the `claude -p` child this delegation authorizes. Must be a UUID (case-insensitive). */
|
|
13
|
+
childSessionId: string;
|
|
14
|
+
/** Bind the delegation to this working directory. At least one of `cwd` / `taskId` is required. */
|
|
15
|
+
cwd?: string;
|
|
16
|
+
/** Bind the delegation to this agent-tasks task id. At least one of `cwd` / `taskId` is required. */
|
|
17
|
+
taskId?: string;
|
|
18
|
+
/** Delegation lifetime in seconds (already parsed, e.g. via `parseDurationSeconds`). Default: the applied pack's `approval_lifecycle.max_age` when set, else {@link DEFAULT_DELEGATION_TTL_SECONDS}. */
|
|
19
|
+
ttlSeconds?: number;
|
|
20
|
+
/** Fallback shape: path to the launcher-supplied Understanding Report file, bound by content AND path hash. */
|
|
21
|
+
reportPath?: string;
|
|
22
|
+
/** Explicit parent session id. Resolved exactly like `harness approve understanding` (flag > env > `.pending-approval`; no newest-report fallback) when omitted. */
|
|
23
|
+
parentSessionId?: string;
|
|
24
|
+
/** Override `harness.generated/` (test injection). */
|
|
25
|
+
generatedDir?: string;
|
|
26
|
+
/** Override "now" for deterministic tests. */
|
|
27
|
+
now?: Date;
|
|
28
|
+
/** Inject a manifest (test). */
|
|
29
|
+
manifest?: Manifest;
|
|
30
|
+
/** Override the ledger writer (test). */
|
|
31
|
+
ledgerAdd?: (sessionId: string, content: string) => Promise<{
|
|
32
|
+
ok: true;
|
|
33
|
+
} | {
|
|
34
|
+
ok: false;
|
|
35
|
+
reason: string;
|
|
36
|
+
}>;
|
|
37
|
+
}
|
|
38
|
+
export type IssueDelegationRefusalReason = "invalid-child-session" | "no-binding" | "invalid-cwd" | "invalid-task" | "invalid-ttl" | "ttl-above-max-age" | "parent-session-unresolved" | "parent-marker-missing" | "parent-marker-forged" | "parent-marker-expired" | "signing-key-absent" | "report-unreadable" | "invalid-input" | "write-failed";
|
|
39
|
+
export type IssueDelegationResult = {
|
|
40
|
+
ok: true;
|
|
41
|
+
filePath: string;
|
|
42
|
+
parentSessionId: string;
|
|
43
|
+
childSessionId: string;
|
|
44
|
+
expiresAt: string;
|
|
45
|
+
/** `written: false` is audit-only degradation (ADR: "failure to write the fact is one stderr line, never a refusal"); the delegation itself is still minted. */
|
|
46
|
+
ledgerFact: {
|
|
47
|
+
written: boolean;
|
|
48
|
+
reason?: string;
|
|
49
|
+
};
|
|
50
|
+
} | {
|
|
51
|
+
ok: false;
|
|
52
|
+
reason: IssueDelegationRefusalReason;
|
|
53
|
+
detail: string;
|
|
54
|
+
};
|
|
55
|
+
/** The `understanding-delegated:<child-sid>:<parent-sid>` ledger fact content (ADR "Audit and doctor"). */
|
|
56
|
+
export declare function delegationLedgerFactFor(childSessionId: string, parentSessionId: string): string;
|
|
57
|
+
/**
|
|
58
|
+
* Issue a signed delegation marker for a `claude -p` child session. Never
|
|
59
|
+
* calls `process.exit`; every failure mode is a `{ ok: false }` result
|
|
60
|
+
* with a distinct `reason` (ADR slice plan format rule: every refusal is
|
|
61
|
+
* a block with a distinct diagnostic, never a fall-through to allow).
|
|
62
|
+
*/
|
|
63
|
+
export declare function issueDelegation(opts: IssueDelegationOptions): Promise<IssueDelegationResult>;
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
// `harness delegate`: slice 3 of docs/decisions/2026-08-27-ug-auto-mode-approval.md
|
|
2
|
+
// ("`claude -p` child processes", "Delegation marker shape", "TTL, cwd,
|
|
3
|
+
// and subagents"), acceptance criterion 1.
|
|
4
|
+
//
|
|
5
|
+
// Issues a signed delegation for a headless `claude -p` child session,
|
|
6
|
+
// bound to an already-approved PARENT session. The delegation is a
|
|
7
|
+
// PRE-AUTHORIZATION, not an approval (key one of the ADR's two-key
|
|
8
|
+
// design): it supplies the trusted signal and the parent linkage; the
|
|
9
|
+
// child's own Understanding Report (key two) is still checked, and its
|
|
10
|
+
// auto-marker still minted, by the child's own PreToolUse hook: nothing
|
|
11
|
+
// here opens a gate.
|
|
12
|
+
//
|
|
13
|
+
// `issueDelegation` is an in-process function, never calling
|
|
14
|
+
// `process.exit`, so the smoke runner (a future consumer, ADR "TTL, cwd,
|
|
15
|
+
// and subagents": "The harness smoke runner ... is the natural first
|
|
16
|
+
// consumer") and tests can call it directly. The CLI wiring in
|
|
17
|
+
// `src/cli/index.ts` is a thin wrapper: flag parsing, one CLI-level
|
|
18
|
+
// usage check with the exact ADR-specified message, and printing the
|
|
19
|
+
// result in the approve CLI's line style.
|
|
20
|
+
//
|
|
21
|
+
// PARENT SESSION RESOLUTION mirrors `harness approve understanding`
|
|
22
|
+
// exactly (flag > $CLAUDE_CODE_SESSION_ID > $CLAUDE_SESSION_ID >
|
|
23
|
+
// $CODEX_SESSION_ID > staged .pending-approval), via the same
|
|
24
|
+
// `resolveApprovalSessionId` helper, with NO newest-report fallback
|
|
25
|
+
// (delegation has no report of its own to guess a session from).
|
|
26
|
+
//
|
|
27
|
+
// LEDGER SOURCE: the ledger fact this verb writes uses its own fixed
|
|
28
|
+
// source tag `harness-delegate-cli` (ADR "Audit and doctor"), distinct
|
|
29
|
+
// from `harness approve understanding`'s `harness-approve-understanding`.
|
|
30
|
+
// Reused directly: the approve CLI's `writeLedgerTag` now takes `source`
|
|
31
|
+
// as an additive parameter (default unchanged, so `approveUnderstanding`'s
|
|
32
|
+
// own call is unaffected) so this verb does not re-implement the same
|
|
33
|
+
// findGroundingMcp + addLedgerFact shape `branch-protection.ts` already
|
|
34
|
+
// carries its own independent copy of. There is no actor field to stamp
|
|
35
|
+
// on a delegation and no `--approved-by` flag to override the source:
|
|
36
|
+
// the delegation's signed `approvedBy` string is the packed
|
|
37
|
+
// `delegated:<parent>;cwd=...;task=...;expires=...` tuple
|
|
38
|
+
// (delegation-markers.ts), which has no room for one, and the ADR rules
|
|
39
|
+
// out adding a new signed field (a `SIGNING_ALG` bump).
|
|
40
|
+
//
|
|
41
|
+
// REPORT FALLBACK (`--report <path>`): binds the launcher-supplied
|
|
42
|
+
// report by BOTH its content (`reportContentHash`) and its path
|
|
43
|
+
// (`reportPathHash`, via the same `hashDelegationCwd` the cwd binding
|
|
44
|
+
// uses, so both sides of the delegation hash paths the same way).
|
|
45
|
+
import { sha256Hex, signingKeyExists, signingKeyPathFor } from "../../runtime/approval-signing.js";
|
|
46
|
+
import { resolveGeneratedDir } from "../../runtime/pending-approval.js";
|
|
47
|
+
import { resolveApprovalSessionId } from "../../runtime/session-id.js";
|
|
48
|
+
import { checkApprovalMarker, hashDelegationCwd, parseApprovalLifecycle, writeDelegationMarker, } from "../../policy-packs/builtin/understanding-before-execution-runtime.js";
|
|
49
|
+
import { readRegularFileRejectingSymlink } from "../../io/read-regular-file.js";
|
|
50
|
+
import { loadDeclaredUnderstandingPack, writeLedgerTag } from "../approve/understanding.js";
|
|
51
|
+
import { resolvePaths } from "../loader.js";
|
|
52
|
+
/** Default delegation lifetime when neither `--ttl` nor the pack's `approval_lifecycle.max_age` is set (ADR "TTL, cwd, and subagents"). */
|
|
53
|
+
export const DEFAULT_DELEGATION_TTL_SECONDS = 3600;
|
|
54
|
+
/** Default ledger `source` tag for the audit-only fact this verb writes (ADR "Audit and doctor"). */
|
|
55
|
+
export const DEFAULT_DELEGATE_LEDGER_SOURCE = "harness-delegate-cli";
|
|
56
|
+
/** Ceiling for an explicit `--ttl` when the applied pack sets no `approval_lifecycle.max_age` (L4 fix, agent-tasks 37ad0b05: an unbounded `--ttl` would otherwise let a caller mint a delegation that outlives any lifetime the pack's own policy intends). */
|
|
57
|
+
export const MAX_DELEGATION_TTL_SECONDS = 24 * 60 * 60;
|
|
58
|
+
/** Same 8-4-4-4-12 hex shape the session-id helpers already validate a Claude Code session id against (`session-id.ts`'s `SESSION_TRANSCRIPT_RE`), case-insensitive. */
|
|
59
|
+
const UUID_RE = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
60
|
+
/** The exact usage message the ADR pins for a delegation with no binding (AC 1). Shared so the CLI's early usage check and this function's own refusal read identically. */
|
|
61
|
+
export const NO_BINDING_MESSAGE = "a delegation must bind a cwd or a task";
|
|
62
|
+
/** The `understanding-delegated:<child-sid>:<parent-sid>` ledger fact content (ADR "Audit and doctor"). */
|
|
63
|
+
export function delegationLedgerFactFor(childSessionId, parentSessionId) {
|
|
64
|
+
return `understanding-delegated:${childSessionId}:${parentSessionId}`;
|
|
65
|
+
}
|
|
66
|
+
/** Control characters rejected from a raw `--task` value, mirroring the `CONTROL_CHARS` check `delegation-markers.ts` already runs on `parentSessionId` (not exported, so mirrored rather than imported). */
|
|
67
|
+
const TASK_ID_CONTROL_CHARS = /[\x00-\x1f\x7f]/;
|
|
68
|
+
/**
|
|
69
|
+
* Validate a raw `--task` value before it ever reaches
|
|
70
|
+
* `writeDelegationMarker` (L1 fix, agent-tasks 37ad0b05: an unvalidated
|
|
71
|
+
* `--task` used to surface downstream as an opaque `write-failed`, or
|
|
72
|
+
* silently rebind, depending on the value). Mirrors
|
|
73
|
+
* `delegation-markers.ts`'s own (unexported) `rejectUnsafeSegmentValue`:
|
|
74
|
+
* empty, or carrying a `;`/`=` segment delimiter, both corrupt the
|
|
75
|
+
* packed `approvedBy` encoding, plus the reserved unbound literal
|
|
76
|
+
* `"-"` (would silently round-trip as "no task bound") and a control
|
|
77
|
+
* character. Returns a detail string on a rejected value, `null` on a
|
|
78
|
+
* safe one.
|
|
79
|
+
*/
|
|
80
|
+
function validateTaskId(taskId) {
|
|
81
|
+
if (taskId.length === 0) {
|
|
82
|
+
return "--task must not be empty";
|
|
83
|
+
}
|
|
84
|
+
if (taskId === "-") {
|
|
85
|
+
return '--task must not be the reserved unbound literal "-"';
|
|
86
|
+
}
|
|
87
|
+
if (taskId.includes(";") || taskId.includes("=")) {
|
|
88
|
+
return `--task must not contain a delegation-segment delimiter (";" or "="): ${JSON.stringify(taskId)}`;
|
|
89
|
+
}
|
|
90
|
+
if (TASK_ID_CONTROL_CHARS.test(taskId)) {
|
|
91
|
+
return `--task must not contain a control character: ${JSON.stringify(taskId)}`;
|
|
92
|
+
}
|
|
93
|
+
return null;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Issue a signed delegation marker for a `claude -p` child session. Never
|
|
97
|
+
* calls `process.exit`; every failure mode is a `{ ok: false }` result
|
|
98
|
+
* with a distinct `reason` (ADR slice plan format rule: every refusal is
|
|
99
|
+
* a block with a distinct diagnostic, never a fall-through to allow).
|
|
100
|
+
*/
|
|
101
|
+
export async function issueDelegation(opts) {
|
|
102
|
+
if (!UUID_RE.test(opts.childSessionId)) {
|
|
103
|
+
return {
|
|
104
|
+
ok: false,
|
|
105
|
+
reason: "invalid-child-session",
|
|
106
|
+
detail: `--child-session must be a UUID (8-4-4-4-12 hex, case-insensitive): got ${JSON.stringify(opts.childSessionId)}`,
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
if (opts.cwd === undefined && opts.taskId === undefined) {
|
|
110
|
+
return { ok: false, reason: "no-binding", detail: NO_BINDING_MESSAGE };
|
|
111
|
+
}
|
|
112
|
+
// L3 fix (agent-tasks 37ad0b05): an empty `--cwd` used to fall through
|
|
113
|
+
// uncaught, and `hashDelegationCwd("")` -> `path.resolve("")` silently
|
|
114
|
+
// rebinds it to the issuer's OWN cwd rather than refusing. Caught here,
|
|
115
|
+
// alongside the no-binding check, before either value reaches a hash.
|
|
116
|
+
if (opts.cwd !== undefined && opts.cwd.length === 0) {
|
|
117
|
+
return {
|
|
118
|
+
ok: false,
|
|
119
|
+
reason: "invalid-cwd",
|
|
120
|
+
detail: "--cwd must not be empty (an empty value would silently rebind to the issuer's own cwd via path.resolve)",
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
if (opts.taskId !== undefined) {
|
|
124
|
+
const taskError = validateTaskId(opts.taskId);
|
|
125
|
+
if (taskError !== null) {
|
|
126
|
+
return { ok: false, reason: "invalid-task", detail: taskError };
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
const generatedDir = opts.generatedDir ??
|
|
130
|
+
resolveGeneratedDir({
|
|
131
|
+
...(opts.homeDir !== undefined ? { homeDir: opts.homeDir } : {}),
|
|
132
|
+
manifestPath: resolvePaths(opts).base,
|
|
133
|
+
});
|
|
134
|
+
// Signing-key precheck FIRST, before resolving or checking the parent
|
|
135
|
+
// marker at all. `checkApprovalMarker`'s own read path (via
|
|
136
|
+
// `verifyMarkerSignature` -> `getOrCreateSigningKey`) self-heals a
|
|
137
|
+
// missing key by CREATING one as a side effect of verification, that
|
|
138
|
+
// is correct for the gate's read side (delegation-markers.ts's own
|
|
139
|
+
// doc comment on `verifyDelegation` explains why), but it would mean
|
|
140
|
+
// this precheck could never observe a genuinely absent key if it ran
|
|
141
|
+
// after the parent-marker check: by the time that check returns, a
|
|
142
|
+
// key would already exist again. Checking here, before either
|
|
143
|
+
// resolveApprovalSessionId or checkApprovalMarker touches the
|
|
144
|
+
// filesystem, is what keeps "no operator signing key" a real,
|
|
145
|
+
// independently reachable refusal rather than one only writeDelegationMarker's
|
|
146
|
+
// own (necessarily later) precheck could ever see.
|
|
147
|
+
if (!signingKeyExists(generatedDir)) {
|
|
148
|
+
return {
|
|
149
|
+
ok: false,
|
|
150
|
+
reason: "signing-key-absent",
|
|
151
|
+
detail: `no operator signing key at ${signingKeyPathFor(generatedDir)}; refusing to delegate (key creation is an operator-side act, never a side effect of delegating)`,
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
// Parent session resolution: exactly the `harness approve
|
|
155
|
+
// understanding` precedence chain (flag > $CLAUDE_CODE_SESSION_ID >
|
|
156
|
+
// $CLAUDE_SESSION_ID > $CODEX_SESSION_ID > staged .pending-approval),
|
|
157
|
+
// with NO 6th-tier newest-report fallback: a delegation has no report
|
|
158
|
+
// of its own to guess a parent session from, and guessing the PARENT
|
|
159
|
+
// wrong here would mint a pre-authorization under the wrong identity.
|
|
160
|
+
const resolvedParent = resolveApprovalSessionId({
|
|
161
|
+
session: opts.parentSessionId,
|
|
162
|
+
generatedDir,
|
|
163
|
+
});
|
|
164
|
+
const parentSessionId = resolvedParent.sessionId;
|
|
165
|
+
if (parentSessionId === "") {
|
|
166
|
+
return {
|
|
167
|
+
ok: false,
|
|
168
|
+
reason: "parent-session-unresolved",
|
|
169
|
+
detail: "no parent session id available. Pass --session-id <id>, or set one of " +
|
|
170
|
+
"$CLAUDE_CODE_SESSION_ID / $CLAUDE_SESSION_ID / $CODEX_SESSION_ID, or run " +
|
|
171
|
+
"`harness preflight` (or trip the gate once) so harness.generated/.pending-approval is staged.",
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
// Manifest: best-effort, exactly like the approve CLI (shared via
|
|
175
|
+
// `loadDeclaredUnderstandingPack`, agent-tasks 37ad0b05). A load
|
|
176
|
+
// failure here degrades the TTL default (falls back to the hardcoded
|
|
177
|
+
// default below) and the ledger write (audit-only, never a refusal)
|
|
178
|
+
// but never blocks issuing the delegation itself.
|
|
179
|
+
const { manifest, manifestLoadError, declaredPack } = loadDeclaredUnderstandingPack(opts);
|
|
180
|
+
const lifecycle = parseApprovalLifecycle(declaredPack.config["approval_lifecycle"]);
|
|
181
|
+
// Key one of the ADR's two-key design: the parent must already carry a
|
|
182
|
+
// valid, unexpired, signed approval marker. Same check the gate itself
|
|
183
|
+
// runs (`checkApprovalMarker`), same `max_age` bound.
|
|
184
|
+
const parentCheck = checkApprovalMarker(generatedDir, parentSessionId, {
|
|
185
|
+
...(lifecycle.maxAgeMs !== undefined ? { maxAgeMs: lifecycle.maxAgeMs } : {}),
|
|
186
|
+
...(opts.now !== undefined ? { now: opts.now } : {}),
|
|
187
|
+
});
|
|
188
|
+
if (!parentCheck.matched) {
|
|
189
|
+
const reason = parentCheck.forged
|
|
190
|
+
? "parent-marker-forged"
|
|
191
|
+
: parentCheck.expired
|
|
192
|
+
? "parent-marker-expired"
|
|
193
|
+
: "parent-marker-missing";
|
|
194
|
+
return { ok: false, reason, detail: parentCheck.detail };
|
|
195
|
+
}
|
|
196
|
+
const now = opts.now ?? new Date();
|
|
197
|
+
// L2/L4 fix (agent-tasks 37ad0b05): an explicit `--ttl` is validated
|
|
198
|
+
// and clamped BEFORE it can reach `expiresAt`. `ttlSeconds <= 0` (or
|
|
199
|
+
// non-finite) used to mint a delegation that is already expired
|
|
200
|
+
// (L2); an unbounded `--ttl` used to let a caller mint one that
|
|
201
|
+
// outlives the applied pack's own `approval_lifecycle.max_age` (L4,
|
|
202
|
+
// or the 24h default ceiling when the pack sets none). Only an
|
|
203
|
+
// EXPLICIT `--ttl` is checked here: the computed default below (from
|
|
204
|
+
// `max_age` or the hardcoded default) is by construction already
|
|
205
|
+
// within whichever ceiling would apply to it.
|
|
206
|
+
let ttlSeconds;
|
|
207
|
+
if (opts.ttlSeconds !== undefined) {
|
|
208
|
+
if (!Number.isFinite(opts.ttlSeconds) || opts.ttlSeconds <= 0) {
|
|
209
|
+
return {
|
|
210
|
+
ok: false,
|
|
211
|
+
reason: "invalid-ttl",
|
|
212
|
+
detail: `--ttl must resolve to a positive, finite number of seconds; got ${opts.ttlSeconds}`,
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
const ceilingSeconds = lifecycle.maxAgeMs !== undefined
|
|
216
|
+
? Math.round(lifecycle.maxAgeMs / 1_000)
|
|
217
|
+
: MAX_DELEGATION_TTL_SECONDS;
|
|
218
|
+
if (opts.ttlSeconds > ceilingSeconds) {
|
|
219
|
+
return {
|
|
220
|
+
ok: false,
|
|
221
|
+
reason: "ttl-above-max-age",
|
|
222
|
+
detail: lifecycle.maxAgeMs !== undefined
|
|
223
|
+
? `--ttl (${opts.ttlSeconds}s) exceeds the applied pack's approval_lifecycle.max_age (${ceilingSeconds}s)`
|
|
224
|
+
: `--ttl (${opts.ttlSeconds}s) exceeds the default ${ceilingSeconds}s (24h) ceiling; set approval_lifecycle.max_age to raise it`,
|
|
225
|
+
};
|
|
226
|
+
}
|
|
227
|
+
ttlSeconds = opts.ttlSeconds;
|
|
228
|
+
}
|
|
229
|
+
else {
|
|
230
|
+
ttlSeconds =
|
|
231
|
+
lifecycle.maxAgeMs !== undefined
|
|
232
|
+
? Math.round(lifecycle.maxAgeMs / 1_000)
|
|
233
|
+
: DEFAULT_DELEGATION_TTL_SECONDS;
|
|
234
|
+
}
|
|
235
|
+
const expiresAt = new Date(now.getTime() + ttlSeconds * 1_000).toISOString();
|
|
236
|
+
// Fallback shape: bind the launcher-supplied report by BOTH its
|
|
237
|
+
// content and its path (delegation-markers.ts, "Delegation marker
|
|
238
|
+
// shape" table: half a binding is worse than none).
|
|
239
|
+
let reportPathHash;
|
|
240
|
+
let reportContentHash;
|
|
241
|
+
if (opts.reportPath !== undefined) {
|
|
242
|
+
const read = readRegularFileRejectingSymlink(opts.reportPath);
|
|
243
|
+
if (read.kind !== "ok") {
|
|
244
|
+
return {
|
|
245
|
+
ok: false,
|
|
246
|
+
reason: "report-unreadable",
|
|
247
|
+
detail: `--report ${opts.reportPath} could not be read (${read.kind})`,
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
reportContentHash = sha256Hex(read.content);
|
|
251
|
+
reportPathHash = hashDelegationCwd(opts.reportPath);
|
|
252
|
+
}
|
|
253
|
+
const cwdHash = opts.cwd !== undefined ? hashDelegationCwd(opts.cwd) : null;
|
|
254
|
+
const taskId = opts.taskId !== undefined ? opts.taskId : null;
|
|
255
|
+
const writeResult = writeDelegationMarker({
|
|
256
|
+
generatedDir,
|
|
257
|
+
childSessionId: opts.childSessionId,
|
|
258
|
+
parentSessionId,
|
|
259
|
+
cwdHash,
|
|
260
|
+
taskId,
|
|
261
|
+
expiresAt,
|
|
262
|
+
...(reportPathHash !== undefined ? { reportPathHash } : {}),
|
|
263
|
+
...(reportContentHash !== undefined ? { reportContentHash } : {}),
|
|
264
|
+
now,
|
|
265
|
+
});
|
|
266
|
+
if (!writeResult.ok) {
|
|
267
|
+
if (writeResult.reason === "signing-key-absent") {
|
|
268
|
+
return { ok: false, reason: "signing-key-absent", detail: writeResult.detail };
|
|
269
|
+
}
|
|
270
|
+
if (writeResult.reason === "invalid-input") {
|
|
271
|
+
// Reachable: a malformed raw parent session id (`--session-id`, or
|
|
272
|
+
// a value read from $CLAUDE_CODE_SESSION_ID / $CLAUDE_SESSION_ID /
|
|
273
|
+
// $CODEX_SESSION_ID / a staged .pending-approval) still reaches
|
|
274
|
+
// `buildDelegationApprovedBy`'s `rejectMalformedSessionId` /
|
|
275
|
+
// `rejectUnsafeSegmentValue` checks on `parentSessionId`
|
|
276
|
+
// unvalidated by this function. `--task` no longer reaches this
|
|
277
|
+
// branch: its own value is now validated (the `invalid-task`
|
|
278
|
+
// refusal above) before `writeDelegationMarker` is ever called.
|
|
279
|
+
// Mapped to its own reason rather than folded into "write-failed",
|
|
280
|
+
// so a malformed parent session id fails closed with a diagnostic
|
|
281
|
+
// distinct from a genuine I/O write failure.
|
|
282
|
+
return { ok: false, reason: "invalid-input", detail: writeResult.detail };
|
|
283
|
+
}
|
|
284
|
+
return { ok: false, reason: "write-failed", detail: writeResult.detail };
|
|
285
|
+
}
|
|
286
|
+
const ledgerContent = delegationLedgerFactFor(opts.childSessionId, parentSessionId);
|
|
287
|
+
let ledgerResult;
|
|
288
|
+
if (opts.ledgerAdd) {
|
|
289
|
+
ledgerResult = await opts.ledgerAdd(opts.childSessionId, ledgerContent);
|
|
290
|
+
}
|
|
291
|
+
else if (manifest) {
|
|
292
|
+
ledgerResult = await writeLedgerTag(manifest, opts.childSessionId, ledgerContent, {}, DEFAULT_DELEGATE_LEDGER_SOURCE);
|
|
293
|
+
}
|
|
294
|
+
else {
|
|
295
|
+
ledgerResult = {
|
|
296
|
+
ok: false,
|
|
297
|
+
reason: manifestLoadError
|
|
298
|
+
? `manifest unreadable (${manifestLoadError}); skipped ledger write`
|
|
299
|
+
: "manifest unreadable; skipped ledger write",
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
return {
|
|
303
|
+
ok: true,
|
|
304
|
+
filePath: writeResult.filePath,
|
|
305
|
+
parentSessionId,
|
|
306
|
+
childSessionId: opts.childSessionId,
|
|
307
|
+
expiresAt,
|
|
308
|
+
ledgerFact: ledgerResult.ok
|
|
309
|
+
? { written: true }
|
|
310
|
+
: { written: false, reason: ledgerResult.reason },
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/cli/delegate/index.ts"],"names":[],"mappings":"AAAA,oFAAoF;AACpF,wEAAwE;AACxE,2CAA2C;AAC3C,EAAE;AACF,uEAAuE;AACvE,mEAAmE;AACnE,mEAAmE;AACnE,sEAAsE;AACtE,uEAAuE;AACvE,wEAAwE;AACxE,qBAAqB;AACrB,EAAE;AACF,6DAA6D;AAC7D,yEAAyE;AACzE,qEAAqE;AACrE,+DAA+D;AAC/D,oEAAoE;AACpE,qEAAqE;AACrE,0CAA0C;AAC1C,EAAE;AACF,oEAAoE;AACpE,iEAAiE;AACjE,8DAA8D;AAC9D,oEAAoE;AACpE,iEAAiE;AACjE,EAAE;AACF,qEAAqE;AACrE,uEAAuE;AACvE,0EAA0E;AAC1E,yEAAyE;AACzE,2EAA2E;AAC3E,sEAAsE;AACtE,wEAAwE;AACxE,wEAAwE;AACxE,sEAAsE;AACtE,4DAA4D;AAC5D,0DAA0D;AAC1D,wEAAwE;AACxE,wDAAw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C,2CAA2C;SAChD,CAAC;IACJ,CAAC;IAED,OAAO;QACL,EAAE,EAAE,IAAI;QACR,QAAQ,EAAE,WAAW,CAAC,QAAQ;QAC9B,eAAe;QACf,cAAc,EAAE,IAAI,CAAC,cAAc;QACnC,SAAS;QACT,UAAU,EAAE,YAAY,CAAC,EAAE;YACzB,CAAC,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE;YACnB,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,YAAY,CAAC,MAAM,EAAE;KACpD,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import type { Manifest } from "../../schema/index.js";
|
|
2
|
+
export interface AutoApproveModeWarning {
|
|
3
|
+
/**
|
|
4
|
+
* The RESOLVED effective mode (`resolveModeFromConfig(pack).mode`);
|
|
5
|
+
* never the literal `pack.config.mode` value. Always a recognised
|
|
6
|
+
* Mode literal (the resolver always returns one, defaulting to
|
|
7
|
+
* `grill_me` when `config.mode` is absent or unrecognised).
|
|
8
|
+
*/
|
|
9
|
+
mode: string;
|
|
10
|
+
/** Rendered as the `⚠` line itself. */
|
|
11
|
+
message: string;
|
|
12
|
+
/**
|
|
13
|
+
* Indented detail lines rendered directly under {@link message} by
|
|
14
|
+
* `format.ts`, mirroring `understandingModeEnv`'s detail-line idiom.
|
|
15
|
+
*/
|
|
16
|
+
detail: string[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Pure: manifest in, a warning out (or `undefined` when there is nothing
|
|
20
|
+
* to flag). Only fires when:
|
|
21
|
+
* - the `understanding-before-execution` pack is declared AND enabled
|
|
22
|
+
* (a pack that never runs has no live auto-approve path to warn
|
|
23
|
+
* about, mirrors the enabled-gate `understanding-mode-env.ts` and
|
|
24
|
+
* `ug-auto-approvals.ts` use);
|
|
25
|
+
* - `config.auto_approve` parses as a valid opt-in block (schema
|
|
26
|
+
* validation already rejects a malformed block at lint time, so a
|
|
27
|
+
* manifest that reaches doctor with an unparseable block has
|
|
28
|
+
* already failed loud elsewhere; this mirrors that same fail-closed
|
|
29
|
+
* "not opted in" reading rather than re-deriving a second opinion);
|
|
30
|
+
* - the RESOLVED effective mode (`resolveModeFromConfig(pack).mode`)
|
|
31
|
+
* is not `"grill_me"`. An absent or unrecognised `config.mode`
|
|
32
|
+
* resolves to `grill_me` (`DEFAULT_MODE`) and therefore never fires
|
|
33
|
+
* this warning, see the module header for why that resolved value,
|
|
34
|
+
* not the literal config key, is what the auto path's report
|
|
35
|
+
* actually carries.
|
|
36
|
+
*/
|
|
37
|
+
export declare function checkAutoApproveMode(manifest: Manifest): AutoApproveModeWarning | undefined;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// Doctor advisory (agent-tasks abfad738, follow-up of ADR
|
|
2
|
+
// docs/decisions/2026-08-27-ug-auto-mode-approval.md slice 1): warn when
|
|
3
|
+
// an operator has opted into the hook-written signed auto-marker path
|
|
4
|
+
// (`policy_packs[understanding-before-execution].config.auto_approve`)
|
|
5
|
+
// without also pairing it with `mode: grill_me`.
|
|
6
|
+
//
|
|
7
|
+
// Why this matters: the auto-approval path's report precondition reuses
|
|
8
|
+
// `validatePersistedReport` (`src/cli/approve/understanding.ts`), which
|
|
9
|
+
// only enforces the report's `mode` field when it is `grill_me`.
|
|
10
|
+
// Outside that mode, report validation is structural only (the report
|
|
11
|
+
// exists and belongs to the session, not that its contents reflect any
|
|
12
|
+
// real understanding exchange). Both the ADR (recommendation 4) and the
|
|
13
|
+
// pack doc recommend pairing `auto_approve` with `grill_me` for exactly
|
|
14
|
+
// this reason. Nothing surfaced the gap before this check: an operator
|
|
15
|
+
// who opts a non-grill_me mode into `auto_approve` gets no signal that
|
|
16
|
+
// the auto path's report gate has degraded to a near-no-op.
|
|
17
|
+
//
|
|
18
|
+
// Deliberately advisory, never an error: `auto_approve` outside
|
|
19
|
+
// `grill_me` is a real, if weaker, gate (the permission-mode allowlist
|
|
20
|
+
// and the signed marker still apply), not a misconfiguration.
|
|
21
|
+
//
|
|
22
|
+
// This check reads `resolveModeFromConfig(pack).mode`, the same
|
|
23
|
+
// GENERATION-path resolver `checkUnderstandingModeEnvDivergence` and
|
|
24
|
+
// `resolveBuiltinDefaultConfig` use, NOT `pack.config.mode` verbatim.
|
|
25
|
+
// A missing `config.mode` resolves to `DEFAULT_MODE` (`grill_me`), and
|
|
26
|
+
// that resolved value is what the generated Stop-hook command actually
|
|
27
|
+
// passes as `UNDERSTANDING_GATE_MODE`, so a report written under an
|
|
28
|
+
// unset `mode` genuinely carries `grill_me` and IS the strict check;
|
|
29
|
+
// there is no gap to warn about. An unrecognised `config.mode` literal
|
|
30
|
+
// also resolves to `grill_me` this same way, with its own warning
|
|
31
|
+
// already surfaced elsewhere (`resolveModeFromConfig`'s `warning`
|
|
32
|
+
// return, consumed by `harness validate` / other doctor checks); this
|
|
33
|
+
// check does not duplicate that.
|
|
34
|
+
//
|
|
35
|
+
// A session-level `UNDERSTANDING_GATE_MODE` env override that diverges
|
|
36
|
+
// from the resolved `config.mode` is a SEPARATE gap, already covered by
|
|
37
|
+
// `checkUnderstandingModeEnvDivergence` (`understanding-mode-env.ts`)'s
|
|
38
|
+
// own advisory line, this check only ever reads the manifest, never
|
|
39
|
+
// `process.env`.
|
|
40
|
+
import { resolveModeFromConfig } from "../../policy-packs/builtin/understanding-before-execution.js";
|
|
41
|
+
import { parseAutoApprove } from "../../policy-packs/builtin/understanding-before-execution/index.js";
|
|
42
|
+
import { findEnabledUnderstandingPack } from "./understanding-mode-env.js";
|
|
43
|
+
/**
|
|
44
|
+
* Pure: manifest in, a warning out (or `undefined` when there is nothing
|
|
45
|
+
* to flag). Only fires when:
|
|
46
|
+
* - the `understanding-before-execution` pack is declared AND enabled
|
|
47
|
+
* (a pack that never runs has no live auto-approve path to warn
|
|
48
|
+
* about, mirrors the enabled-gate `understanding-mode-env.ts` and
|
|
49
|
+
* `ug-auto-approvals.ts` use);
|
|
50
|
+
* - `config.auto_approve` parses as a valid opt-in block (schema
|
|
51
|
+
* validation already rejects a malformed block at lint time, so a
|
|
52
|
+
* manifest that reaches doctor with an unparseable block has
|
|
53
|
+
* already failed loud elsewhere; this mirrors that same fail-closed
|
|
54
|
+
* "not opted in" reading rather than re-deriving a second opinion);
|
|
55
|
+
* - the RESOLVED effective mode (`resolveModeFromConfig(pack).mode`)
|
|
56
|
+
* is not `"grill_me"`. An absent or unrecognised `config.mode`
|
|
57
|
+
* resolves to `grill_me` (`DEFAULT_MODE`) and therefore never fires
|
|
58
|
+
* this warning, see the module header for why that resolved value,
|
|
59
|
+
* not the literal config key, is what the auto path's report
|
|
60
|
+
* actually carries.
|
|
61
|
+
*/
|
|
62
|
+
export function checkAutoApproveMode(manifest) {
|
|
63
|
+
const pack = findEnabledUnderstandingPack(manifest);
|
|
64
|
+
if (!pack)
|
|
65
|
+
return undefined;
|
|
66
|
+
const autoApprove = parseAutoApprove(pack.config["auto_approve"]);
|
|
67
|
+
if (autoApprove === null)
|
|
68
|
+
return undefined;
|
|
69
|
+
const { mode } = resolveModeFromConfig(pack);
|
|
70
|
+
if (mode === "grill_me")
|
|
71
|
+
return undefined;
|
|
72
|
+
return {
|
|
73
|
+
mode,
|
|
74
|
+
message: `auto_approve is configured with mode ${mode} (policy_packs[understanding-before-execution].config.mode); report validation is structural only outside grill_me`,
|
|
75
|
+
detail: [
|
|
76
|
+
"set config.mode: grill_me, or accept the weaker report gate; see docs/policy-packs/understanding-before-execution.md",
|
|
77
|
+
],
|
|
78
|
+
};
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=auto-approve-mode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auto-approve-mode.js","sourceRoot":"","sources":["../../../src/cli/doctor/auto-approve-mode.ts"],"names":[],"mappings":"AAAA,0DAA0D;AAC1D,yEAAyE;AACzE,sEAAsE;AACtE,uEAAuE;AACvE,iDAAiD;AACjD,EAAE;AACF,wEAAwE;AACxE,wEAAwE;AACxE,iEAAiE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|
+
export interface CodexConfigDriftSection {
|
|
3
|
+
/** ⚠ lines; each rolls into warningCount. */
|
|
4
|
+
warnings: string[];
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Whether the manifest's `understanding-before-execution` pack has opted
|
|
8
|
+
* Codex into the `auto_approve` path (`auto_approve.harnesses` contains
|
|
9
|
+
* `"codex"`). Pure and side-effect-free: reuses the same fail-closed
|
|
10
|
+
* parser the Codex PreToolUse hook itself consults
|
|
11
|
+
* (`attemptAutoApproval` in `../pack/auto-approve-path.ts`), so a
|
|
12
|
+
* malformed `auto_approve` block resolves to "not opted in" here too,
|
|
13
|
+
* never a guess.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isCodexOptedIntoAutoApprove(manifest: Manifest): boolean;
|
|
16
|
+
export interface BuildCodexConfigDriftOptions {
|
|
17
|
+
/** `harness.generated/` for the manifest in use; kept for shape-parity with `BuildSettingsDriftOptions` (`driftCheckOpts` in index.ts is shared between both), unused by this check (see module header: no baseline exists to read here). */
|
|
18
|
+
generatedDir: string;
|
|
19
|
+
/** `harness.lock` path for the manifest in use; kept for the same shape-parity reason as `generatedDir`, unused by this check. */
|
|
20
|
+
lockPath: string;
|
|
21
|
+
/** Resolves the repo-scoped candidate file (`<cwd>/.codex/config.toml`). */
|
|
22
|
+
cwd: string;
|
|
23
|
+
/** Operator home; resolves the default `$CODEX_HOME` when the env var is unset. */
|
|
24
|
+
home: string;
|
|
25
|
+
/** Env for `CODEX_HOME` resolution. */
|
|
26
|
+
env: NodeJS.ProcessEnv;
|
|
27
|
+
}
|
|
28
|
+
export declare function buildCodexConfigDrift(opts: BuildCodexConfigDriftOptions): CodexConfigDriftSection;
|