@polydeukes/core 0.3.0 → 0.5.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/dist/config.d.ts CHANGED
@@ -1,18 +1,15 @@
1
1
  /**
2
- * Config schema v2 + `defineConfig()` validator — config as data (CONFIG-04).
2
+ * Config schema and the `defineConfig()` validator — config as data.
3
3
  *
4
- * This is the single settings surface the three areas share (covenant's `protectedPaths`,
5
- * ledger's `testCmd`, memory's ticket pattern all reference this shape). Since schema v2 the
6
- * input is pure JSON-representable data: `testCmd` is a `{scope}` template string, and
7
- * `defineConfig` is the runtime validator for parsed unknown data (the CONFIG-03 loader feeds
8
- * it values the compiler never saw). It stays a pure function — zero file I/O, zero runtime
9
- * dependencies (hand-rolled validation; the published JSON Schema is a sibling artifact the
10
- * source never reads).
4
+ * The single settings surface the areas share. The input is pure JSON-representable data,
5
+ * and `defineConfig` is the runtime validator for parsed unknown values the compiler never
6
+ * saw. It stays a pure function no file I/O and no runtime dependencies: validation is
7
+ * hand-rolled, and the published JSON Schema is a sibling artifact this source never reads.
11
8
  */
12
- /** Conventional default telemetry log path (PRD §4.3) — local-only observation data. */
9
+ /** Conventional default telemetry log path — local-only observation data. */
13
10
  export declare const DEFAULT_TELEMETRY_LOG_PATH = ".polydeukes/roi.log";
14
11
  /**
15
- * `LanguageProfile` — the unit of the language axis (PRD §4.1).
12
+ * `LanguageProfile` — the unit of the language axis.
16
13
  *
17
14
  * `testCmd` is a shell command template: every literal `{scope}` token is substituted at
18
15
  * resolve time, and the core only carries the resulting string — it never interprets it.
@@ -27,16 +24,22 @@ export type LanguageProfile = {
27
24
  testCmd: string;
28
25
  };
29
26
  /**
30
- * `DisciplineForbid` — the delta-family predicate value (COVENANT-10 §4.1).
27
+ * `DisciplineForbid` — the delta-family predicate value.
31
28
  *
32
- * The string shorthand is equivalent to `{ added }`; `removed`/`present` directions are
33
- * deferred (COVENANT-12) and rejected by validation.
29
+ * The string shorthand is equivalent to `{ added }`. It is the only direction that exists;
30
+ * anything else is rejected by validation.
34
31
  */
35
32
  export type DisciplineForbid = string | {
36
33
  added: string;
37
34
  };
38
35
  /**
39
- * `DisciplineEntry` — one user-declared discipline (COVENANT-10 §4.1). Pure JSON data.
36
+ * `EnforceLevel` — an entry's own rung on the promotion ladder. `advise` records a break
37
+ * without stopping it; `block` pins the entry at block whatever default the ladder later
38
+ * adopts. Absence means advise; `block` is the promotion rung.
39
+ */
40
+ export type EnforceLevel = 'block' | 'advise';
41
+ /**
42
+ * `DisciplineEntry` — one user-declared discipline. Pure JSON data.
40
43
  *
41
44
  * Exactly one predicate key (`forbid` | `immutable` | `forbidCommand` |
42
45
  * `requirePrecedent`) per entry; `in`/`except` scope the delta and context families.
@@ -46,8 +49,10 @@ export type DisciplineForbid = string | {
46
49
  export type DisciplineEntry = {
47
50
  /** unique handle — telemetry label and verdict reason prefix */
48
51
  id: string;
49
- /** prose rationale, documentation only — never judged */
52
+ /** prose rationale — never judged, and carried into the break message */
50
53
  why?: string;
54
+ /** the author's level; composes with the observer's surface level, lenient side winning */
55
+ enforce?: EnforceLevel;
51
56
  /** delta/context-family scope: glob(s) the file path must match (absent = every file change) */
52
57
  in?: string | string[];
53
58
  /** delta/context-family scope: glob(s) excluded after `in` */
@@ -63,44 +68,61 @@ export type DisciplineEntry = {
63
68
  /**
64
69
  * context family — the session evidence one edit requires beforehand. Exactly one
65
70
  * evidence key. The core owns and fully validates `command`; every other key is
66
- * adapter vocabulary whose value passes through verbatim (CONFIG-07 layering).
71
+ * adapter vocabulary whose value passes through verbatim.
67
72
  */
68
73
  requirePrecedent?: Record<string, unknown>;
69
74
  };
70
75
  /**
71
- * `PolydeukesConfig` — the input shape a user writes (PRD §4.1). JSON-serializable data.
76
+ * `DisciplineDraft` — an unpromoted discipline: the promotion ladder's first rung,
77
+ * registered as prose ahead of any predicate.
78
+ *
79
+ * A draft is declared, never inferred — only the literal `draft: true` makes one, and an
80
+ * entry with neither a predicate nor the marker stays a validation error. It carries no
81
+ * predicate, scope, or trigger key, produces no registration, no judgment, and no
82
+ * telemetry row; `pdks explain` renders it as unpromoted.
83
+ */
84
+ export type DisciplineDraft = {
85
+ /** unique handle in the same label space as judged entries and meta-covenant labels */
86
+ id: string;
87
+ /** the draft's whole body — required prose, unlike the judged families' optional why */
88
+ why: string;
89
+ /** the explicit marker; only the literal true exists (false is rejected as dead data) */
90
+ draft: true;
91
+ };
92
+ /**
93
+ * `PolydeukesConfig` — the input shape a user writes. JSON-serializable data.
72
94
  *
73
95
  * Language keys (`typescript`, `python`, …) are user *values*, not the core's vocabulary —
74
96
  * no language or tool literal appears in the core source.
75
97
  */
