@lmzhen/dsh-evolution-core 0.5.0 → 0.6.1

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.
@@ -106,6 +106,12 @@ export declare const DEFAULT_REVIEW_CONTEXT_MESSAGES = 60;
106
106
  export declare const DEFAULT_REVIEW_MESSAGE_CHARS = 2000;
107
107
  export declare const DEFAULT_CURATOR_BOOT_GRACE_SECONDS = 10;
108
108
  export declare const DEFAULT_CURATOR_REVIEW_MAX_TOKENS = 2048;
109
+ /** Threat-scan WINDOW SIZE (not a total cap — E-12: the whole text is scanned in
110
+ * overlapping windows, so content beyond this stays in scope). The coverage
111
+ * floor is `PATTERN_OVERLAP + 1` (V6-05). Single home for the core scanners'
112
+ * default parameter and clamp fallback, plus evolution-threat's Config default
113
+ * — the two packages previously wrote 65_536 independently (G0/S0.1). */
114
+ export declare const DEFAULT_THREAT_MAX_SCAN_CHARS = 65536;
109
115
  /** 0.3.17 (S3.10, T-1): control-plane fields a model-facing write call may
110
116
  * never carry — single source for plan-validator, evolution-policy and the
111
117
  * threat scanner (they used to each hardcode the list).
@@ -56,6 +56,7 @@ export * from './threats.ts';
56
56
  export * from './tool-dispatch.ts';
57
57
  export * from './usage.ts';
58
58
  export * from './constants.ts';
59
+ export * from './params.ts';
59
60
  export * from './numeric.ts';
60
61
  export * from './opt-in.ts';
61
62
  //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,195 @@
1
+ /**
2
+ * Parameter id consolidation (G0/S0.2): one semantic gets ONE id.
3
+ *
4
+ * Nine places in this family carry the same value under two carriers: three use
5
+ * the SAME name in two carriers (reviewMode, staleAfterDays, archiveAfterDays —
6
+ * resolved by the existing policy-shadows-row rule) and six use DIFFERENT names.
7
+ * This module owns the six: the policy/snapshot name is the canonical id, the
8
+ * plugin-row name is a deprecated alias kept readable for one minor version
9
+ * (0.6.x) and removable in 0.7.0.
10
+ *
11
+ * Reading stays compatible (a carrier still spelling the legacy name resolves),
12
+ * writing is strict (the write path accepts canonical ids only, so no new
13
+ * document is created under a deprecated name).
14
+ * @module
15
+ */
16
+ /** Deprecated alias (plugin-row name) -> canonical id (policy/snapshot name). */
17
+ export declare const PARAM_ALIASES: Readonly<Record<string, string>>;
18
+ /**
19
+ * Resolve any parameter id to its canonical form.
20
+ * @param id - canonical id or deprecated alias.
21
+ * @returns the canonical id; ids without an alias pass through unchanged.
22
+ */
23
+ export declare function resolveParamId(id: string): string;
24
+ /**
25
+ * Whether an id is a deprecated alias.
26
+ * @param id - parameter id to test.
27
+ * @returns true when the id must be migrated to its canonical form.
28
+ */
29
+ export declare function isDeprecatedParamId(id: string): boolean;
30
+ /**
31
+ * Guard for the write path: only canonical ids may be written.
32
+ * @param id - parameter id a caller intends to write.
33
+ * @returns the canonical id.
34
+ * @throws {Error} when the id is a deprecated alias; the message names both ids.
35
+ */
36
+ export declare function canonicalWriteId(id: string): string;
37
+ /**
38
+ * Read a parameter from a carrier that may still spell the legacy name.
39
+ * @param carrier - config/snapshot object to read from, or undefined.
40
+ * @param id - canonical id (a deprecated alias is accepted and resolved first).
41
+ * @returns the canonical value when present, else the alias value, else undefined.
42
+ */
43
+ export declare function readParam(carrier: object | undefined, id: string): unknown;
44
+ /** Exposure group (design §7.2): the unit a developer changes together. */
45
+ export type ParamGroup = 'library' | 'write-caps' | 'review' | 'memory' | 'curator' | 'deployment' | 'internal';
46
+ /** Exposure tier (design §7.1): the interface combination a parameter gets. */
47
+ export type ParamTier = 'E0' | 'E1' | 'E2' | 'E3' | 'E4';
48
+ /** Where the authoritative value lives. */
49
+ export type ParamAuthority = 'code' | 'cordis' | 'install';
50
+ /**
51
+ * One parameter's exposure contract (design §8.1).
52
+ *
53
+ * MACHINE-READ CONTRACT: the entries below are written ONE PER LINE with the
54
+ * key order id, group, tier, authority, owner, applies, docAnchor, summary so
55
+ * the .mjs generators (`gen-param-docs.mjs`, `verify-param-registry.mjs`) can
56
+ * parse this text without importing TypeScript. `param-registry.spec.ts`
57
+ * asserts that the parsed text and this runtime array agree, so the two sides
58
+ * cannot drift.
59
+ *
60
+ * `applies` is the SETTINGS-side timing: 'none' means the parameter is not
61
+ * writable through the user layer (a cordis.yml change still follows the
62
+ * deployment's patch-reload policy).
63
+ */
64
+ export interface ParamExposure {
65
+ id: string;
66
+ group: ParamGroup;
67
+ tier: ParamTier;
68
+ authority: ParamAuthority;
69
+ owner: string;
70
+ applies: 'live' | 'restart' | 'none';
71
+ docAnchor: string;
72
+ summary: string;
73
+ }
74
+ /**
75
+ * The parameter registry. G1/S1.1 seeds it with the review group (G-C); the
76
+ * remaining groups land in S2.1. E3 = behaviour preference the user may change
77
+ * (live); E2 = resource or identity knob that stays with the deployment.
78
+ */
79
+ export declare const PARAM_EXPOSURE: readonly ParamExposure[];
80
+ /** The settings namespace each OWNER PACKAGE registers (design §7.2).
81
+ *
82
+ * Keyed by owner rather than by group because a namespace has exactly one
83
+ * registrant (the platform refuses a second registration of the same name),
84
+ * while a group may span packages — group 'memory' is served by memory-files and
85
+ * tool-memory, each owning its own section. A package without an entry has no
86
+ * user layer (its knobs stay deployment-only). */
87
+ export declare const PARAM_NAMESPACES: Readonly<Record<string, string>>;
88
+ /** Structural view of one registered settings scope (platform Service Definition).
89
+ * Declared locally so this module keeps its zero-import, zero-dependency shape. */
90
+ interface SettingsScopeLike {
91
+ get(): unknown;
92
+ watch(callback: (next: unknown, prev: unknown) => void): () => void;
93
+ }
94
+ /** Structural view of the platform settings provider; only the members the
95
+ * family uses are named. A missing `describe` disables the user layer loudly
96
+ * (see {@link paramSectionOverrides}) instead of reading as 'no overrides'. */
97
+ export interface SettingsProviderLike {
98
+ register(namespace: string, schema: unknown, options: {
99
+ base: unknown;
100
+ applies?: 'live' | 'restart';
101
+ /** Owner-side refusal of a resolved section (cross-field rules the schema
102
+ * cannot express); throwing refuses the WRITE that produced the value. */
103
+ validate?: (value: unknown) => void;
104
+ }): SettingsScopeLike;
105
+ /** Merge a patch into one namespace's user layer. A stale `expectedRevision`
106
+ * rejects with the platform's SETTINGS_CONFLICT error. */
107
+ update?(namespace: string, patch: object, expectedRevision?: number): Promise<void>;
108
+ describe?(options?: {
109
+ redactSecrets?: boolean;
110
+ }): {
111
+ ns: string;
112
+ /** Current resolved section (schema defaults < base < user). */
113
+ value?: unknown;
114
+ /** Raw user section: a key's PRESENCE marks a user override. */
115
+ user?: Record<string, unknown>;
116
+ /** Monotonic revision of that raw section; a write sends it back. */
117
+ revision?: number;
118
+ /** Owner's declared effect timing. */
119
+ applies?: 'live' | 'restart';
120
+ }[];
121
+ }
122
+ /** Hooks a caller may supply when a section attaches to the settings service.
123
+ * @typeParam T - the section's value type (what `validate` inspects). */
124
+ export interface ParamSectionOptions<T extends object = object> {
125
+ /** Called once when the user layer turns unreadable (a warning, never silent). */
126
+ warn?: (message: string) => void;
127
+ /** Called after every committed change that the reader can observe — the place
128
+ * to REBUILD registration-level facts (the platform's own `installSection`
129
+ * documents the same hook shape). Consumers that read at use time pass nothing. */
130
+ onChange?: () => void;
131
+ /** Refuse a resolved section the owner could not act on: a cross-field rule the
132
+ * schema cannot express (the platform applies this hook to the RESOLVED section,
133
+ * so a user value is judged together with the deployment layer beneath it).
134
+ * Throwing refuses the write that produced the value. */
135
+ validate?: (value: T) => void;
136
+ }
137
+ /** Reader for one parameter section: presence-aware user overrides. */
138
+ export interface ParamOverrides<T extends object> {
139
+ /** The namespace this reader is bound to. */
140
+ readonly namespace: string;
141
+ /** The user-set value for one key, or undefined when the user never set it. */
142
+ get<K extends keyof T & string>(key: K): T[K] | undefined;
143
+ /** The resolved section (defaults < base < user) — display and tests. */
144
+ resolved(): T;
145
+ }
146
+ /**
147
+ * G3: expose one parameter section to the user layer.
148
+ *
149
+ * Precedence stays 'user > deployment > default': the caller keeps reading its
150
+ * deployment carriers (policy snapshot, then the plugin row) and consults
151
+ * {@link ParamOverrides.get} FIRST — an unset key returns undefined, so the
152
+ * deployment value keeps winning and the family's shadowing rules survive.
153
+ *
154
+ * Failure posture: a provider without `describe` (or one whose describe throws)
155
+ * leaves the user layer UNAVAILABLE and warns once — deployment values then
156
+ * apply. Treating an unreadable user layer as 'no overrides' would silently
157
+ * ignore a setting the user did write, so the warning names it.
158
+ * @typeParam T - the section's value type.
159
+ * @param provider - the platform settings provider, or undefined when absent.
160
+ * @param namespace - namespace to register.
161
+ * @param schema - schemastery schema the platform validates against.
162
+ * @param base - composition base layer (the plugin row's values).
163
+ * @param options - warning sink and the change hook.
164
+ * @returns a reader bound to the namespace.
165
+ */
166
+ export declare function paramSectionOverrides<T extends object>(provider: SettingsProviderLike | undefined, namespace: string, schema: unknown, base: T, options?: ParamSectionOptions<T>): ParamOverrides<T>;
167
+ /** Minimal structural view of the cordis context used to attach a section.
168
+ * The callback takes `unknown` on purpose: cordis's own `inject` declares a
169
+ * `Context` parameter, and a callback accepting `unknown` is assignable to it
170
+ * (parameter contravariance) while a narrower shape is not. */
171
+ export interface SettingsHostLike {
172
+ inject(names: string[], callback: (ctx: unknown) => void): unknown;
173
+ }
174
+ /**
175
+ * Attach a parameter section through the optional settings service.
176
+ * @typeParam T - the section's value type.
177
+ * @param host - the plugin context (structurally typed).
178
+ * @param namespace - namespace to register.
179
+ * @param schema - schemastery schema the platform validates against.
180
+ * @param base - composition base layer (the plugin row's values).
181
+ * @param options - warning sink and the change hook.
182
+ * @returns a reader that follows the provider when it appears.
183
+ */
184
+ export declare function installParamSection<T extends object>(host: SettingsHostLike, namespace: string, schema: unknown, base: T, options?: ParamSectionOptions<T>): ParamOverrides<T>;
185
+ /**
186
+ * Number-typed read over {@link readParam}: the family's tunables are numbers,
187
+ * and a value of another type reads as absent so the caller's default applies
188
+ * (the same outcome the numeric clamps produce for a malformed value).
189
+ * @param carrier - config/snapshot object to read from, or undefined.
190
+ * @param id - canonical id (a deprecated alias is accepted and resolved first).
191
+ * @returns the resolved number, or undefined when absent or not a number.
192
+ */
193
+ export declare function readNumberParam(carrier: object | undefined, id: string): number | undefined;
194
+ export {};
195
+ //# sourceMappingURL=params.d.ts.map
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@lmzhen/dsh-evolution-core",
3
3
  "description": "Shared stores, prompts, signals and lifecycle logic for the dsh-evolution plugin family (community build)",
4
- "version": "0.5.0",
4
+ "version": "0.6.1",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },