@aiwayds/dsh-model-sync 0.2.1 → 0.2.3
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/README.md +2 -2
- package/README.zh-CN.md +2 -2
- package/lib/index.js +25 -3
- package/lib/index.js.map +1 -1
- package/lib/remote-catalog.d.ts +93 -3
- package/lib/remote-catalog.js +172 -23
- package/lib/remote-catalog.js.map +1 -1
- package/lib/writer.d.ts +65 -14
- package/lib/writer.js +178 -21
- package/lib/writer.js.map +1 -1
- package/package.json +2 -2
- package/src/index.ts +23 -2
- package/src/remote-catalog.ts +243 -24
- package/src/writer.ts +265 -27
package/lib/writer.d.ts
CHANGED
|
@@ -1,23 +1,47 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Write translated model profiles to dsh settings via the settings.mutate API.
|
|
3
3
|
*
|
|
4
|
-
* Key behaviors (design doc §4
|
|
4
|
+
* Key behaviors (design doc §4, revised for the modelOverrides mutual
|
|
5
|
+
* exclusion, 2026-09-03):
|
|
5
6
|
* - Change-only writes: compare the merged target (target ⊕ modelOverrides)
|
|
6
7
|
* against the raw user segment (desc.user), not resolved values (which have
|
|
7
8
|
* schema defaults applied)
|
|
8
9
|
* - modelOverrides are the user's own per-model channel (think levels,
|
|
9
|
-
* narrowed context windows).
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
10
|
+
* narrowed context windows). The dsh llm-pi-ai validation refuses a route
|
|
11
|
+
* whose settings carry a models list beside non-empty modelOverrides, so a
|
|
12
|
+
* models write must clear the key in the same mutate: the overrides are
|
|
13
|
+
* folded into the written models, an `unset` op removes the key (set+unset
|
|
14
|
+
* apply atomically), and the raw overrides are staged in the models-store
|
|
15
|
+
* BEFORE the mutate (store-first). Store-first is the data-safety
|
|
16
|
+
* invariant: settings is the authoritative, lossless source in every
|
|
17
|
+
* failure window — a failed/rejected mutate leaves the key in place and
|
|
18
|
+
* the settings-wins rule (see Replay below) suppresses the staged copy,
|
|
19
|
+
* while a failed store write skips the mutate entirely ('store-unavailable',
|
|
20
|
+
* settings untouched), so the key is never unset without a stored copy.
|
|
21
|
+
* Earlier behaviors both failed:
|
|
22
|
+
* v0.1.5 unset without persisting (the next round clobbered the folded
|
|
23
|
+
* fields), v0.1.6 preserved the key forever (every mutate was rejected by
|
|
24
|
+
* the mutual-exclusion validation and nothing landed).
|
|
25
|
+
* - Replay: when settings carries no overrides but the models-store does, the
|
|
26
|
+
* stored values fold into the target with no unset op — the merged view is
|
|
27
|
+
* re-derived identically every round, so change-only detection stays
|
|
28
|
+
* stable and the customizations survive. Settings overrides win over
|
|
29
|
+
* stored ones (a re-added key is the user's latest intent).
|
|
14
30
|
* - Revision conflict retry: catch SETTINGS_CONFLICT, re-read, re-translate,
|
|
15
31
|
* re-write once
|
|
16
32
|
* - Never touches ~/.dsh/settings.yaml directly — only through settings.mutate
|
|
33
|
+
* - Store read failure: when the models-store read fails (corrupt JSON,
|
|
34
|
+
* EACCES, …) AND settings carries no overrides key, skip the round with
|
|
35
|
+
* reason 'store-unavailable' and leave settings.models untouched — the
|
|
36
|
+
* already-landed folded values are the authoritative fallback. A write
|
|
37
|
+
* triggered from a settings-side key is unaffected: settings-wins, and the
|
|
38
|
+
* atomic writeDoc replaces it on disk (heals the corruption as a side
|
|
39
|
+
* effect).
|
|
17
40
|
*
|
|
18
41
|
* @module dsh-model-sync/writer
|
|
19
42
|
*/
|
|
20
43
|
import type { SettingsModelProfile } from './translate.ts';
|
|
44
|
+
import type { ModelsStoreAccessor } from './remote-catalog.ts';
|
|
21
45
|
/**
|
|
22
46
|
* The settings seam this module needs — injected via parameter, not imported
|
|
23
47
|
* from dsh internals (design doc §4.1: "writer.ts 不能直接 import dsh 的
|
|
@@ -46,7 +70,22 @@ export interface Logger {
|
|
|
46
70
|
}
|
|
47
71
|
export interface SyncResult {
|
|
48
72
|
wrote: boolean;
|
|
49
|
-
reason: 'no-change' | 'wrote' | 'conflict-retry-ok' | 'conflict-retry-failed' | 'mutate-rejected' | 'skipped';
|
|
73
|
+
reason: 'no-change' | 'wrote' | 'conflict-retry-ok' | 'conflict-retry-failed' | 'mutate-rejected' | 'store-unavailable' | 'skipped';
|
|
74
|
+
/**
|
|
75
|
+
* Where the folded overrides came from: 'settings' = the key was present
|
|
76
|
+
* (folded + unset in the same mutate, staged in the models-store before
|
|
77
|
+
* the mutate — store-first); 'store' = replayed from the models-store (no
|
|
78
|
+
* unset). Absent when no overrides were involved at all.
|
|
79
|
+
*/
|
|
80
|
+
overridesSource?: 'settings' | 'store';
|
|
81
|
+
/**
|
|
82
|
+
* Override ids with no matching entry in the written target. 'settings'
|
|
83
|
+
* source: they were dropped from settings by the unset but are kept in the
|
|
84
|
+
* models-store verbatim (and apply again if the id shows up in a later
|
|
85
|
+
* target). 'store' source: they simply stay stored. Undefined when no
|
|
86
|
+
* overrides were involved.
|
|
87
|
+
*/
|
|
88
|
+
droppedOverrideIds?: string[];
|
|
50
89
|
}
|
|
51
90
|
/**
|
|
52
91
|
* Deep equality check for two settings model profile arrays.
|
|
@@ -56,19 +95,31 @@ export declare function profilesEqual(current: SettingsModelProfile[], target: S
|
|
|
56
95
|
/**
|
|
57
96
|
* Write translated model profiles to settings for a given route.
|
|
58
97
|
*
|
|
59
|
-
* Implements the full §4 protocol
|
|
98
|
+
* Implements the full §4 protocol (revised for the modelOverrides mutual
|
|
99
|
+
* exclusion):
|
|
60
100
|
* 1. Get revision from describe()
|
|
61
|
-
* 2.
|
|
62
|
-
*
|
|
101
|
+
* 2. Resolve the overrides to fold: the settings key when non-empty, the
|
|
102
|
+
* models-store replay otherwise; merge into the target (override wins per
|
|
103
|
+
* field)
|
|
63
104
|
* 3. Change-only write: skip when the raw user-segment models already equal
|
|
64
|
-
* the merged target
|
|
65
|
-
*
|
|
66
|
-
*
|
|
105
|
+
* the merged target — except when the settings key is present, because the
|
|
106
|
+
* models+overrides combo is refused by the llm-pi-ai validation (the
|
|
107
|
+
* set+unset must run to move the document out of the refused shape)
|
|
108
|
+
* 4. Store-first: when the settings key is present, stage the raw overrides
|
|
109
|
+
* in the models-store BEFORE the mutate; a store write failure skips the
|
|
110
|
+
* mutate entirely and reports 'store-unavailable' (settings untouched —
|
|
111
|
+
* the key is never unset without a stored copy). Then call mutate with
|
|
112
|
+
* expectedRevision: one `set` on the models path, plus an `unset` on the
|
|
113
|
+
* modelOverrides path (atomic in a single mutate).
|
|
114
|
+
* 5. On SETTINGS_CONFLICT: re-read, re-translate (caller's job), re-resolve
|
|
115
|
+
* the overrides from the fresh descriptor, stage again (store-first),
|
|
116
|
+
* re-write once
|
|
67
117
|
*
|
|
68
118
|
* @param settings The settings service (injected, not imported)
|
|
69
119
|
* @param route The provider route id
|
|
70
120
|
* @param target Translated settings-writable entries (sorted by id)
|
|
71
121
|
* @param logger Logger for warnings/errors
|
|
72
122
|
* @param retranslate Callback to re-translate on conflict (receives new revision)
|
|
123
|
+
* @param store The models-store accessor for the overrides replay/persist
|
|
73
124
|
*/
|
|
74
|
-
export declare function syncToSettings(settings: SettingsService | undefined, route: string, target: SettingsModelProfile[], logger: Logger, retranslate?: (newRevision: number) => Promise<SettingsModelProfile[]
|
|
125
|
+
export declare function syncToSettings(settings: SettingsService | undefined, route: string, target: SettingsModelProfile[], logger: Logger, retranslate?: (newRevision: number) => Promise<SettingsModelProfile[]>, store?: ModelsStoreAccessor): Promise<SyncResult>;
|
package/lib/writer.js
CHANGED
|
@@ -98,31 +98,119 @@ function mergeOverrides(target, overrides) {
|
|
|
98
98
|
const override = overrides[entry.id];
|
|
99
99
|
if (override === undefined)
|
|
100
100
|
return entry;
|
|
101
|
-
|
|
101
|
+
// Force the entry's own id back on: an override object that happens to
|
|
102
|
+
// carry an `id` field must not silently re-key the entry in the written
|
|
103
|
+
// models list.
|
|
104
|
+
return { ...entry, ...override, id: entry.id };
|
|
102
105
|
});
|
|
103
106
|
}
|
|
107
|
+
/**
|
|
108
|
+
* Override ids that cannot fold into the target (no entry carries the id).
|
|
109
|
+
* Sorted so the report line is deterministic.
|
|
110
|
+
*/
|
|
111
|
+
function droppedOverrideIds(overrides, mergedTarget) {
|
|
112
|
+
if (overrides === undefined)
|
|
113
|
+
return undefined;
|
|
114
|
+
const targetIds = new Set(mergedTarget.map((entry) => entry.id));
|
|
115
|
+
return Object.keys(overrides).filter((id) => !targetIds.has(id)).sort();
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Resolve the overrides to fold for one route: a non-empty settings key wins
|
|
119
|
+
* (a re-added key is the user's latest intent); otherwise the models-store
|
|
120
|
+
* replay applies. An empty `{}` key counts as absent — the dsh validation
|
|
121
|
+
* only refuses non-empty overrides beside a models list, and there is nothing
|
|
122
|
+
* in it to preserve.
|
|
123
|
+
*/
|
|
124
|
+
async function resolveOverrides(desc, route, store) {
|
|
125
|
+
const raw = getRawUserModelOverrides(desc, route);
|
|
126
|
+
if (raw !== undefined && Object.keys(raw).length > 0) {
|
|
127
|
+
return { overrides: raw, source: 'settings' };
|
|
128
|
+
}
|
|
129
|
+
if (store !== undefined) {
|
|
130
|
+
// The store read may now throw on corruption / permission failures
|
|
131
|
+
// (remote-catalog readDoc propagates anything other than ENOENT). We
|
|
132
|
+
// bubble it up: with no settings overrides to fall back on, the caller
|
|
133
|
+
// must skip the round rather than fold an unreplayed target into
|
|
134
|
+
// settings and clobber the folded values. With a settings key in play
|
|
135
|
+
// (the earlier branch above) this code path is never reached, so a
|
|
136
|
+
// settings-side write always proceeds and the atomic writeDoc heals the
|
|
137
|
+
// corruption on its next write.
|
|
138
|
+
const stored = await store.read(route);
|
|
139
|
+
if (stored?.overrides !== undefined && Object.keys(stored.overrides).length > 0) {
|
|
140
|
+
return { overrides: stored.overrides, source: 'store' };
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return { overrides: undefined, source: undefined };
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Stage overrides in the models-store BEFORE the mutate that unsets them
|
|
147
|
+
* from settings (store-first). The RMW runs inside the accessor's
|
|
148
|
+
* serialized write queue via `updateOverrides` — the previous read-then-
|
|
149
|
+
* write pattern read OUTSIDE the queue, which let the fetch side's
|
|
150
|
+
* `store.write` clobber any staged overrides that landed in the window
|
|
151
|
+
* between this read and the eventual write. The queue-internal field-
|
|
152
|
+
* level seed (B1) merges the stage with whatever the route currently
|
|
153
|
+
* holds: `overrides` is replaced by the new value, every other field
|
|
154
|
+
* (`models` / `checkedAt` / `lastModified` / `etag`) is preserved
|
|
155
|
+
* verbatim when present, otherwise seeded with a sensible default.
|
|
156
|
+
* A concurrent fetch write (the C1 race surface) can no longer wipe
|
|
157
|
+
* the stage: the fetch-side patch only names fetch-owned fields, so
|
|
158
|
+
* the seed leaves `overrides` alone. While the settings key is present
|
|
159
|
+
* it always wins over the store (resolveOverrides order); the stored
|
|
160
|
+
* copy is only ever replayed once the key is gone. Callers must treat
|
|
161
|
+
* a throw from here as "skip the mutate": unsetting without a staged
|
|
162
|
+
* copy is the v0.1.5 data loss.
|
|
163
|
+
*
|
|
164
|
+
* The store read may fail on corruption / permission errors (the
|
|
165
|
+
* queue's internal read tolerates them by treating the doc as empty,
|
|
166
|
+
* then the atomic writeDoc replaces the bad file with a fresh,
|
|
167
|
+
* well-formed entry — the self-heal). The field-level seed keeps the
|
|
168
|
+
* resulting entry well-formed (models: [], checkedAt: Date.now(),
|
|
169
|
+
* lastModified: 0, etag: undefined, overrides: <stage>), so the fetch
|
|
170
|
+
* side can consume it on its next round. (A storeless call — store
|
|
171
|
+
* undefined — cannot stage anything and keeps the legacy
|
|
172
|
+
* unset-without-copy behavior; production wiring in index.ts always
|
|
173
|
+
* passes a store.)
|
|
174
|
+
*/
|
|
175
|
+
async function persistOverridesToStore(store, route, overrides) {
|
|
176
|
+
if (store === undefined)
|
|
177
|
+
return;
|
|
178
|
+
await store.updateOverrides(route, overrides);
|
|
179
|
+
}
|
|
104
180
|
// ---------------------------------------------------------------------------
|
|
105
181
|
// syncToSettings (§4)
|
|
106
182
|
// ---------------------------------------------------------------------------
|
|
107
183
|
/**
|
|
108
184
|
* Write translated model profiles to settings for a given route.
|
|
109
185
|
*
|
|
110
|
-
* Implements the full §4 protocol
|
|
186
|
+
* Implements the full §4 protocol (revised for the modelOverrides mutual
|
|
187
|
+
* exclusion):
|
|
111
188
|
* 1. Get revision from describe()
|
|
112
|
-
* 2.
|
|
113
|
-
*
|
|
189
|
+
* 2. Resolve the overrides to fold: the settings key when non-empty, the
|
|
190
|
+
* models-store replay otherwise; merge into the target (override wins per
|
|
191
|
+
* field)
|
|
114
192
|
* 3. Change-only write: skip when the raw user-segment models already equal
|
|
115
|
-
* the merged target
|
|
116
|
-
*
|
|
117
|
-
*
|
|
193
|
+
* the merged target — except when the settings key is present, because the
|
|
194
|
+
* models+overrides combo is refused by the llm-pi-ai validation (the
|
|
195
|
+
* set+unset must run to move the document out of the refused shape)
|
|
196
|
+
* 4. Store-first: when the settings key is present, stage the raw overrides
|
|
197
|
+
* in the models-store BEFORE the mutate; a store write failure skips the
|
|
198
|
+
* mutate entirely and reports 'store-unavailable' (settings untouched —
|
|
199
|
+
* the key is never unset without a stored copy). Then call mutate with
|
|
200
|
+
* expectedRevision: one `set` on the models path, plus an `unset` on the
|
|
201
|
+
* modelOverrides path (atomic in a single mutate).
|
|
202
|
+
* 5. On SETTINGS_CONFLICT: re-read, re-translate (caller's job), re-resolve
|
|
203
|
+
* the overrides from the fresh descriptor, stage again (store-first),
|
|
204
|
+
* re-write once
|
|
118
205
|
*
|
|
119
206
|
* @param settings The settings service (injected, not imported)
|
|
120
207
|
* @param route The provider route id
|
|
121
208
|
* @param target Translated settings-writable entries (sorted by id)
|
|
122
209
|
* @param logger Logger for warnings/errors
|
|
123
210
|
* @param retranslate Callback to re-translate on conflict (receives new revision)
|
|
211
|
+
* @param store The models-store accessor for the overrides replay/persist
|
|
124
212
|
*/
|
|
125
|
-
export async function syncToSettings(settings, route, target, logger, retranslate) {
|
|
213
|
+
export async function syncToSettings(settings, route, target, logger, retranslate, store) {
|
|
126
214
|
if (settings === undefined) {
|
|
127
215
|
logger.debug('settings service unavailable; skip write for route %s', route);
|
|
128
216
|
return { wrote: false, reason: 'skipped' };
|
|
@@ -134,22 +222,60 @@ export async function syncToSettings(settings, route, target, logger, retranslat
|
|
|
134
222
|
return { wrote: false, reason: 'skipped' };
|
|
135
223
|
}
|
|
136
224
|
const rawModels = getRawUserModels(desc, route);
|
|
137
|
-
|
|
138
|
-
|
|
225
|
+
let effectiveOverrides;
|
|
226
|
+
let overridesSource;
|
|
227
|
+
try {
|
|
228
|
+
({ overrides: effectiveOverrides, source: overridesSource } =
|
|
229
|
+
await resolveOverrides(desc, route, store));
|
|
230
|
+
}
|
|
231
|
+
catch (readErr) {
|
|
232
|
+
// The store is unreadable (corrupted JSON, EACCES, …) and settings
|
|
233
|
+
// carries no overrides key — there is no authoritative source for the
|
|
234
|
+
// user's folded values other than the existing settings.models. Skip
|
|
235
|
+
// the round with reason 'store-unavailable': writing the raw pi.dev
|
|
236
|
+
// target now would overwrite settings.models with unreplayed values
|
|
237
|
+
// and silently clobber the user's fold (the same data-loss shape
|
|
238
|
+
// v0.1.5 hit, just via a different path). The next refresh attempts
|
|
239
|
+
// the same round again; a manual re-add of the key (or a fresh
|
|
240
|
+
// successful settings-side write that heals the file) unblocks it.
|
|
241
|
+
logger.warn('models-store read failed for route %s: %s', route, readErr instanceof Error ? readErr.message : String(readErr));
|
|
242
|
+
return { wrote: false, reason: 'store-unavailable' };
|
|
243
|
+
}
|
|
244
|
+
const hasSettingsOverrides = overridesSource === 'settings';
|
|
245
|
+
const mergedTarget = mergeOverrides(target, effectiveOverrides);
|
|
139
246
|
// Change-only write (§4.4): skip when the stored models already reflect
|
|
140
|
-
// target ⊕ overrides.
|
|
141
|
-
//
|
|
142
|
-
//
|
|
143
|
-
if (rawModels !== undefined && profilesEqual(rawModels, mergedTarget)) {
|
|
247
|
+
// target ⊕ overrides. Skipped when the settings key is present — the unset
|
|
248
|
+
// must run in this mutate to clear the refused models+overrides combo, and
|
|
249
|
+
// after it lands the replay keeps later rounds change-only.
|
|
250
|
+
if (!hasSettingsOverrides && rawModels !== undefined && profilesEqual(rawModels, mergedTarget)) {
|
|
144
251
|
logger.debug('no change for route %s; skip write', route);
|
|
145
252
|
return { wrote: false, reason: 'no-change' };
|
|
146
253
|
}
|
|
254
|
+
const dropped = droppedOverrideIds(effectiveOverrides, mergedTarget);
|
|
147
255
|
const ops = [
|
|
148
256
|
{ op: 'set', path: ['providers', route, 'models'], value: mergedTarget },
|
|
149
257
|
];
|
|
258
|
+
if (hasSettingsOverrides) {
|
|
259
|
+
ops.push({ op: 'unset', path: ['providers', route, 'modelOverrides'] });
|
|
260
|
+
}
|
|
261
|
+
// Store-first: stage the raw overrides in the models-store BEFORE the
|
|
262
|
+
// mutate that unsets them from settings. A store write failure must skip
|
|
263
|
+
// the mutate entirely — unsetting without a staged copy is the v0.1.5
|
|
264
|
+
// data loss — and settings stays untouched, so it remains the
|
|
265
|
+
// authoritative source. Reported honestly as 'store-unavailable': the
|
|
266
|
+
// mutate never ran, so 'mutate-rejected' would be a lie.
|
|
267
|
+
if (hasSettingsOverrides && effectiveOverrides !== undefined) {
|
|
268
|
+
try {
|
|
269
|
+
await persistOverridesToStore(store, route, effectiveOverrides);
|
|
270
|
+
}
|
|
271
|
+
catch (persistErr) {
|
|
272
|
+
logger.warn('models-store persist failed for route %s: %s', route, persistErr instanceof Error ? persistErr.message : String(persistErr));
|
|
273
|
+
return { wrote: false, reason: 'store-unavailable' };
|
|
274
|
+
}
|
|
275
|
+
}
|
|
150
276
|
try {
|
|
151
277
|
await settings.mutate('llm-pi-ai', ops, desc.revision);
|
|
152
|
-
return { wrote: true, reason: 'wrote' };
|
|
278
|
+
return { wrote: true, reason: 'wrote', overridesSource, droppedOverrideIds: dropped };
|
|
153
279
|
}
|
|
154
280
|
catch (err) {
|
|
155
281
|
// Check for SETTINGS_CONFLICT
|
|
@@ -172,15 +298,46 @@ export async function syncToSettings(settings, route, target, logger, retranslat
|
|
|
172
298
|
return { wrote: false, reason: 'conflict-retry-failed' };
|
|
173
299
|
}
|
|
174
300
|
const newTarget = await retranslate(newDesc.revision);
|
|
301
|
+
let retry;
|
|
302
|
+
try {
|
|
303
|
+
retry = await resolveOverrides(newDesc, route, store);
|
|
304
|
+
}
|
|
305
|
+
catch (readErr) {
|
|
306
|
+
// Same fail-closed contract as the main path: with the settings key
|
|
307
|
+
// gone between the two attempts, the store replay is the only way
|
|
308
|
+
// to recover the fold; an unreadable store leaves the user values
|
|
309
|
+
// stranded in settings.models. Skip the retry, report honestly.
|
|
310
|
+
logger.warn('models-store read failed for route %s on retry: %s', route, readErr instanceof Error ? readErr.message : String(readErr));
|
|
311
|
+
return { wrote: false, reason: 'store-unavailable' };
|
|
312
|
+
}
|
|
313
|
+
const retryHasSettingsOverrides = retry.source === 'settings';
|
|
314
|
+
const retryMerged = mergeOverrides(newTarget, retry.overrides);
|
|
315
|
+
const retryDropped = droppedOverrideIds(retry.overrides, retryMerged);
|
|
175
316
|
const retryOps = [
|
|
176
|
-
{
|
|
177
|
-
op: 'set',
|
|
178
|
-
path: ['providers', route, 'models'],
|
|
179
|
-
value: mergeOverrides(newTarget, getRawUserModelOverrides(newDesc, route)),
|
|
180
|
-
},
|
|
317
|
+
{ op: 'set', path: ['providers', route, 'models'], value: retryMerged },
|
|
181
318
|
];
|
|
319
|
+
if (retryHasSettingsOverrides) {
|
|
320
|
+
retryOps.push({ op: 'unset', path: ['providers', route, 'modelOverrides'] });
|
|
321
|
+
}
|
|
322
|
+
// Store-first again on the retry: the overrides were re-resolved from
|
|
323
|
+
// the fresh descriptor, so stage them before the retry mutate (the
|
|
324
|
+
// user may have changed or removed the key between the attempts).
|
|
325
|
+
if (retryHasSettingsOverrides && retry.overrides !== undefined) {
|
|
326
|
+
try {
|
|
327
|
+
await persistOverridesToStore(store, route, retry.overrides);
|
|
328
|
+
}
|
|
329
|
+
catch (persistErr) {
|
|
330
|
+
logger.warn('models-store persist failed for route %s: %s', route, persistErr instanceof Error ? persistErr.message : String(persistErr));
|
|
331
|
+
return { wrote: false, reason: 'store-unavailable' };
|
|
332
|
+
}
|
|
333
|
+
}
|
|
182
334
|
await settings.mutate('llm-pi-ai', retryOps, newDesc.revision);
|
|
183
|
-
return {
|
|
335
|
+
return {
|
|
336
|
+
wrote: true,
|
|
337
|
+
reason: 'conflict-retry-ok',
|
|
338
|
+
overridesSource: retry.source,
|
|
339
|
+
droppedOverrideIds: retryDropped,
|
|
340
|
+
};
|
|
184
341
|
}
|
|
185
342
|
catch (retryErr) {
|
|
186
343
|
logger.warn('conflict retry failed for route %s: %s', route, retryErr instanceof Error ? retryErr.message : String(retryErr));
|
package/lib/writer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"writer.js","sourceRoot":"","sources":["../src/writer.ts"],"names":[],"mappings":"AAAA,sFAAsF;
|
|
1
|
+
{"version":3,"file":"writer.js","sourceRoot":"","sources":["../src/writer.ts"],"names":[],"mappings":"AAAA,sFAAsF;AA6GtF,8EAA8E;AAC9E,YAAY;AACZ,8EAA8E;AAE9E,2DAA2D;AAC3D,MAAM,iBAAiB,GAAG,mBAAmB,CAAA;AAE7C,8EAA8E;AAC9E,kCAAkC;AAClC,8EAA8E;AAE9E;;;GAGG;AACH,MAAM,UAAU,aAAa,CAC3B,OAA+B,EAC/B,MAA8B;IAE9B,IAAI,OAAO,CAAC,MAAM,KAAK,MAAM,CAAC,MAAM;QAAE,OAAO,KAAK,CAAA;IAClD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACxC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC;YAAE,OAAO,KAAK,CAAA;IACrD,CAAC;IACD,OAAO,IAAI,CAAA;AACb,CAAC;AAED,SAAS,SAAS,CAAC,CAA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AE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,mBAAmB,EAAE,CAAA;gBACtD,CAAC;YACH,CAAC;YAED,MAAM,QAAQ,CAAC,MAAM,CAAC,WAAW,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAA;YAC9D,OAAO;gBACL,KAAK,EAAE,IAAI;gBACX,MAAM,EAAE,mBAAmB;gBAC3B,eAAe,EAAE,KAAK,CAAC,MAAM;gBAC7B,kBAAkB,EAAE,YAAY;aACjC,CAAA;QACH,CAAC;QAAC,OAAO,QAAiB,EAAE,CAAC;YAC3B,MAAM,CAAC,IAAI,CACT,wCAAwC,EACxC,KAAK,EACL,QAAQ,YAAY,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAChE,CAAA;YACD,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,uBAAuB,EAAE,CAAA;QAC1D,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiwayds/dsh-model-sync",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "dsh plugin: keep llm-pi-ai provider routes' model lists in step with the pi.dev gateway, written through the official settings seam",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"build": "tsc -p tsconfig.json",
|
|
32
32
|
"check": "tsc --noEmit -p tsconfig.json",
|
|
33
33
|
"pretest": "tsc -p tsconfig.json",
|
|
34
|
-
"test": "node --test test/live-catalog.test.mjs test/diff.test.mjs test/translate.test.mjs test/writer.test.mjs test/remote-catalog.test.mjs test/serviceability.test.mjs test/command.test.mjs test/real-cordis.test.mjs"
|
|
34
|
+
"test": "node --test test/live-catalog.test.mjs test/diff.test.mjs test/translate.test.mjs test/writer.test.mjs test/writer-overrides.test.mjs test/remote-catalog.test.mjs test/serviceability.test.mjs test/command.test.mjs test/real-cordis.test.mjs"
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {},
|
|
37
37
|
"peerDependencies": {
|
package/src/index.ts
CHANGED
|
@@ -288,7 +288,8 @@ export function apply(ctx: Context): void {
|
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
290
|
|
|
291
|
-
// Write to settings (change-only, with conflict retry)
|
|
291
|
+
// Write to settings (change-only, with conflict retry); the store
|
|
292
|
+
// carries the modelOverrides replay/persist (mutual-exclusion fix)
|
|
292
293
|
const syncResult = await syncToSettings(
|
|
293
294
|
settings,
|
|
294
295
|
route,
|
|
@@ -301,16 +302,36 @@ export function apply(ctx: Context): void {
|
|
|
301
302
|
void newRevision // revision is used by the caller
|
|
302
303
|
return translated.entries
|
|
303
304
|
},
|
|
305
|
+
store,
|
|
304
306
|
)
|
|
305
307
|
|
|
306
308
|
if (syncResult.wrote) {
|
|
307
|
-
|
|
309
|
+
// Detail suffix for the override flows; routes without overrides keep
|
|
310
|
+
// the classic "(wrote)" line byte-for-byte.
|
|
311
|
+
const reason = syncResult.reason === 'wrote' ? '' : `${syncResult.reason}; `
|
|
312
|
+
let detail: string | undefined
|
|
313
|
+
if (syncResult.overridesSource === 'settings') {
|
|
314
|
+
detail = `${reason}folded user modelOverrides, unset the key`
|
|
315
|
+
} else if (syncResult.overridesSource === 'store') {
|
|
316
|
+
detail = `${reason}applied stored modelOverrides`
|
|
317
|
+
}
|
|
318
|
+
if (detail !== undefined && syncResult.droppedOverrideIds !== undefined && syncResult.droppedOverrideIds.length > 0) {
|
|
319
|
+
detail += `; override ids not in target kept in models-store: ${syncResult.droppedOverrideIds.join(', ')}`
|
|
320
|
+
}
|
|
321
|
+
lines.push(detail !== undefined
|
|
322
|
+
? `${route}: wrote ${translated.entries.length} models (${detail})`
|
|
323
|
+
: `${route}: wrote ${translated.entries.length} models (${syncResult.reason})`)
|
|
308
324
|
} else if (syncResult.reason === 'no-change') {
|
|
309
325
|
lines.push(`${route}: up to date (${translated.entries.length} models)`)
|
|
310
326
|
} else if (syncResult.reason === 'skipped') {
|
|
311
327
|
lines.push(`${route}: skipped — settings service unavailable or llm-pi-ai namespace not registered`)
|
|
312
328
|
} else if (syncResult.reason === 'mutate-rejected') {
|
|
313
329
|
lines.push(`${route}: rejected by settings validation (see log)`)
|
|
330
|
+
} else if (syncResult.reason === 'store-unavailable') {
|
|
331
|
+
// The store failed (corrupt/permission on read, or filesystem on
|
|
332
|
+
// write); settings.models was the authoritative source and stays
|
|
333
|
+
// untouched either way — the user's folded values are preserved.
|
|
334
|
+
lines.push(`${route}: skipped (models-store unavailable; settings untouched)`)
|
|
314
335
|
} else {
|
|
315
336
|
lines.push(`${route}: ${syncResult.reason} (${translated.entries.length} models)`)
|
|
316
337
|
}
|