@sema-agent/settings-schema 30.1.0 → 31.0.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.
@@ -32,23 +32,30 @@
32
32
  * (it is why the piece is rejected rather than dropped).
33
33
  *
34
34
  * CC 2.1.296 DIVERGENCES (the ones LISTED there are each in the stricter direction — a document CC would load may be rejected here, never the reverse): listed once,
35
- * in `docs/CC-DIVERGENCE.md` (section "hooks classifier", H1–H7) — the whole-subtree guard-sign scan is the first of them. The entry field table
35
+ * in `docs/CC-DIVERGENCE.md` (section "hooks classifier", H1–H8) — the whole-subtree guard-sign scan is the first of them. The entry field table
36
36
  * ({@link HOOK_ENTRY_FIELDS}) carries EVERY key CC's five hook-entry schemas carry (`cli309.js:252382`), so no key CC judges is stripped here unjudged. That is a statement about
37
37
  * which KEYS are read; the VALUE forms are the field kinds' (H7 lists where they judge more than CC does), with one known place where a kind judges LESS than CC: an `http` entry's `url`
38
38
  * is read as a non-empty string where CC checks URL syntax (not closed yet — see CHANGELOG 20.0.0, "已知限制").
39
+ * One column is this contract's own, not CC's (H8): a `command` entry's `plugin` ({@link HookPluginContext}, 31.0.0) — CC reads a plugin hook's context from where the plugin sits, so its
40
+ * entry schema has no such key and strips one written in a settings file; here the context travels on the entry, and a bad one is a bad piece like any other field's bad value.
39
41
  *
40
42
  * COORDINATES are raw {@link ConfigPath} segments (the keys as written). An unknown event name or a key outside `hooks` is user text and may be
41
43
  * anything, a pasted credential included: pass a coordinate through `outgoingPath` before it leaves the process (log, UI, wire). The classifier
42
44
  * echoes no values and writes no sentences — the sentences are the consumers' (same law as `DROPPED_ENTRY_REASON_CODES`).
43
45
  *
44
- * SELF-CONTAINED. {@link classifyHooksConfig} and the module-private declarations it uses reference nothing outside themselves except
45
- * {@link HOOK_EVENTS} and JavaScript built-ins (no zod): a consumer that copies the function into its own bundle (client-core's generator
46
- * does, with the private declarations it uses) copies one closure plus the event vocabulary. The hooks-classify test file (group ⑤) holds this.
46
+ * SELF-CONTAINED. {@link classifyHooksConfig} and the module-private declarations it uses reference nothing outside themselves except their REGISTERED
47
+ * names and JavaScript built-ins (no zod): a consumer that copies the function into its own bundle (client-core's generator does, with the private
48
+ * declarations it uses) copies one closure and gives the copy's scope each registered name, bound to the runtime export it names — never a copy of it.
49
+ * The registered names: {@link HOOK_EVENTS} (the event vocabulary), and the three judgements the `plugin` field needs, each read from its one owner
50
+ * (31.0.0): {@link pluginOptionKeysProblem} (this module; it registers {@link pluginOptionEnvName} in turn), `isAbsoluteHostPath` (`./host-path`) and
51
+ * `readCredentialRef` (the engine primitives package, the one reader of a credential reference). The closure carries no copy of any of them.
52
+ * The hooks-classify test file (group ⑤) holds the registered set exactly; `test/hook-plugin-context-31.0.0.test.ts` S7 holds "no copy".
47
53
  *
48
54
  * Input is a settings document as parsed from JSON. Values JSON cannot produce (accessors, class instances, cycles) are not part of the
49
55
  * contract; cycles are tolerated, a throwing accessor propagates.
50
56
  */
51
57
  import { z } from "zod";
58
+ import { type CredentialRef } from "@sema-agent/primitives";
52
59
  import type { ConfigPath } from "./config-fns.js";
53
60
  /** The full 33-event contract set = CC 198's 27 + the 6 post-198 events — the one exported closed set of hook event names. */
54
61
  export declare const HOOK_EVENTS: readonly ["PreToolUse", "PostToolUse", "PostToolUseFailure", "PostToolBatch", "Notification", "UserPromptSubmit", "UserPromptExpansion", "SessionStart", "SessionEnd", "Stop", "StopFailure", "SubagentStart", "SubagentStop", "PreCompact", "PostCompact", "PermissionRequest", "PermissionDenied", "Setup", "TeammateIdle", "TaskCreated", "TaskCompleted", "Elicitation", "ElicitationResult", "ConfigChange", "WorktreeCreate", "WorktreeRemove", "InstructionsLoaded", "CwdChanged", "FileChanged", "MessageDisplay", "DirectoryAdded", "PreModelSwitch", "PostModelSwitch"];