76
98
  export type PolydeukesConfig = {
77
- /** IDE schema reference (CONFIG-03) — accepted and ignored, never part of the resolution */
99
+ /** IDE schema reference — accepted and ignored, never part of the resolution */
78
100
  $schema?: string;
79
101
  /** language axis, first-class. keys are user values ('typescript', 'python', …) */
80
102
  languages: Record<string, LanguageProfile>;
81
- /** raw protected path patterns — normalization is CONFIG-02's job */
103
+ /** raw protected path patterns — normalized downstream, never here */
82
104
  protectedPaths?: string[];
83
105
  /**
84
- * adapter namespaces (CONFIG-07) — keys are ecosystem values (never validated), each
85
- * value is that adapter's own settings object, passed through verbatim (the vocabulary
86
- * belongs to the adapter, whose own validator judges the contents)
106
+ * adapter namespaces — keys are ecosystem values (never validated), each value is that
107
+ * adapter's own settings object, passed through verbatim (the vocabulary belongs to the
108
+ * adapter, whose own validator judges the contents)
87
109
  */
88
110
  adapters?: Record<string, Record<string, unknown>>;
89
111
  telemetry?: {
90
- /** conventional default applies when omitted (§4.3) */
112
+ /** conventional default applies when omitted */
91
113
  logPath?: string;
92
114
  };
93
115
  /** user-declared disciplines — validated here, compiled by the covenant package */
94
- disciplines?: DisciplineEntry[];
116
+ disciplines?: (DisciplineEntry | DisciplineDraft)[];
95
117
  /**
96
- * TTL witness values for the covenant valve seam (CONFIG-05) — consumed at
97
- * assembly time, validated here
118
+ * TTL witness values for the covenant valve seam — consumed at assembly time,
119
+ * validated here
98
120
  */
99
121
  witness?: {
100
122
  /**
101
123
  * the agreed phrase a human types alone on a message's first line — quoting it
102
- * mid-sentence is a mention, not an invocation (COVENANT-15). Non-empty after
103
- * trimming; the value itself is free (provenance, not secrecy, is the defence)
124
+ * mid-sentence is a mention, not an invocation. Non-empty after trimming; the value
125
+ * itself is free, since provenance rather than secrecy is the defence
104
126
  */
105
127
  token: string;
106
128
  /** validity window in minutes from the user message's timestamp — finite and > 0 */
@@ -110,11 +132,11 @@ export type PolydeukesConfig = {
110
132
  /**
111
133
  * `ResolvedLanguageProfile` — a {@link LanguageProfile} with its template compiled.
112
134
  *
113
- * Consumers keep the callable shape (`testCmd(scope)`), identical to schema v1 (LEDGER-05).
135
+ * Consumers keep the callable shape (`testCmd(scope)`).
114
136
  */
115
137
  export type ResolvedLanguageProfile = {
116
138
  productionGlob: string | string[];
117
- /** compiled from the template — consumers keep the callable shape (LEDGER-05) */
139
+ /** compiled from the template — consumers keep the callable shape */
118
140
  testCmd: (scope: string) => string;
119
141
  };
120
142
  /**
@@ -130,8 +152,14 @@ export type ResolvedConfig = {
130
152
  telemetry: {
131
153
  logPath: string;
132
154
  };
133
- /** validated discipline data, passed through verbatim (absent stays absent) */
155
+ /**
156
+ * validated judged entries only — drafts are split out at resolution time so the
157
+ * covenant compiler has no path that receives one. Present whenever the input
158
+ * declared a `disciplines` array, holding exactly its judged entries in order.
159
+ */
134
160
  disciplines?: DisciplineEntry[];
161
+ /** validated drafts in declaration order (absent when the input carries none) */
162
+ drafts?: DisciplineDraft[];
135
163
  /** validated witness data, passed through verbatim (absent stays absent) */
136
164
  witness?: {
137
165
  token: string;
@@ -139,7 +167,7 @@ export type ResolvedConfig = {
139
167
  };
140
168
  };
141
169
  /**
142
- * `ConfigValidationError` — raised when a config fails structural validation (PRD §4.3).
170
+ * `ConfigValidationError` — raised when a config fails structural validation.
143
171
  *
144
172
  * The message names the offending field path so the developer sees exactly what is wrong.
145
173
  * This throw is a developer-time error (config authoring), a different axis from the
@@ -150,13 +178,13 @@ export declare class ConfigValidationError extends Error {
150
178
  }
151
179
  /**
152
180
  * Validate parsed unknown data as a {@link PolydeukesConfig} and return a
153
- * {@link ResolvedConfig} with defaults filled and templates compiled (PRD §4.3).
154
- * Pure — no file I/O.
181
+ * {@link ResolvedConfig} with defaults filled and templates compiled. Pure — no file I/O.
155
182
  *
156
183
  * Throws {@link ConfigValidationError} (naming the offending field path) when the top level
157
184
  * is not a plain object, any object level carries an unknown key, `languages` is
158
185
  * missing/empty, any language's `productionGlob` is missing/empty, any `testCmd` is not a
159
- * non-empty string template, `telemetry.logPath` is not a string, `protectedPaths` carries a
160
- * non-string element, or `adapters` is not a map of plain-object namespaces.
186
+ * non-empty string template, `telemetry.logPath` is not a non-empty string after trimming,
187
+ * `protectedPaths` carries a non-string or empty element, or `adapters` is not a map of
188
+ * plain-object namespaces.
161
189
  */
162
190
  export declare function defineConfig(config: unknown): ResolvedConfig;