@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 +64 -36
- package/dist/config.js +238 -149
- package/dist/exit-codes.d.ts +20 -0
- package/dist/exit-codes.js +20 -0
- package/dist/fail-policy.d.ts +7 -7
- package/dist/fail-policy.js +8 -8
- package/dist/index.d.ts +13 -28
- package/dist/index.js +8 -21
- package/dist/is-plain-object.d.ts +1 -1
- package/dist/is-plain-object.js +1 -1
- package/dist/protected-paths.d.ts +3 -3
- package/dist/protected-paths.js +3 -3
- package/dist/telemetry.d.ts +24 -21
- package/dist/telemetry.js +36 -29
- package/dist/transcript.d.ts +16 -19
- package/dist/transcript.js +11 -14
- package/package.json +1 -1
- package/schema/polydeukes.schema.json +38 -9
package/dist/config.d.ts
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Config schema
|
|
2
|
+
* Config schema and the `defineConfig()` validator — config as data.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
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
|
|
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
|
|
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
|
|
27
|
+
* `DisciplineForbid` — the delta-family predicate value.
|
|
31
28
|
*
|
|
32
|
-
* The string shorthand is equivalent to `{ added }
|
|
33
|
-
*
|
|
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
|
-
* `
|
|
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
|
|
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
|
|
71
|
+
* adapter vocabulary whose value passes through verbatim.
|
|
67
72
|
*/
|
|
68
73
|
requirePrecedent?: Record<string, unknown>;
|
|
69
74
|
};
|
|
70
75
|
/**
|
|
71
|
-
* `
|
|
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
|
|
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 —
|
|
103
|
+
/** raw protected path patterns — normalized downstream, never here */
|
|
82
104
|
protectedPaths?: string[];
|
|
83
105
|
/**
|
|
84
|
-
* adapter namespaces
|
|
85
|
-
*
|
|
86
|
-
*
|
|
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
|
|
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
|
|
97
|
-
*
|
|
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
|
|
103
|
-
*
|
|
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)`)
|
|
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
|
|
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
|
-
/**
|
|
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
|
|
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
|
|
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
|
|
160
|
-
* non-string element, or `adapters` is not a map of
|
|
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;
|