@@ -83,6 +90,166 @@ export type HookOnFailure = (typeof HOOK_ON_FAILURE_WORDS)[number];
83
90
  export declare const HOOK_CLOUD_WORDS: readonly ["device", "skip"];
84
91
  /** One word of {@link HOOK_CLOUD_WORDS}. */
85
92
  export type HookCloud = (typeof HOOK_CLOUD_WORDS)[number];
93
+ /**
94
+ * A plugin option value that names a stored credential instead of carrying it (31.0.0): the `vault` kind of the engine primitives' credential reference, and ONLY that kind — an `env`,
95
+ * `handle` or `assertion` reference is never taken from a hook entry (an environment name would read any variable of the process that resolves it, a handle names someone else's
96
+ * credential, an assertion is minted by the deployment). Judged by the primitives' `readCredentialRef` itself (the classifier calls it — no second reading of its own here) and
97
+ * accepted when it reads a `vault` reference; this type is that kind of the primitives' `CredentialRef`.
98
+ * FORM ONLY: who may resolve the entry, and whether anything does, are the consumers' — this package judges the shape. A runner that cannot resolve a reference refuses the hook:
99
+ * it never runs it with the reference standing in for the value.
100
+ */
101
+ export type HookPluginOptionRef = Extract<CredentialRef, {
102
+ readonly kind: "vault";
103
+ }>;
104
+ /**
105
+ * The plugin context a `command` entry carries (field `plugin`, 31.0.0 — before 31.0.0 the key was not a contract field and was stripped): the plugin the hook belongs to.
106
+ * · `name` — the plugin's name: a non-empty string with no NUL byte;
107
+ * · `root` — required: the plugin's directory; `dataDir` (optional) — its data directory. Each an absolute host path, judged by `isAbsoluteHostPath` (the classifier calls it;
108
+ * whether the directory exists is the runner's business);
109
+ * · `options` (optional) — the plugin's option values by option key. A key is an identifier (`[A-Za-z_][A-Za-z0-9_]*`) and no two keys become the same environment variable
110
+ * ({@link pluginOptionEnvName}: `CLAUDE_PLUGIN_OPTION_<KEY upper-cased>` for an identifier), so no value silently overwrites another ({@link pluginOptionKeysProblem} answers both
111
+ * questions; the classifier calls it). A value is a string with no NUL byte or a {@link HookPluginOptionRef}.
112
+ * Any other member, or a member of the wrong form, makes the whole `plugin` bad — and a bad `plugin` is a bad piece like any other field's bad value (dropped in a non-guard event, the
113
+ * whole document rejected in a guard event, `field: "plugin"`). The loaded entry carries a fresh copy (no record or reference shared with the document). CARRIED, not executed here.
114
+ * The document's own law reaches inside it too: the classifier searches every entry, `plugin` included, for guard signs — an option KEY named for a guard event (`PreToolUse` /
115
+ * `PermissionRequest`) with a value, or an `options` record that is matcher-shaped (`hooks` beside `matcher`), is one, and then the whole settings document is rejected in any event
116
+ * (`guard-entry-invalid`, `field: "plugin"`) — the same as before 31.0.0, when the key was stripped. {@link pluginOptionKeysProblem} judges keys as keys and does not answer that.
117
+ * How big a context may be is the runner's cap; {@link measureHookPluginContext} is the one measure.
118
+ */
119
+ export interface HookPluginContext {
120
+ readonly name: string;
121
+ readonly root: string;
122
+ readonly dataDir?: string;
123
+ readonly options?: Readonly<Record<string, string | HookPluginOptionRef>>;
124
+ }
125
+ /** What is wrong with a list of plugin option keys ({@link pluginOptionKeysProblem}): a key that is not an identifier, or two keys that become the same environment variable name. */
126
+ export type PluginOptionKeysProblem = {
127
+ readonly kind: "not_identifier";
128
+ readonly key: string;
129
+ } | {
130
+ readonly kind: "collision";
131
+ readonly keys: readonly [string, string];
132
+ readonly envName: string;
133
+ };
134
+ /**
135
+ * The first problem with a list of plugin option keys, in key order, or `undefined` when there is none: a key that is not an identifier (`[A-Za-z_][A-Za-z0-9_]*`) ⇒ `not_identifier`;
136
+ * a key that becomes the same environment variable as an earlier key ({@link pluginOptionEnvName} — for identifiers that is "equal once upper-cased") ⇒ `collision` with the two keys
137
+ * (earlier first) and that name. THE judgement the classifier makes on `plugin.options` (it calls this function; a problem there makes the entry a bad piece): a sender can ask it
138
+ * before it sends. It judges keys as keys — a key named for a guard event is the document's law, not this one (see {@link HookPluginContext}). The keys are user text — pass them
139
+ * through the consumer's echo rules before they are shown. Its one REGISTERED name is {@link pluginOptionEnvName} (no other free name but JavaScript built-ins): a consumer's
140
+ * generator may copy it whole and give the copy that name.
141
+ */
142
+ export declare function pluginOptionKeysProblem(keys: readonly string[]): PluginOptionKeysProblem | undefined;
143
+ /**
144
+ * The name of the environment variable that carries one plugin option to a hook process: `CLAUDE_PLUGIN_OPTION_` followed by the option key as written with every UTF-16 code unit
145
+ * outside `[A-Za-z0-9_]` replaced by `_`, then upper-cased (the replacement comes first, so only ASCII is ever upper-cased). The reference implementation's fold for that variable. The
146
+ * ONE writing of it in this package (`pluginOptionKeysProblem`'s `envName` reads it): a runner that sets the variables from the keys as written and a sender that still folds before
147
+ * it sends both read this, never their own copy. Two different keys can fold to one name (`api-key` / `api_key`, `a.b` / `A_B`); which value the process then sees is the runner's to
148
+ * decide — this gives the name only. On a plugin entry the classifier already refuses such keys ({@link pluginOptionKeysProblem}). SELF-CONTAINED (no free name but JavaScript
149
+ * built-ins): a consumer's generator may copy it whole.
150
+ */
151
+ export declare function pluginOptionEnvName(key: string): string;
152
+ /** The path names a command line may name as `${NAME}` (closed, frozen): the project directory, the plugin's directory, the plugin's data directory. The order is the order
153
+ * {@link planHookCommandSpawn} reports a missing value in when more than one is missing. */
154
+ export declare const HOOK_COMMAND_PATH_NAMES: readonly ["CLAUDE_PROJECT_DIR", "CLAUDE_PLUGIN_ROOT", "CLAUDE_PLUGIN_DATA"];
155
+ /** One word of {@link HOOK_COMMAND_PATH_NAMES}. */
156
+ export type HookCommandPathName = (typeof HOOK_COMMAND_PATH_NAMES)[number];
157
+ /**
158
+ * Why a command hook cannot start (closed, frozen). The ORDER IS THE PRECEDENCE: when more than one holds, {@link planHookCommandSpawn} reports the earliest —
159
+ * · `path_unset` — the command line names a path name ({@link HOOK_COMMAND_PATH_NAMES}) that has no value (either execution form: the shell would expand it to nothing);
160
+ * · `shell_form_user_config` — a plugin entry's shell-form command (no `args`) names `${user_config.K}`: never substituted there (the shell would parse the value again), whatever the
161
+ * option holds — the reference implementation refuses the same hook, whether the option is sensitive, stored or not, PowerShell or not;
162
+ * · `user_config_unset` — a plugin entry's exec-form command line names an option key its option table does not hold;
163
+ * · `user_config_unresolved` — a plugin entry's exec-form command line names an option whose value in the table is still a {@link HookPluginOptionRef} (a reference not resolved by the
164
+ * caller).
165
+ * The words are about the command line against the table the caller holds, not about resolving a reference (that is the caller's, with its own words). The three option words exist only
166
+ * for a plugin entry: on an entry no plugin brought, `${user_config.K}` is not a placeholder (see {@link planHookCommandSpawn}).
167
+ */
168
+ export declare const HOOK_COMMAND_SPAWN_REFUSAL_WORDS: readonly ["path_unset", "shell_form_user_config", "user_config_unset", "user_config_unresolved"];
169
+ /** One word of {@link HOOK_COMMAND_SPAWN_REFUSAL_WORDS}. */
170
+ export type HookCommandSpawnRefusalWord = (typeof HOOK_COMMAND_SPAWN_REFUSAL_WORDS)[number];
171
+ /** A refusal of {@link planHookCommandSpawn}: the word, and the path name or the option key (as written on the command line — user text: pass it through the consumer's echo rules,
172
+ * or use {@link hookCommandSpawnRefusalSentence}) it is about. Never a value. */
173
+ export type HookCommandSpawnRefusal = {
174
+ readonly word: "path_unset";
175
+ readonly name: HookCommandPathName;
176
+ } | {
177
+ readonly word: Exclude<HookCommandSpawnRefusalWord, "path_unset">;
178
+ readonly key: string;
179
+ };
180
+ /** What {@link planHookCommandSpawn} answers: the shell-form command as it is (`shell`), the exec-form copy a process starts from (`exec`), or why it cannot start (`refused`). */
181
+ export type HookCommandSpawnPlan = {
182
+ readonly kind: "shell";
183
+ readonly command: string;
184
+ } | {
185
+ readonly kind: "exec";
186
+ readonly file: string;
187
+ readonly args: readonly string[];
188
+ } | {
189
+ readonly kind: "refused";
190
+ readonly refusal: HookCommandSpawnRefusal;
191
+ };
192
+ /**
193
+ * THE rule for the placeholders of a command hook's command line, and the one reader of their grammar: a sender that substitutes before it sends and a runner that substitutes when it
194
+ * starts the process both call this function, so the two cannot answer differently.
195
+ *
196
+ * GRAMMAR. One pass, left to right, over `command` and then each `args` element. At each `${` the pass recognizes one of the three path names written `${CLAUDE_PROJECT_DIR}` /
197
+ * `${CLAUDE_PLUGIN_ROOT}` / `${CLAUDE_PLUGIN_DATA}`, or — on a plugin entry — an option placeholder `${user_config.K}` (`K` = one or more characters up to the next `}`, the
198
+ * reference implementation's form) — nothing else: any other `${…}` stays as written. A value put in is NOT scanned again: a value that itself reads `${user_config.X}` or
199
+ * `${CLAUDE_PLUGIN_ROOT}` is handed on as those characters (the reference implementation substitutes the path names first and the options in a second pass over the result; this
200
+ * contract does not — a value is a value, not a template).
201
+ *
202
+ * INPUT. `entry` — the command line, and whether a plugin brought it: exec form when `args` is present (`command` is the program, no shell), shell form when it is not (the same
203
+ * switch as the entry's own); a PLUGIN entry is one with a `plugin` member — the same reading the classifier and the `plugin` column make (a {@link CommandHookEntry} the classifier
204
+ * loaded is passed as it is). The `user_config` namespace belongs to plugin entries: on an entry with no `plugin`, `${user_config.…}` is no placeholder at all — it stays as written
205
+ * like any other `${…}`, and a shell-form command is not refused for it (the reference implementation takes an option table only for a plugin's hook, and both its refusal and its
206
+ * substitution hang on that table). `paths` — each path name's value, all three stated: a string (the empty string included) is the value, `undefined` is no value. `resolved` —
207
+ * optional, a plugin entry's option table as the caller holds it after resolving (or, for a sender, the table it holds); left out, the table is the entry's own `plugin.options`, and
208
+ * the empty table when the context has no `options` member. In the table an OWN key holding a string (the empty string included) is that option's value, an own key holding a
209
+ * {@link HookPluginOptionRef} is an option whose value is a reference not resolved, a key not held is an option that is not set. A table given for an entry with no `plugin`, or
210
+ * a `null` table or `plugin` (on any command line), is the caller's error and THROWS — the namespace follows the entry, never whether a table happens to be at hand.
211
+ * Reading the environment, the disk, the secure store or a clock is the caller's; this function does none of it.
212
+ *
213
+ * VERDICT, in the order of {@link HOOK_COMMAND_SPAWN_REFUSAL_WORDS} — a whole word is judged over the whole command line before the next word (any unset key beats any unresolved one,
214
+ * wherever each stands): a named path name without a value ⇒ `path_unset` (the first missing one in {@link HOOK_COMMAND_PATH_NAMES} order); shell form naming an option ⇒
215
+ * `shell_form_user_config`; exec form naming a key the table does not hold ⇒ `user_config_unset`; exec form naming a key whose value is a reference ⇒ `user_config_unresolved` (keys:
216
+ * the first in pass order; the three option words only where options are recognized, i.e. on a plugin entry). Otherwise shell form ⇒ `command` as it is (a shell expands path names from
217
+ * the environment; nothing is substituted in the text), exec form ⇒ `file` / `args` with every recognized placeholder replaced by its value in that same pass.
218
+ *
219
+ * CALL SHAPES. A runner passes the entry it loaded and its paths — `planHookCommandSpawn(entry, paths)` — and nothing else decides the namespace. A runner with steps of its own between
220
+ * the checks (a directory to look at, a reference to resolve) keeps one precedence by answering every refusal but the LAST word at once and `user_config_unresolved` after its own
221
+ * steps: the function reports only the earliest word, so when it reports the last one no earlier word holds; a runner that resolves references calls again with the resolved table
222
+ * (`planHookCommandSpawn(entry, paths, resolved)`). A sender that substitutes for a runner which substitutes the path names itself passes each path name's own placeholder as its
223
+ * value (`{ CLAUDE_PLUGIN_ROOT: "${CLAUDE_PLUGIN_ROOT}", … }`) and, on a plugin entry, the table it holds: a value is not scanned again, so the placeholder reaches the runner as
224
+ * written — and every option word comes out exactly as the runner's own call would give it.
225
+ *
226
+ * THE COPY ONLY. The answer is what a process starts from: an `exec` answer has no `command` member and a `shell` answer's `command` is the input itself; the entry is never written. What
227
+ * is shown, logged or recorded (a hook's display name, its ledger row, a frame, a sentence) is the entry as written, never this copy — the copy may hold option values.
228
+ * SELF-CONTAINED (no free name but JavaScript built-ins): a consumer's generator may copy it whole.
229
+ */
230
+ export declare function planHookCommandSpawn(entry: {
231
+ readonly command: string;
232
+ readonly args?: readonly string[];
233
+ readonly plugin?: {
234
+ readonly options?: Readonly<Record<string, string | HookPluginOptionRef>>;
235
+ };
236
+ }, paths: Readonly<Record<HookCommandPathName, string | undefined>>, resolved?: Readonly<Record<string, string | HookPluginOptionRef>>): HookCommandSpawnPlan;
237
+ /**
238
+ * The one sentence for a {@link HookCommandSpawnRefusal}: fixed words plus the path name, or the option key passed through this package's echo of caller text (control and
239
+ * bidirectional characters stripped, long keys cut). Never a value — the refusal carries none. A runner and a sender show this sentence instead of writing their own.
240
+ */
241
+ export declare function hookCommandSpawnRefusalSentence(refusal: HookCommandSpawnRefusal): string;
242
+ /** The cap on {@link measureHookPluginContext}'s count for one entry's plugin context, in UTF-16 code units (a literal type: the measure's own copy is tied to it at compile time). */
243
+ export declare const HOOK_PLUGIN_CONTEXT_CHARS_CAP = 8192;
244
+ /**
245
+ * How big one entry's plugin context is, against {@link HOOK_PLUGIN_CONTEXT_CHARS_CAP}: `chars` = the length of `name` + `root` + `dataDir` + for each option, its key + its value — a
246
+ * string value counts its length, a reference counts its `entry` (the `kind` word and the JSON structure count nothing). Counted per entry. `chars > cap` is over the cap (what a runner
247
+ * answers then is the runner's). The input is a context the classifier accepted. SELF-CONTAINED (no free name but JavaScript built-ins): a consumer's generator may copy it whole.
248
+ */
249
+ export declare function measureHookPluginContext(plugin: HookPluginContext): {
250
+ readonly chars: number;
251
+ readonly cap: typeof HOOK_PLUGIN_CONTEXT_CHARS_CAP;
252
+ };
86
253
  /** `shell` values: 'bash' = the user's $SHELL family; 'powershell' = pwsh. Default bash. */
