@aiwayds/dsh-model-sync 0.12.1 → 0.13.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.
- package/README.md +18 -17
- package/README.zh-CN.md +18 -17
- package/lib/index.d.ts +54 -384
- package/lib/index.js +306 -1107
- package/lib/index.js.map +1 -1
- package/lib/official-adapter.d.ts +80 -0
- package/lib/official-adapter.js +34 -0
- package/lib/official-adapter.js.map +1 -0
- package/lib/official-migrate.d.ts +122 -0
- package/lib/official-migrate.js +653 -0
- package/lib/official-migrate.js.map +1 -0
- package/lib/official-scheduler.d.ts +72 -0
- package/lib/official-scheduler.js +195 -0
- package/lib/official-scheduler.js.map +1 -0
- package/lib/official-store.d.ts +41 -0
- package/lib/official-store.js +84 -0
- package/lib/official-store.js.map +1 -0
- package/lib/official-sync.d.ts +68 -0
- package/lib/official-sync.js +274 -0
- package/lib/official-sync.js.map +1 -0
- package/lib/opencode-go-adapter.d.ts +56 -0
- package/lib/opencode-go-adapter.js +455 -0
- package/lib/opencode-go-adapter.js.map +1 -0
- package/lib/opencode-go-patch-file.d.ts +11 -0
- package/lib/opencode-go-patch-file.js +175 -11
- package/lib/opencode-go-patch-file.js.map +1 -1
- package/lib/opencode-go-source.d.ts +1 -1
- package/lib/opencode-go-source.js +1 -1
- package/locale/en.json +1 -1
- package/locale/zh.json +1 -1
- package/package.json +3 -3
- package/src/index.ts +352 -1281
- package/src/official-adapter.ts +111 -0
- package/src/official-migrate.ts +863 -0
- package/src/official-scheduler.ts +235 -0
- package/src/official-store.ts +122 -0
- package/src/official-sync.ts +371 -0
- package/src/opencode-go-adapter.ts +494 -0
- package/src/opencode-go-patch-file.ts +175 -9
- package/src/opencode-go-source.ts +1 -1
- package/lib/opencode-go-diagnose.d.ts +0 -96
- package/lib/opencode-go-diagnose.js +0 -177
- package/lib/opencode-go-diagnose.js.map +0 -1
- package/lib/opencode-go-grouping.d.ts +0 -7
- package/lib/opencode-go-grouping.js +0 -21
- package/lib/opencode-go-grouping.js.map +0 -1
- package/lib/opencode-go-host-catalog.d.ts +0 -42
- package/lib/opencode-go-host-catalog.js +0 -98
- package/lib/opencode-go-host-catalog.js.map +0 -1
- package/lib/opencode-go-journal.d.ts +0 -114
- package/lib/opencode-go-journal.js +0 -406
- package/lib/opencode-go-journal.js.map +0 -1
- package/lib/opencode-go-migrate.d.ts +0 -378
- package/lib/opencode-go-migrate.js +0 -1529
- package/lib/opencode-go-migrate.js.map +0 -1
- package/lib/opencode-go-migration.d.ts +0 -270
- package/lib/opencode-go-migration.js +0 -473
- package/lib/opencode-go-migration.js.map +0 -1
- package/lib/opencode-go-one-shot.d.ts +0 -282
- package/lib/opencode-go-one-shot.js +0 -1131
- package/lib/opencode-go-one-shot.js.map +0 -1
- package/lib/opencode-go-planner.d.ts +0 -168
- package/lib/opencode-go-planner.js +0 -407
- package/lib/opencode-go-planner.js.map +0 -1
- package/lib/opencode-go-scheduler.d.ts +0 -128
- package/lib/opencode-go-scheduler.js +0 -241
- package/lib/opencode-go-scheduler.js.map +0 -1
- package/lib/opencode-go-store.d.ts +0 -18
- package/lib/opencode-go-store.js +0 -68
- package/lib/opencode-go-store.js.map +0 -1
- package/lib/opencode-go-sync.d.ts +0 -107
- package/lib/opencode-go-sync.js +0 -388
- package/lib/opencode-go-sync.js.map +0 -1
- package/lib/opencode-go-writer.d.ts +0 -148
- package/lib/opencode-go-writer.js +0 -1061
- package/lib/opencode-go-writer.js.map +0 -1
- package/src/opencode-go-diagnose.ts +0 -276
- package/src/opencode-go-grouping.ts +0 -26
- package/src/opencode-go-host-catalog.ts +0 -125
- package/src/opencode-go-journal.ts +0 -460
- package/src/opencode-go-migrate.ts +0 -1951
- package/src/opencode-go-migration.ts +0 -666
- package/src/opencode-go-one-shot.ts +0 -1399
- package/src/opencode-go-planner.ts +0 -582
- package/src/opencode-go-scheduler.ts +0 -315
- package/src/opencode-go-store.ts +0 -73
- package/src/opencode-go-sync.ts +0 -541
- package/src/opencode-go-writer.ts +0 -1301
|
@@ -1,473 +0,0 @@
|
|
|
1
|
-
// P1d-1: migration gate + single-writer route authority (design §14.1 / §14.6 /
|
|
2
|
-
// §14.7, M-4 / M-5; ADR-008). Pure state/fingerprint/routeWriter functions plus
|
|
3
|
-
// an injected migration-record store seam. No timer, no network, no settings
|
|
4
|
-
// write lives here — the migrate *command* itself is P1d-2. Tests inject an
|
|
5
|
-
// `appliedFingerprint` record to exercise the applied state without apply().
|
|
6
|
-
//
|
|
7
|
-
// Priority (§14.7.1): ① migration gate (`none`) > ② single-writer ownership >
|
|
8
|
-
// ③ ordinary §6.2.4 write semantics. A skipped route must always produce a
|
|
9
|
-
// report line (never silent), which callers build from RouteWriterDecision.
|
|
10
|
-
import { createHash } from 'node:crypto';
|
|
11
|
-
import { GO_SLOT_ROUTES } from "./opencode-go-grouping.js";
|
|
12
|
-
import { GO_MIGRATION_STORE_KEY_BASE, isUnscopedStoreKey, scopedStoreKey } from "./opencode-go-profile.js";
|
|
13
|
-
import { loadModelsStore } from "./remote-catalog.js";
|
|
14
|
-
/** Cordis service seam: tests register a fake record store under this name. */
|
|
15
|
-
export const GO_MIGRATION_STORE_SERVICE = 'goMigrationStore';
|
|
16
|
-
/**
|
|
17
|
-
* Base name of the models-store raw slot holding the go migration record
|
|
18
|
-
* (P1d-1). B1: profile-scoped stores persist it as
|
|
19
|
-
* `<profileKey>#migration:opencode-go`; the unscoped name is kept only for
|
|
20
|
-
* legacy callers/tests and is never claimed by a scoped store. The literal is
|
|
21
|
-
* owned by opencode-go-profile.ts so `isUnscopedStoreKey` can distinguish a
|
|
22
|
-
* scoped migration record from a legacy key without guessing the key shape.
|
|
23
|
-
*/
|
|
24
|
-
export const GO_MIGRATION_STORE_KEY = GO_MIGRATION_STORE_KEY_BASE;
|
|
25
|
-
/**
|
|
26
|
-
* D6: the ONE computation of the "unclaimable record" status label. Both
|
|
27
|
-
* `migrate status` (opencode-go-migrate.ts) and the go report's status refresh
|
|
28
|
-
* (index.ts `loadMigrationStatus`) use this helper, so the same store state
|
|
29
|
-
* yields the same label in both commands (W1). Call only when the profile's own
|
|
30
|
-
* scoped read() found no record — a foreign record must never relabel a profile
|
|
31
|
-
* that already has its own applied/drifted record (B1 isolation).
|
|
32
|
-
*/
|
|
33
|
-
export function unclaimedRecordState(unclaimed) {
|
|
34
|
-
if (unclaimed.some((record) => record.kind === 'foreign-profile'))
|
|
35
|
-
return 'foreign-profile';
|
|
36
|
-
if (unclaimed.length > 0)
|
|
37
|
-
return 'legacy-store';
|
|
38
|
-
return undefined;
|
|
39
|
-
}
|
|
40
|
-
/** Fixed report line required by §14.6 for every migration-gate skip. */
|
|
41
|
-
export const MIGRATION_GATE_HINT = '检测到未迁移配置,已跳过写入;运行 /model-sync migrate plan';
|
|
42
|
-
// ---------------------------------------------------------------------------
|
|
43
|
-
// Fingerprint + state detection (pure)
|
|
44
|
-
// ---------------------------------------------------------------------------
|
|
45
|
-
function isRecord(value) {
|
|
46
|
-
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
47
|
-
}
|
|
48
|
-
/** Canonical JSON (recursive key sort) — the ownership-entry hash algorithm (§14.1). */
|
|
49
|
-
function canonicalize(value) {
|
|
50
|
-
if (Array.isArray(value))
|
|
51
|
-
return value.map(canonicalize);
|
|
52
|
-
if (!isRecord(value))
|
|
53
|
-
return value;
|
|
54
|
-
const out = {};
|
|
55
|
-
for (const key of Object.keys(value).sort())
|
|
56
|
-
out[key] = canonicalize(value[key]);
|
|
57
|
-
return out;
|
|
58
|
-
}
|
|
59
|
-
/** sha256 of canonical JSON — section fingerprint (§14.1). */
|
|
60
|
-
export function fingerprintSection(value) {
|
|
61
|
-
return createHash('sha256').update(JSON.stringify(canonicalize(value))).digest('hex');
|
|
62
|
-
}
|
|
63
|
-
/** Extract only the `opencode-go*` provider sections that currently exist. */
|
|
64
|
-
export function readGoProviderSections(source, routes = Object.values(GO_SLOT_ROUTES)) {
|
|
65
|
-
// A SettingsDescriptor carries `user.providers`; a raw providers object is
|
|
66
|
-
// itself the route→section map. Discriminate on `user` rather than `ns` so a
|
|
67
|
-
// partial descriptor fixture (no `ns`) still resolves correctly.
|
|
68
|
-
const providers = isRecord(source) && isRecord(source.user)
|
|
69
|
-
? source.user.providers
|
|
70
|
-
: isRecord(source) ? source.providers : undefined;
|
|
71
|
-
if (!isRecord(providers))
|
|
72
|
-
return undefined;
|
|
73
|
-
const sections = {};
|
|
74
|
-
for (const route of routes) {
|
|
75
|
-
const data = providers[route];
|
|
76
|
-
if (isRecord(data))
|
|
77
|
-
sections[route] = data;
|
|
78
|
-
}
|
|
79
|
-
return sections;
|
|
80
|
-
}
|
|
81
|
-
/** Fingerprint of the current `opencode-go*` sections (empty object when absent). */
|
|
82
|
-
export function fingerprintGoRoutes(source, routes) {
|
|
83
|
-
return fingerprintSection(readGoProviderSections(source, routes) ?? {});
|
|
84
|
-
}
|
|
85
|
-
// --- Two-level applied fingerprint (§14.7.4) --------------------------------
|
|
86
|
-
//
|
|
87
|
-
// Only STABLE fields take part in drift detection:
|
|
88
|
-
// appliedIdentity = sha256(canonical({ <route>: {api, baseURL, displayName,
|
|
89
|
-
// apiKeyEnv} })) — from settings
|
|
90
|
-
// appliedManagedIds = { <route>: sorted ids in the ownership ledger } — from ledger
|
|
91
|
-
// appliedFingerprint = sha256(canonical({ appliedIdentity, appliedManagedIds }))
|
|
92
|
-
//
|
|
93
|
-
// Excluded on purpose: models[] capacity/capability fields (name,
|
|
94
|
-
// contextWindow, maxTokens, input, reasoningEfforts, compat — all rewritten
|
|
95
|
-
// every sync round), user-owned ids, model order, modelOverrides, and any
|
|
96
|
-
// time/usage field. Those are handled by the managed-vs-user-owned repair
|
|
97
|
-
// rules, never by closing the gate. Identity fields are never rewritten by a
|
|
98
|
-
// sync round, and the ledger ids change only through our own successful
|
|
99
|
-
// writes (which immediately re-persist the fingerprint), so a normal sync
|
|
100
|
-
// cannot create an identity-level mismatch. An external identity edit →
|
|
101
|
-
// `drifted`; an external models edit → still `applied`.
|
|
102
|
-
const IDENTITY_FIELDS = ['api', 'baseURL', 'displayName', 'apiKeyEnv'];
|
|
103
|
-
/** Identity map: only the four stable fields of each present go section. */
|
|
104
|
-
export function goIdentityOf(sections) {
|
|
105
|
-
const out = {};
|
|
106
|
-
for (const [route, section] of Object.entries(sections ?? {})) {
|
|
107
|
-
if (!isRecord(section))
|
|
108
|
-
continue;
|
|
109
|
-
const entry = {};
|
|
110
|
-
for (const field of IDENTITY_FIELDS) {
|
|
111
|
-
if (section[field] !== undefined)
|
|
112
|
-
entry[field] = section[field];
|
|
113
|
-
}
|
|
114
|
-
out[route] = entry;
|
|
115
|
-
}
|
|
116
|
-
return out;
|
|
117
|
-
}
|
|
118
|
-
/**
|
|
119
|
-
* Hash of the current route identities — stable across ordinary sync rounds.
|
|
120
|
-
* `routes` restricts the compared set: a record keeps the route set it was
|
|
121
|
-
* written with, so routes created later by a sync round never look like drift.
|
|
122
|
-
*/
|
|
123
|
-
export function fingerprintGoIdentity(sections, routes) {
|
|
124
|
-
const all = goIdentityOf(sections);
|
|
125
|
-
if (routes === undefined)
|
|
126
|
-
return fingerprintSection(all);
|
|
127
|
-
return fingerprintSection(Object.fromEntries(routes.map((route) => [route, all[route] ?? {}])));
|
|
128
|
-
}
|
|
129
|
-
/** Full applied fingerprint = sha256(canonical({ identity, managedIds })). */
|
|
130
|
-
export function appliedFingerprintOf(identity, managedIds) {
|
|
131
|
-
return fingerprintSection({ identity, managedIds: managedIds ?? {} });
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* ONE route-set convention for the two-level applied fingerprint, shared by
|
|
135
|
-
* `migrationStatusOf` (loadMigrationStatus) and the writer's `onOwnWrite`:
|
|
136
|
-
* identity routes are the record's `appliedIdentityRoutes` (or the routes
|
|
137
|
-
* present in settings when the record has none); managed-id routes are exactly
|
|
138
|
-
* the entries present in the supplied map. A configured-but-absent route must
|
|
139
|
-
* NOT be fabricated as `<route>: []` — migrate/onOwnWrite persist only routes
|
|
140
|
-
* with a real ledger entry, and inventing empty ones here makes the first
|
|
141
|
-
* healthy round look like a fingerprint drift (`fingerprint-healed` noise).
|
|
142
|
-
*/
|
|
143
|
-
export function appliedFingerprintFieldsOf(sections, record, managedIds) {
|
|
144
|
-
const identityRoutes = record?.appliedIdentityRoutes ?? Object.keys(sections ?? {});
|
|
145
|
-
const identity = fingerprintGoIdentity(sections, identityRoutes);
|
|
146
|
-
return { identity, appliedFingerprint: appliedFingerprintOf(identity, managedIds) };
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* The ONE post-own-write migration record update — extracted from index.ts so
|
|
150
|
-
* tests (H2: the 0.11.x four-route convergence) drive the exact code the
|
|
151
|
-
* plugin runs. Semantics:
|
|
152
|
-
* - `appliedIdentityRoutes` shrinks to the routes still PRESENT in settings
|
|
153
|
-
* (0.12.0 catalog-reuse unsets the legacy protocol routes; keeping them in
|
|
154
|
-
* the identity set would make every later read look like drift) — with the
|
|
155
|
-
* just-written route always included (M2: prevents the degenerate
|
|
156
|
-
* constant `sha256('{}')` identity when every section is gone).
|
|
157
|
-
* - `appliedManagedIds[route]` is SET for a normal write and DELETED for an
|
|
158
|
-
* unset (M2: the ledger key was deleted — a persisted `[]` entry no ledger
|
|
159
|
-
* backs makes the stored fingerprint disagree with every status read and
|
|
160
|
-
* costs a fingerprint-healed round).
|
|
161
|
-
* - `appliedIdentity` / `appliedFingerprint` are recomputed from the live
|
|
162
|
-
* sections + the updated managed-id map, so the persisted record always
|
|
163
|
-
* matches what `migrationStatusOf` recomputes (no phantom heal).
|
|
164
|
-
* Pure: returns the next record; the caller persists it.
|
|
165
|
-
*/
|
|
166
|
-
export function ownWriteRecordUpdate(input) {
|
|
167
|
-
const sections = readGoProviderSections(input.source, input.routes) ?? {};
|
|
168
|
-
const presentRoutes = Object.keys(sections);
|
|
169
|
-
const prior = input.record ?? {};
|
|
170
|
-
// The just-written route joins the identity set ONLY on a real write. An
|
|
171
|
-
// unset drops it together with its section: identity and fingerprint are
|
|
172
|
-
// always recomputed from the SAME list the status read will use, so the
|
|
173
|
-
// degenerate empty-set hash (`sha256('{}')`) can only ever arise on BOTH
|
|
174
|
-
// sides simultaneously — never as a one-sided drift.
|
|
175
|
-
const includeRoute = input.unset !== true;
|
|
176
|
-
const identityRoutes = [...new Set([
|
|
177
|
-
...(prior.appliedIdentityRoutes ?? presentRoutes).filter((candidate) => presentRoutes.includes(candidate) || (includeRoute && candidate === input.route)),
|
|
178
|
-
...(includeRoute ? [input.route] : []),
|
|
179
|
-
])];
|
|
180
|
-
const appliedManagedIds = { ...(prior.appliedManagedIds ?? {}) };
|
|
181
|
-
if (input.unset === true)
|
|
182
|
-
delete appliedManagedIds[input.route];
|
|
183
|
-
else
|
|
184
|
-
appliedManagedIds[input.route] = [...input.managedIds].sort((a, b) => a.localeCompare(b));
|
|
185
|
-
// P2-②: an EMPTY identity route set means "no verifiable applied identity".
|
|
186
|
-
// Persisting `appliedIdentityRoutes: []` (+ the constant `sha256('{}')`
|
|
187
|
-
// identity it hashes to) would make ANY later config — including an
|
|
188
|
-
// unmigrated legacy-inline one — constant-match and read as `applied`
|
|
189
|
-
// (migration-gate penetration). Drop the applied-state fields instead: the
|
|
190
|
-
// record keeps everything else and state detection falls back to the
|
|
191
|
-
// closed-gate legacy path. `migrationStateOf` carries the matching
|
|
192
|
-
// read-side guard, so an old record that already carries `[]` cannot
|
|
193
|
-
// penetrate either.
|
|
194
|
-
if (identityRoutes.length === 0) {
|
|
195
|
-
const rest = { ...prior, appliedManagedIds };
|
|
196
|
-
delete rest.appliedIdentity;
|
|
197
|
-
delete rest.appliedIdentityRoutes;
|
|
198
|
-
delete rest.appliedFingerprint;
|
|
199
|
-
return rest;
|
|
200
|
-
}
|
|
201
|
-
const { identity, appliedFingerprint } = appliedFingerprintFieldsOf(sections, { appliedIdentityRoutes: identityRoutes }, appliedManagedIds);
|
|
202
|
-
return {
|
|
203
|
-
...prior,
|
|
204
|
-
appliedIdentity: identity,
|
|
205
|
-
appliedIdentityRoutes: identityRoutes,
|
|
206
|
-
appliedManagedIds,
|
|
207
|
-
appliedFingerprint,
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* Ledger ids for exactly the routes that HAVE a ledger entry. This is the
|
|
212
|
-
* managed-id half of the shared fingerprint convention above: no entry means
|
|
213
|
-
* no route in the map (never an empty array), so a normal first onboarding and
|
|
214
|
-
* a later own write hash identically. Unreadable entries are skipped too —
|
|
215
|
-
* the strict per-mutate gate already fails closed on a record read failure.
|
|
216
|
-
*/
|
|
217
|
-
export async function goLedgerManagedIds(routes, readEntry) {
|
|
218
|
-
const managedIds = {};
|
|
219
|
-
for (const route of routes) {
|
|
220
|
-
let entry;
|
|
221
|
-
try {
|
|
222
|
-
entry = await readEntry(route);
|
|
223
|
-
}
|
|
224
|
-
catch {
|
|
225
|
-
continue; // unreadable ledger ⇒ no managed ids (never delete), no fabricated entry
|
|
226
|
-
}
|
|
227
|
-
if (entry !== undefined)
|
|
228
|
-
managedIds[route] = Object.keys(entry.managed ?? {}).sort();
|
|
229
|
-
}
|
|
230
|
-
return managedIds;
|
|
231
|
-
}
|
|
232
|
-
function hasInlineModels(sections, chatRoute) {
|
|
233
|
-
const chat = sections[chatRoute];
|
|
234
|
-
return isRecord(chat) && Array.isArray(chat.models);
|
|
235
|
-
}
|
|
236
|
-
/**
|
|
237
|
-
* Determine migration state (§14.1 / §14.7.4). Order matters: absent →
|
|
238
|
-
* identity-based applied/drifted (new records) → full-fingerprint match
|
|
239
|
-
* (legacy records written before the two-level split) → recorded legacy/drifted
|
|
240
|
-
* → unrecorded legacy form. Only an IDENTITY mismatch is `drifted`: a models
|
|
241
|
-
* edit (capacity fields, user-owned ids, order) leaves identity intact and is
|
|
242
|
-
* repaired by the writer instead of closing the gate.
|
|
243
|
-
*/
|
|
244
|
-
export function migrationStateOf(sections, record, chatRoute = GO_SLOT_ROUTES.chat) {
|
|
245
|
-
if (sections === undefined || Object.keys(sections).length === 0)
|
|
246
|
-
return 'absent';
|
|
247
|
-
const fingerprint = fingerprintSection(sections);
|
|
248
|
-
if (record?.appliedIdentity !== undefined) {
|
|
249
|
-
// P2-②: an explicit EMPTY appliedIdentityRoutes hashes every config to the
|
|
250
|
-
// same constant (`sha256('{}')`), so it must never count as a valid
|
|
251
|
-
// applied identity — treat it as absent and fall through to the legacy
|
|
252
|
-
// fingerprint comparison (which can only match the truly applied bytes).
|
|
253
|
-
const identityRoutes = record.appliedIdentityRoutes;
|
|
254
|
-
if (identityRoutes === undefined || identityRoutes.length > 0) {
|
|
255
|
-
return fingerprintGoIdentity(sections, identityRoutes) === record.appliedIdentity
|
|
256
|
-
? 'applied' : 'drifted';
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
// Backward compatibility with the pre-§14.7.4 full-section fingerprint.
|
|
260
|
-
if (record?.appliedFingerprint !== undefined && fingerprint === record.appliedFingerprint)
|
|
261
|
-
return 'applied';
|
|
262
|
-
if (record !== undefined && (record.appliedFingerprint !== undefined || record.legacyFingerprint !== undefined)) {
|
|
263
|
-
if (record.legacyFingerprint !== undefined && fingerprint === record.legacyFingerprint) {
|
|
264
|
-
return hasInlineModels(sections, chatRoute) ? 'legacy-inline' : 'legacy-inherit';
|
|
265
|
-
}
|
|
266
|
-
return 'drifted';
|
|
267
|
-
}
|
|
268
|
-
return hasInlineModels(sections, chatRoute) ? 'legacy-inline' : 'legacy-inherit';
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
* Full status from a settings descriptor (or raw providers object) + record.
|
|
272
|
-
* `currentManagedIds`, when supplied, comes from the live ownership ledger and
|
|
273
|
-
* drives the §14.7.4 self-heal check (identity matches but the stored full
|
|
274
|
-
* fingerprint is stale because the fingerprint write failed after a commit).
|
|
275
|
-
*/
|
|
276
|
-
export function migrationStatusOf(source, record, routes, currentManagedIds) {
|
|
277
|
-
const sections = readGoProviderSections(source, routes);
|
|
278
|
-
// Compare only the route set the record was written with — routes added by a
|
|
279
|
-
// later sync round must not invalidate an otherwise unchanged identity. The
|
|
280
|
-
// shared helper keeps this EXACT route set in sync with onOwnWrite, so a
|
|
281
|
-
// healthy round cannot emit a phantom `fingerprint-healed`.
|
|
282
|
-
const managedIds = currentManagedIds ?? record?.appliedManagedIds ?? {};
|
|
283
|
-
const { identity, appliedFingerprint: expectedFingerprint } = appliedFingerprintFieldsOf(sections, record, managedIds);
|
|
284
|
-
return {
|
|
285
|
-
state: migrationStateOf(sections, record, routes?.[0] ?? GO_SLOT_ROUTES.chat),
|
|
286
|
-
fingerprint: fingerprintSection(sections ?? {}),
|
|
287
|
-
identity,
|
|
288
|
-
appliedIdentity: record?.appliedIdentity,
|
|
289
|
-
appliedManagedIds: record?.appliedManagedIds,
|
|
290
|
-
appliedFingerprint: record?.appliedFingerprint,
|
|
291
|
-
legacyFingerprint: record?.legacyFingerprint,
|
|
292
|
-
applying: record?.applying === true,
|
|
293
|
-
// P2-② (agy final): a degenerate record (`appliedIdentityRoutes: []`,
|
|
294
|
-
// constant `sha256('{}')` identity) constant-matches ANY config, so the
|
|
295
|
-
// raw identity equality below is trivially true — gating `fingerprintHealed`
|
|
296
|
-
// on the same valid-identity condition `migrationStateOf` uses keeps the
|
|
297
|
-
// §14.7.4 self-heal write-back (index.ts persists `expectedFingerprint`
|
|
298
|
-
// when this flag fires) away from records no state detector reads as
|
|
299
|
-
// applied. `undefined` routes stay valid (pre-identity-list records fall
|
|
300
|
-
// back to the routes present in settings).
|
|
301
|
-
fingerprintHealed: record?.appliedIdentity !== undefined
|
|
302
|
-
&& (record.appliedIdentityRoutes === undefined || record.appliedIdentityRoutes.length > 0)
|
|
303
|
-
&& identity === record.appliedIdentity
|
|
304
|
-
&& record.appliedFingerprint !== expectedFingerprint,
|
|
305
|
-
expectedFingerprint,
|
|
306
|
-
};
|
|
307
|
-
}
|
|
308
|
-
// ---------------------------------------------------------------------------
|
|
309
|
-
// Single-writer route authority (pure)
|
|
310
|
-
// ---------------------------------------------------------------------------
|
|
311
|
-
/** True for any configured go route id or the `opencode-go*` prefix. */
|
|
312
|
-
export function isGoRoute(route, customRoutes) {
|
|
313
|
-
if (customRoutes?.includes(route) === true)
|
|
314
|
-
return true;
|
|
315
|
-
return Object.values(GO_SLOT_ROUTES).includes(route) || route.startsWith('opencode-go');
|
|
316
|
-
}
|
|
317
|
-
function isZenRoute(route, cfg) {
|
|
318
|
-
if (cfg.zenRoutes?.includes(route) === true)
|
|
319
|
-
return true;
|
|
320
|
-
return route.startsWith('opencode-zen');
|
|
321
|
-
}
|
|
322
|
-
/**
|
|
323
|
-
* The single decision point every write path must call before settings.mutate.
|
|
324
|
-
*
|
|
325
|
-
* Rules (§14.7.1, task P1d-1):
|
|
326
|
-
* - go.enabled=true + caller≠'go' on an `opencode-go*` route → always skip;
|
|
327
|
-
* the legacy pi.dev path may never take over, even if the gate returned none.
|
|
328
|
-
* - go.enabled=true + caller='go' + state=applied with a matching fingerprint,
|
|
329
|
-
* or state=absent → write. legacy-inherit / legacy-inline / drifted → skip
|
|
330
|
-
* (migration gate) and report MIGRATION_GATE_HINT.
|
|
331
|
-
* - `applying` → skip (M-5: auto rounds drop while apply is in progress).
|
|
332
|
-
* - go.enabled=false → v0.9.0 behavior restored for go routes (pi.dev owner).
|
|
333
|
-
* - zen routes mode: only the zen writer owns zen routes; other routes are
|
|
334
|
-
* unaffected (pi.dev owner) and keep their original behavior.
|
|
335
|
-
*/
|
|
336
|
-
export function routeWriter(route, cfg, migration) {
|
|
337
|
-
const goRoute = isGoRoute(route, cfg.goRoutes);
|
|
338
|
-
if (goRoute && cfg.goEnabled) {
|
|
339
|
-
if (cfg.caller !== 'go') {
|
|
340
|
-
return {
|
|
341
|
-
decision: 'skip',
|
|
342
|
-
owner: 'go',
|
|
343
|
-
reason: 'skipped-route-owner: go (single-writer: opencode.go.enabled=true; legacy pi.dev path must never write opencode-go* routes)',
|
|
344
|
-
};
|
|
345
|
-
}
|
|
346
|
-
if (migration.applying) {
|
|
347
|
-
return {
|
|
348
|
-
decision: 'skip',
|
|
349
|
-
owner: 'none',
|
|
350
|
-
reason: `skipped-route-owner: none (migration applying; ${MIGRATION_GATE_HINT})`,
|
|
351
|
-
};
|
|
352
|
-
}
|
|
353
|
-
// §14.7.4: a record with `appliedIdentity` is judged applied by IDENTITY
|
|
354
|
-
// match alone — models edits must not close the gate. Legacy records fall
|
|
355
|
-
// back to the full-section fingerprint equality they were written with.
|
|
356
|
-
if (migration.state === 'applied'
|
|
357
|
-
&& ((migration.appliedIdentity !== undefined && migration.identity === migration.appliedIdentity)
|
|
358
|
-
|| (migration.appliedFingerprint !== undefined && migration.fingerprint === migration.appliedFingerprint))) {
|
|
359
|
-
return { decision: 'write', owner: 'go', reason: 'owner=go (migration applied; identity/fingerprint matched)' };
|
|
360
|
-
}
|
|
361
|
-
if (migration.state === 'absent') {
|
|
362
|
-
return { decision: 'write', owner: 'go', reason: 'owner=go (absent; no pre-existing section to migrate)' };
|
|
363
|
-
}
|
|
364
|
-
return {
|
|
365
|
-
decision: 'skip',
|
|
366
|
-
owner: 'none',
|
|
367
|
-
reason: `skipped-route-owner: none (migration gate: ${migration.state}; ${MIGRATION_GATE_HINT})`,
|
|
368
|
-
};
|
|
369
|
-
}
|
|
370
|
-
// go.enabled=false (or non-go route): zen routes still have a single owner.
|
|
371
|
-
if (cfg.zenMode === 'routes' && isZenRoute(route, cfg)) {
|
|
372
|
-
if (cfg.caller !== 'zen') {
|
|
373
|
-
return { decision: 'skip', owner: 'zen', reason: 'skipped-route-owner: zen (zen routes mode: only the zen writer owns zen routes)' };
|
|
374
|
-
}
|
|
375
|
-
return { decision: 'write', owner: 'zen', reason: 'owner=zen' };
|
|
376
|
-
}
|
|
377
|
-
// Everything else keeps the original pi.dev behavior. A go caller writing a
|
|
378
|
-
// non-go route is a no-op in practice; allow it so callers can pass a uniform
|
|
379
|
-
// decision function without changing other routes' semantics.
|
|
380
|
-
return { decision: 'write', owner: 'pi.dev', reason: 'owner=pi.dev' };
|
|
381
|
-
}
|
|
382
|
-
// ---------------------------------------------------------------------------
|
|
383
|
-
// Injected store (production adapter reads the same models-store JSON)
|
|
384
|
-
// ---------------------------------------------------------------------------
|
|
385
|
-
/**
|
|
386
|
-
* Build a migration store over the models-store raw-slot accessor.
|
|
387
|
-
*
|
|
388
|
-
* `profileKey` scopes the record slot to `<profileKey>#migration:opencode-go`
|
|
389
|
-
* and stamps the same identity into the record. Reads require the stamp to
|
|
390
|
-
* match — a record from another profile (or an unscoped legacy record with no
|
|
391
|
-
* stamp) is treated as "no record", so state detection falls back to
|
|
392
|
-
* legacy/absent and the migration gate stays closed. Omitting `profileKey`
|
|
393
|
-
* keeps the pre-fix unscoped behavior for legacy callers/tests only.
|
|
394
|
-
*/
|
|
395
|
-
export function createFileMigrationStateStore(accessor, profileKey) {
|
|
396
|
-
const slot = profileKey === undefined
|
|
397
|
-
? GO_MIGRATION_STORE_KEY
|
|
398
|
-
: scopedStoreKey(profileKey, GO_MIGRATION_STORE_KEY);
|
|
399
|
-
return {
|
|
400
|
-
async read() {
|
|
401
|
-
let raw;
|
|
402
|
-
try {
|
|
403
|
-
raw = await accessor.readRaw(slot);
|
|
404
|
-
}
|
|
405
|
-
catch {
|
|
406
|
-
return undefined; // unreadable ⇒ no record ⇒ conservative legacy detection
|
|
407
|
-
}
|
|
408
|
-
if (!isRecord(raw))
|
|
409
|
-
return undefined;
|
|
410
|
-
// Read-side ownership check (B1): never adopt a record stamped for a
|
|
411
|
-
// different profile, and never claim an unstamped legacy record.
|
|
412
|
-
if (profileKey !== undefined && raw.profileKey !== profileKey)
|
|
413
|
-
return undefined;
|
|
414
|
-
return raw;
|
|
415
|
-
},
|
|
416
|
-
// H4: write paths must see store errors, never "no prior record". Only a
|
|
417
|
-
// genuinely absent slot (or a foreign stamp, which is an ownership
|
|
418
|
-
// verdict — not an error) reads as undefined here.
|
|
419
|
-
async readStrict() {
|
|
420
|
-
const raw = await accessor.readRaw(slot);
|
|
421
|
-
if (!isRecord(raw))
|
|
422
|
-
return undefined;
|
|
423
|
-
if (profileKey !== undefined && raw.profileKey !== profileKey)
|
|
424
|
-
return undefined;
|
|
425
|
-
return raw;
|
|
426
|
-
},
|
|
427
|
-
async write(record) {
|
|
428
|
-
// writeRaw is queue-serialized atomic temp+rename, i.e. the SAME queue
|
|
429
|
-
// that persists the ownership ledger (§14.7.4: settings → ledger → fingerprint).
|
|
430
|
-
const stamped = profileKey === undefined ? record : { ...record, profileKey };
|
|
431
|
-
await accessor.writeRaw(slot, stamped);
|
|
432
|
-
},
|
|
433
|
-
async legacyKeys() {
|
|
434
|
-
const keys = await accessor.listRawKeys();
|
|
435
|
-
return keys.filter((key) => key === GO_MIGRATION_STORE_KEY || isUnscopedStoreKey(key));
|
|
436
|
-
},
|
|
437
|
-
async unclaimedRecords() {
|
|
438
|
-
// No resolved profile → no "foreign" notion; legacy callers keep their
|
|
439
|
-
// pre-fix read behavior. Status in production always has a profileKey.
|
|
440
|
-
if (profileKey === undefined)
|
|
441
|
-
return [];
|
|
442
|
-
const keys = await accessor.listRawKeys();
|
|
443
|
-
const out = [];
|
|
444
|
-
for (const key of keys) {
|
|
445
|
-
const isUnscopedSlot = key === GO_MIGRATION_STORE_KEY;
|
|
446
|
-
const isScopedSlot = !isUnscopedSlot && key.endsWith(`#${GO_MIGRATION_STORE_KEY}`);
|
|
447
|
-
if (!isUnscopedSlot && !isScopedSlot)
|
|
448
|
-
continue;
|
|
449
|
-
let raw;
|
|
450
|
-
try {
|
|
451
|
-
raw = await accessor.readRaw(key);
|
|
452
|
-
}
|
|
453
|
-
catch {
|
|
454
|
-
continue; // unreadable slot is advisory only; never changes the gate
|
|
455
|
-
}
|
|
456
|
-
if (!isRecord(raw))
|
|
457
|
-
continue;
|
|
458
|
-
const stamp = typeof raw.profileKey === 'string' && raw.profileKey.length > 0
|
|
459
|
-
? raw.profileKey : undefined;
|
|
460
|
-
if (stamp === profileKey)
|
|
461
|
-
continue; // our own record — claimable as before
|
|
462
|
-
const kind = stamp === undefined ? 'legacy-store' : 'foreign-profile';
|
|
463
|
-
out.push(stamp === undefined ? { kind, key } : { kind, key, profileKey: stamp });
|
|
464
|
-
}
|
|
465
|
-
return out;
|
|
466
|
-
},
|
|
467
|
-
};
|
|
468
|
-
}
|
|
469
|
-
/** Production factory; tests pass a temp-file accessor or inject a fake store. */
|
|
470
|
-
export function createModelsStoreMigrationStateStore(storePath, profileKey) {
|
|
471
|
-
return createFileMigrationStateStore(loadModelsStore(storePath), profileKey);
|
|
472
|
-
}
|
|
473
|
-
//# sourceMappingURL=opencode-go-migration.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"opencode-go-migration.js","sourceRoot":"","sources":["../src/opencode-go-migration.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,gFAAgF;AAChF,6EAA6E;AAC7E,4EAA4E;AAC5E,6EAA6E;AAC7E,EAAE;AACF,8EAA8E;AAC9E,2EAA2E;AAC3E,4EAA4E;AAE5E,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAA;AAC1D,OAAO,EAAE,2BAA2B,EAAE,kBAAkB,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAC1G,OAAO,EAAE,eAAe,EAA4B,MAAM,qBAAqB,CAAA;AAG/E,+EAA+E;AAC/E,MAAM,CAAC,MAAM,0BAA0B,GAAG,kBAAkB,CAAA;AAC5D;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,2BAA2B,CAAA;AA0FjE;;;;;;;GAOG;AACH,MAAM,UAAU,oBAAoB,CAClC,SAA8C;IAE9C,IAAI,SAAS,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,iBAAiB,CAAC;QAAE,OAAO,iBAAiB,CAAA;IAC3F,IAAI,SAAS,CAAC,MAAM,GAAG,CAAC;QAAE,OAAO,cAAc,CAAA;IAC/C,OAA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