87
254
  declare const HOOK_SHELLS: readonly ["bash", "powershell"];
88
255
  /**
@@ -94,7 +261,8 @@ declare const HOOK_SHELLS: readonly ["bash", "powershell"];
94
261
  * presence of `args` is the switch), `shell` (see above), `async` = run in background without blocking, `asyncRewake` = background + wake the model on exit 2,
95
262
  * `onFailure` (see {@link HOOK_ON_FAILURE_WORDS}), and — CC marks them `@internal` — `rewakeMessage` (the prefix of the system-reminder the model gets when an `asyncRewake` hook exits
96
263
  * 2) and `rewakeSummary` (the one-line summary the user sees then): both a string of at least one character (`nonEmpty`), `cloud` (`any`: CC reads every value outside {@link HOOK_CLOUD_WORDS} as `skip`
97
- * and loads the file, so there is nothing to judge — the value is carried as written and the reader folds);
264
+ * and loads the file, so there is nothing to judge — the value is carried as written and the reader folds), and — this contract's own column, not CC's (31.0.0) — `plugin`
265
+ * (the plugin context: {@link HookPluginContext}; a bad one is a bad piece);
98
266
  * · prompt / agent: `prompt` ($ARGUMENTS = the hook input JSON), `model`; prompt only: `continueOnBlock` = the `continue` value of the `decision: "block"` the entry produces when its
99
267
  * verdict is not ok (CC default false: the turn ends);
100
268
  * · http: `url`, `headers` (values may reference $NAMEs listed in `allowedEnvVars` — env-NAME interpolation only, the config never carries a
@@ -113,6 +281,7 @@ export declare const HOOK_ENTRY_FIELDS: {
113
281
  readonly rewakeMessage: "nonEmpty?";
114
282
  readonly rewakeSummary: "nonEmpty?";
115
283
  readonly cloud: "any?";
284
+ readonly plugin: "plugin?";
116
285
  readonly if: "string?";
117
286
  readonly timeout: "seconds?";
118
287
  readonly statusMessage: "string?";
@@ -164,7 +333,7 @@ export declare const HOOK_ENTRY_FIELDS: {
164
333
  };
165
334
  /** The type of {@link HOOK_ENTRY_FIELDS}: per entry type, field name → field kind (literal types). */
166
335
  export type HookEntryFields = typeof HOOK_ENTRY_FIELDS;
167
- type HookFieldBaseValue<B> = B extends "text" | "nonEmpty" | "string" ? string : B extends "shell" ? (typeof HOOK_SHELLS)[number] : B extends "onFailure" ? HookOnFailure : B extends "any" ? unknown : B extends "boolean" ? boolean : B extends "seconds" ? number : B extends "stringRecord" ? Record<string, string> : B extends "stringList" | "argv" ? string[] : B extends "record" ? Record<string, unknown> : never;
336
+ type HookFieldBaseValue<B> = B extends "text" | "nonEmpty" | "string" ? string : B extends "shell" ? (typeof HOOK_SHELLS)[number] : B extends "onFailure" ? HookOnFailure : B extends "any" ? unknown : B extends "boolean" ? boolean : B extends "seconds" ? number : B extends "stringRecord" ? Record<string, string> : B extends "stringList" | "argv" ? string[] : B extends "record" ? Record<string, unknown> : B extends "plugin" ? HookPluginContext : never;
168
337
  type HookFieldValue<K> = K extends `${infer B}?` ? HookFieldBaseValue<B> : HookFieldBaseValue<K>;
169
338
  type Flat<O> = {
170
339
  [K in keyof O]: O[K];
@@ -265,10 +434,12 @@ export type HooksClassification = {
265
434
  * and what loads. Pure: reads `settingsDoc` (the WHOLE document — guard signs outside `hooks` count), never modifies it, no I/O, no sentences.
266
435
  * Rejections and drops are listed in document order.
267
436
  *
268
- * COPYING THIS FUNCTION (client-core's generator, or any consumer that emits it as source): its one free name besides JavaScript built-ins is
269
- * {@link HOOK_EVENTS}. The copy's scope must be GIVEN that name, bound to this package's runtime export `HOOK_EVENTS` (the upstream constant —
270
- * the generator injects it as a registered value, it does not re-declare it). Never paste a literal event list into the generated text: that is
271
- * a second event table, which the upstream drift gate (it watches `HOOK_EVENTS`) cannot see, and which goes stale the first time CC adds an event.
437
+ * COPYING THIS FUNCTION (client-core's generator, or any consumer that emits it as source): its free names besides JavaScript built-ins are its
438
+ * REGISTERED names — {@link HOOK_EVENTS}, {@link pluginOptionKeysProblem} and `isAbsoluteHostPath` (this package's runtime exports) and `readCredentialRef`
439
+ * (the runtime export of `@sema-agent/primitives`, this package's runtime dependency). The copy's scope must be GIVEN each of them, bound to the export
440
+ * it names (the generator injects each as a registered value, it does not re-declare it; `pluginOptionKeysProblem` in turn registers {@link pluginOptionEnvName}).
441
+ * Never paste a literal event list or a copied judgement into the generated text: a second event table is one the upstream drift gate (it watches
442
+ * `HOOK_EVENTS`) cannot see and goes stale the first time CC adds an event; a copied judgement is a second reading that drifts from its owner unseen.
272
443
  * The module-private declarations the closure uses (the `HOOK_*` constants and `hook*` helpers below the classifier line) are copied with it;
273
444
  * the hooks-classify test file (group ⑤) pins that the free names are exactly these.
274
445
  */