instar 1.3.489 → 1.3.490
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/commands/server.d.ts.map +1 -1
- package/dist/commands/server.js +979 -28
- package/dist/commands/server.js.map +1 -1
- package/dist/config/ConfigDefaults.d.ts.map +1 -1
- package/dist/config/ConfigDefaults.js +23 -0
- package/dist/config/ConfigDefaults.js.map +1 -1
- package/dist/core/CodexResumeMap.d.ts +95 -0
- package/dist/core/CodexResumeMap.d.ts.map +1 -0
- package/dist/core/CodexResumeMap.js +283 -0
- package/dist/core/CodexResumeMap.js.map +1 -0
- package/dist/core/MeshRpc.d.ts +3 -0
- package/dist/core/MeshRpc.d.ts.map +1 -1
- package/dist/core/MeshRpc.js +5 -0
- package/dist/core/MeshRpc.js.map +1 -1
- package/dist/core/ModelSwapService.d.ts +26 -11
- package/dist/core/ModelSwapService.d.ts.map +1 -1
- package/dist/core/ModelSwapService.js +59 -21
- package/dist/core/ModelSwapService.js.map +1 -1
- package/dist/core/PostUpdateMigrator.d.ts +16 -0
- package/dist/core/PostUpdateMigrator.d.ts.map +1 -1
- package/dist/core/PostUpdateMigrator.js +62 -2
- package/dist/core/PostUpdateMigrator.js.map +1 -1
- package/dist/core/SessionManager.d.ts +4 -0
- package/dist/core/SessionManager.d.ts.map +1 -1
- package/dist/core/SessionManager.js +3 -0
- package/dist/core/SessionManager.js.map +1 -1
- package/dist/core/SessionRefresh.d.ts +36 -7
- package/dist/core/SessionRefresh.d.ts.map +1 -1
- package/dist/core/SessionRefresh.js +90 -29
- package/dist/core/SessionRefresh.js.map +1 -1
- package/dist/core/TopicProfileOrchestrator.d.ts +480 -0
- package/dist/core/TopicProfileOrchestrator.d.ts.map +1 -0
- package/dist/core/TopicProfileOrchestrator.js +1404 -0
- package/dist/core/TopicProfileOrchestrator.js.map +1 -0
- package/dist/core/TopicProfileResolver.d.ts +104 -0
- package/dist/core/TopicProfileResolver.d.ts.map +1 -0
- package/dist/core/TopicProfileResolver.js +231 -0
- package/dist/core/TopicProfileResolver.js.map +1 -0
- package/dist/core/TopicProfileStore.d.ts +308 -0
- package/dist/core/TopicProfileStore.d.ts.map +1 -0
- package/dist/core/TopicProfileStore.js +781 -0
- package/dist/core/TopicProfileStore.js.map +1 -0
- package/dist/core/TopicProfileTransferCarrier.d.ts +227 -0
- package/dist/core/TopicProfileTransferCarrier.d.ts.map +1 -0
- package/dist/core/TopicProfileTransferCarrier.js +533 -0
- package/dist/core/TopicProfileTransferCarrier.js.map +1 -0
- package/dist/core/TopicResumeMap.d.ts +67 -1
- package/dist/core/TopicResumeMap.d.ts.map +1 -1
- package/dist/core/TopicResumeMap.js +114 -1
- package/dist/core/TopicResumeMap.js.map +1 -1
- package/dist/core/classifyProfileChange.d.ts +83 -0
- package/dist/core/classifyProfileChange.d.ts.map +1 -0
- package/dist/core/classifyProfileChange.js +274 -0
- package/dist/core/classifyProfileChange.js.map +1 -0
- package/dist/core/devGatedFeatures.d.ts.map +1 -1
- package/dist/core/devGatedFeatures.js +6 -0
- package/dist/core/devGatedFeatures.js.map +1 -1
- package/dist/core/frameworkSessionLaunch.d.ts +26 -0
- package/dist/core/frameworkSessionLaunch.d.ts.map +1 -1
- package/dist/core/frameworkSessionLaunch.js +58 -0
- package/dist/core/frameworkSessionLaunch.js.map +1 -1
- package/dist/core/slackRefreshBinding.d.ts +83 -0
- package/dist/core/slackRefreshBinding.d.ts.map +1 -0
- package/dist/core/slackRefreshBinding.js +54 -0
- package/dist/core/slackRefreshBinding.js.map +1 -0
- package/dist/core/topicProfileIngress.d.ts +128 -0
- package/dist/core/topicProfileIngress.d.ts.map +1 -0
- package/dist/core/topicProfileIngress.js +249 -0
- package/dist/core/topicProfileIngress.js.map +1 -0
- package/dist/core/topicProfileValidation.d.ts +109 -0
- package/dist/core/topicProfileValidation.d.ts.map +1 -0
- package/dist/core/topicProfileValidation.js +247 -0
- package/dist/core/topicProfileValidation.js.map +1 -0
- package/dist/core/topicProfileWriteSurface.d.ts +222 -0
- package/dist/core/topicProfileWriteSurface.d.ts.map +1 -0
- package/dist/core/topicProfileWriteSurface.js +631 -0
- package/dist/core/topicProfileWriteSurface.js.map +1 -0
- package/dist/core/types.d.ts +37 -0
- package/dist/core/types.d.ts.map +1 -1
- package/dist/core/types.js.map +1 -1
- package/dist/lifeline/TelegramLifeline.d.ts.map +1 -1
- package/dist/lifeline/TelegramLifeline.js +6 -0
- package/dist/lifeline/TelegramLifeline.js.map +1 -1
- package/dist/messaging/TelegramAdapter.d.ts +10 -1
- package/dist/messaging/TelegramAdapter.d.ts.map +1 -1
- package/dist/messaging/TelegramAdapter.js +41 -1
- package/dist/messaging/TelegramAdapter.js.map +1 -1
- package/dist/scaffold/templates.d.ts.map +1 -1
- package/dist/scaffold/templates.js +9 -0
- package/dist/scaffold/templates.js.map +1 -1
- package/dist/server/AgentServer.d.ts +32 -0
- package/dist/server/AgentServer.d.ts.map +1 -1
- package/dist/server/AgentServer.js +52 -3
- package/dist/server/AgentServer.js.map +1 -1
- package/dist/server/CapabilityIndex.d.ts.map +1 -1
- package/dist/server/CapabilityIndex.js +1 -0
- package/dist/server/CapabilityIndex.js.map +1 -1
- package/dist/server/routes.d.ts +17 -0
- package/dist/server/routes.d.ts.map +1 -1
- package/dist/server/routes.js +271 -1
- package/dist/server/routes.js.map +1 -1
- package/package.json +1 -1
- package/src/data/builtin-manifest.json +66 -66
- package/src/scaffold/templates.ts +9 -0
- package/upgrades/1.3.490.md +34 -0
- package/upgrades/side-effects/topic-profile.md +142 -0
|
@@ -0,0 +1,308 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TopicProfileStore — sticky per-topic execution profile (framework / model /
|
|
3
|
+
* thinking-mode), TOPIC-PROFILE-SPEC §4/§5.1.
|
|
4
|
+
*
|
|
5
|
+
* Modeled on TopicFrameworksStore for the file/atomic-write shape, with the
|
|
6
|
+
* deliberate departures the spec's review required:
|
|
7
|
+
*
|
|
8
|
+
* - Single-writer serialized `mutate(topicKey, patch)` (the CommitmentTracker
|
|
9
|
+
* CAS pattern), NOT a load→overwrite-whole-object `set`. The profile has
|
|
10
|
+
* three independently-writable axes — a whole-object rewrite would clobber
|
|
11
|
+
* a concurrently-set field. `mutate` does a read-modify-write under a
|
|
12
|
+
* per-topic process-local lock, merging only the changed fields.
|
|
13
|
+
* - In-memory cache is AUTHORITATIVE for reads. The file is read once at
|
|
14
|
+
* boot and on explicit external-change invalidation only — per-spawn
|
|
15
|
+
* resolution is O(1) (§5.1).
|
|
16
|
+
* - Durability precedes acknowledgment: `mutate` resolves only after a flush
|
|
17
|
+
* containing its write has durably landed (tmp+rename completed). A failed
|
|
18
|
+
* flush REFUSES the write out loud (throws FlushRefusedError) AND ROLLS
|
|
19
|
+
* BACK the in-memory mutation to the last durably-flushed snapshot — on a
|
|
20
|
+
* failed COALESCED flush, every waiter whose write is not yet durable is
|
|
21
|
+
* refused and rolled back together (§5.1, rounds 5-7).
|
|
22
|
+
* - Queued flush waiters COALESCE: a mutate arriving while a flush is in
|
|
23
|
+
* flight is satisfied by a single trailing flush of the latest cache
|
|
24
|
+
* snapshot — a batch of N writes costs O(1-2) flushes (§5.1, round 6).
|
|
25
|
+
* - The undo snapshot ({ current, previous }) is durable in the same file;
|
|
26
|
+
* `previous` shifts once per delta-carrying disclosure — the ORCHESTRATION
|
|
27
|
+
* layer signals the shift via opts.shiftPrevious (it owns the §8 burst /
|
|
28
|
+
* coalescing-window accounting); the store never guesses the cadence.
|
|
29
|
+
* - Legacy `state/topic-frameworks.json` is a ONE-DIRECTIONAL read-only seed
|
|
30
|
+
* (never overwrites a profile entry) + a profile-store-written mirror so a
|
|
31
|
+
* binary rollback still reads current framework data (§5.1).
|
|
32
|
+
* - The dry-run shadow (`intendedProfile`, §14) is a sibling field that
|
|
33
|
+
* resolution NEVER reads; it has its own lifecycle (flip-clear, skew fates).
|
|
34
|
+
* - §10.4 parked intended-but-unhealthy profiles + breaker counter live on
|
|
35
|
+
* the entry so a revert can re-offer the pin and a new operator pin can
|
|
36
|
+
* atomically supersede the parked state in the same mutate.
|
|
37
|
+
*/
|
|
38
|
+
import type { IntelligenceFramework } from './intelligenceProviderFactory.js';
|
|
39
|
+
import { type EscalationOverride, type ProfileModelTier, type ProfileValidationError, type ThinkingMode } from './topicProfileValidation.js';
|
|
40
|
+
/** §4 — the Topic Profile object. Every axis independently nullable. */
|
|
41
|
+
export interface TopicProfile {
|
|
42
|
+
framework?: IntelligenceFramework | null;
|
|
43
|
+
/** Explicit BASELINE model id — mutually exclusive with modelTier. */
|
|
44
|
+
model?: string | null;
|
|
45
|
+
/** BASELINE tier pin — mutually exclusive with model. */
|
|
46
|
+
modelTier?: ProfileModelTier | null;
|
|
47
|
+
/** §9 — does the heavy-work ultra mandate still apply? Default 'inherit'. */
|
|
48
|
+
escalationOverride?: EscalationOverride | null;
|
|
49
|
+
thinkingMode?: ThinkingMode | null;
|
|
50
|
+
/** ISO timestamp, stamped server-side. */
|
|
51
|
+
updatedAt: string;
|
|
52
|
+
/** VERIFIED operator principal (or 'api-token' / 'system:*'), stamped server-side. */
|
|
53
|
+
updatedBy: string;
|
|
54
|
+
}
|
|
55
|
+
/** §14 — dry-run shadow intent. Resolution NEVER reads this. */
|
|
56
|
+
export interface IntendedProfileShadow {
|
|
57
|
+
fields: Omit<TopicProfile, 'updatedAt' | 'updatedBy'>;
|
|
58
|
+
recordedAt: string;
|
|
59
|
+
recordedBy: string;
|
|
60
|
+
}
|
|
61
|
+
/** §10.4 — a reverted profile retained as intended-but-unhealthy. */
|
|
62
|
+
export interface ParkedProfile {
|
|
63
|
+
profile: TopicProfile;
|
|
64
|
+
reason: string;
|
|
65
|
+
parkedAt: string;
|
|
66
|
+
}
|
|
67
|
+
export interface TopicProfileEntry {
|
|
68
|
+
current: TopicProfile | null;
|
|
69
|
+
/** Undo target — the profile the operator last saw disclosed (§8/R7-4). */
|
|
70
|
+
previous: TopicProfile | null;
|
|
71
|
+
intendedProfile: IntendedProfileShadow | null;
|
|
72
|
+
parked: ParkedProfile | null;
|
|
73
|
+
/** §10.4 consecutive attributable spawn-failure counter. */
|
|
74
|
+
breakerCount: number;
|
|
75
|
+
}
|
|
76
|
+
export declare class FlushRefusedError extends Error {
|
|
77
|
+
constructor(cause: unknown);
|
|
78
|
+
}
|
|
79
|
+
export declare class ProfileLockTimeoutError extends Error {
|
|
80
|
+
constructor(topicKey: string);
|
|
81
|
+
}
|
|
82
|
+
export declare class ProfileValidationRefusal extends Error {
|
|
83
|
+
readonly validation: ProfileValidationError;
|
|
84
|
+
constructor(validation: ProfileValidationError);
|
|
85
|
+
}
|
|
86
|
+
export interface MutateOptions {
|
|
87
|
+
/**
|
|
88
|
+
* Shift current→previous before applying the patch. The orchestration
|
|
89
|
+
* layer sets this on the FIRST write of a disclosed burst / coalescing
|
|
90
|
+
* window (§5.1 once-per-delta-carrying-disclosure cadence).
|
|
91
|
+
*/
|
|
92
|
+
shiftPrevious?: boolean;
|
|
93
|
+
/** WRITE-phase lock-acquisition timeout (ms). Default 5000. */
|
|
94
|
+
lockTimeoutMs?: number;
|
|
95
|
+
}
|
|
96
|
+
export interface MutateResult {
|
|
97
|
+
/** False when the patch produced no effective field change. */
|
|
98
|
+
changed: boolean;
|
|
99
|
+
entry: TopicProfileEntry;
|
|
100
|
+
/** True when this mutate cleared a §10.4 parked profile (supersession). */
|
|
101
|
+
supersededParked: boolean;
|
|
102
|
+
}
|
|
103
|
+
export interface ReplaceResult {
|
|
104
|
+
/** False when the arriving entry equals local current (no effective delta). */
|
|
105
|
+
delta: boolean;
|
|
106
|
+
entry: TopicProfileEntry;
|
|
107
|
+
/** §14 skew arm (ii): a populated local shadow retained against a shadowless REPLACE. */
|
|
108
|
+
retainedLocalShadow: boolean;
|
|
109
|
+
/** §14 skew arm (i): an arriving shadow discarded because this machine is not in dry-run. */
|
|
110
|
+
discardedArrivingShadow: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* §5.3/§10.2 receiving-machine revalidation: fields of the ARRIVING entry
|
|
113
|
+
* that failed the closed-enum/framework-compat clamp on this host and fell
|
|
114
|
+
* to the default (null) for that field. Empty when revalidation was not
|
|
115
|
+
* requested or everything validated. The caller owns the one-line
|
|
116
|
+
* disclosure per dropped field (aggregated per §5.3).
|
|
117
|
+
*/
|
|
118
|
+
droppedFields: ProfileValidationError[];
|
|
119
|
+
}
|
|
120
|
+
export interface ReplaceRevalidationOptions {
|
|
121
|
+
/**
|
|
122
|
+
* The framework an arriving model id validates against when the arriving
|
|
123
|
+
* entry does not itself carry a valid framework (§10.2 framework-compat).
|
|
124
|
+
*/
|
|
125
|
+
fallbackFramework: IntelligenceFramework;
|
|
126
|
+
}
|
|
127
|
+
export interface ReplaceOptions {
|
|
128
|
+
/**
|
|
129
|
+
* §5.3 (mandatory at the transfer-apply and §12 restore-apply doors): run
|
|
130
|
+
* the full §10.2 closed-enum + framework-compat clamp over the ARRIVING
|
|
131
|
+
* entry BEFORE persist — never trusted because a peer sent it. A failing
|
|
132
|
+
* field falls to the default (null) for that field and is reported in
|
|
133
|
+
* `droppedFields` for the caller's one-line disclosure. The installed-CLI
|
|
134
|
+
* arm of §5.3 revalidation stays at the resolution boundary
|
|
135
|
+
* (TopicProfileResolver.isLaunchable) so a valid pin is RETAINED — it
|
|
136
|
+
* falls back at launch with the same disclosure, and recovers when the
|
|
137
|
+
* CLI appears. Omitted = no revalidation (trusted local callers only).
|
|
138
|
+
*/
|
|
139
|
+
revalidate?: ReplaceRevalidationOptions;
|
|
140
|
+
}
|
|
141
|
+
export interface TopicProfileStoreOptions {
|
|
142
|
+
/** Absolute path to state/topic-profiles.json. */
|
|
143
|
+
stateFilePath: string;
|
|
144
|
+
/** Absolute path to the legacy state/topic-frameworks.json (seed + mirror). */
|
|
145
|
+
legacyFrameworksPath?: string;
|
|
146
|
+
/** Whether THIS machine is in dry-run (governs arriving-shadow fate, §14). */
|
|
147
|
+
isDryRun?: () => boolean;
|
|
148
|
+
now?: () => Date;
|
|
149
|
+
/** Optional audit sink (rollback-window reconcile + boot events, §12). */
|
|
150
|
+
audit?: (event: Record<string, unknown>) => void;
|
|
151
|
+
}
|
|
152
|
+
export declare class TopicProfileStore {
|
|
153
|
+
private readonly stateFilePath;
|
|
154
|
+
private readonly legacyFrameworksPath;
|
|
155
|
+
private readonly isDryRun;
|
|
156
|
+
private readonly now;
|
|
157
|
+
/** AUTHORITATIVE in-memory cache (§5.1). */
|
|
158
|
+
private topics;
|
|
159
|
+
/** Deep snapshot of the last durably-flushed topics map (rollback target). */
|
|
160
|
+
private lastFlushed;
|
|
161
|
+
private mirrorGeneratedAt;
|
|
162
|
+
/** Per-topic process-local locks (promise chains). */
|
|
163
|
+
private locks;
|
|
164
|
+
/** Store-wide serialized flush queue (§5.1 round-4/6). */
|
|
165
|
+
private flushInFlight;
|
|
166
|
+
private trailingFlush;
|
|
167
|
+
constructor(options: TopicProfileStoreOptions);
|
|
168
|
+
private readonly audit;
|
|
169
|
+
/** Entry for a topic, or null. Cache read — never touches disk. */
|
|
170
|
+
get(topicKey: number | string): TopicProfileEntry | null;
|
|
171
|
+
/** The live profile for a topic (resolution input). Never the shadow. */
|
|
172
|
+
resolve(topicKey: number | string): TopicProfile | null;
|
|
173
|
+
/** Undo target (§10.3). Null when nothing to undo yet. */
|
|
174
|
+
previousFor(topicKey: number | string): TopicProfile | null;
|
|
175
|
+
/** Admin/migration only (§5.1) — read surfaces use get(). */
|
|
176
|
+
all(): Record<string, TopicProfileEntry>;
|
|
177
|
+
/**
|
|
178
|
+
* Run `fn` holding the topic's process-local lock. The §8 RESPAWN phase and
|
|
179
|
+
* escalation swaps serialize through this same lock; `mutate` uses it for
|
|
180
|
+
* the WRITE phase. `timeoutMs` bounds ACQUISITION (a wedged holder causes a
|
|
181
|
+
* ProfileLockTimeoutError, not an unbounded queue); the holder itself is
|
|
182
|
+
* bounded by the caller (§8 RESPAWN-phase TTL).
|
|
183
|
+
*/
|
|
184
|
+
withTopicLock<T>(topicKey: number | string, fn: () => Promise<T> | T, timeoutMs?: number): Promise<T>;
|
|
185
|
+
/**
|
|
186
|
+
* Field-merged single-writer write. `null` field values CLEAR the field;
|
|
187
|
+
* `undefined` fields are untouched. Enforces the §4 model/modelTier hard
|
|
188
|
+
* mutual exclusion against the MERGE RESULT. Resolves only after the write
|
|
189
|
+
* is durable; throws FlushRefusedError (with rollback) when it is not.
|
|
190
|
+
*/
|
|
191
|
+
mutate(topicKey: number | string, patch: Partial<Omit<TopicProfile, 'updatedAt'>> & {
|
|
192
|
+
updatedBy: string;
|
|
193
|
+
}, opts?: MutateOptions): Promise<MutateResult>;
|
|
194
|
+
/**
|
|
195
|
+
* Wholesale per-topic REPLACE — NOT a field-merge (§5.3 round-3: a merge
|
|
196
|
+
* would skip nulls and resurrect a pin the operator cleared remotely).
|
|
197
|
+
* `previous` is pinned to the receiving machine's pre-replace `current`
|
|
198
|
+
* (undo means "back to what this machine had") — EXCEPT when the REPLACE
|
|
199
|
+
* produces no effective delta (A→B→A round-trip, duplicate retried pull):
|
|
200
|
+
* then `previous` must NOT shift (§5.1 round-10).
|
|
201
|
+
*
|
|
202
|
+
* Arriving-shadow fate under regime/timing skew (§14 round-13):
|
|
203
|
+
* (i) a NON-dry-run receiver discards the arriving shadow;
|
|
204
|
+
* (ii) an arriving entry with NO shadow never destroys a populated local
|
|
205
|
+
* shadow on a still-dry-run receiver — it is retained.
|
|
206
|
+
*/
|
|
207
|
+
replaceEntry(topicKey: number | string, arriving: {
|
|
208
|
+
current: TopicProfile | null;
|
|
209
|
+
intendedProfile?: IntendedProfileShadow | null;
|
|
210
|
+
}, opts?: ReplaceOptions): Promise<ReplaceResult>;
|
|
211
|
+
/** Record a dry-run intent. Never read by resolution. */
|
|
212
|
+
setShadow(topicKey: number | string, fields: IntendedProfileShadow['fields'], recordedBy: string): Promise<void>;
|
|
213
|
+
/**
|
|
214
|
+
* The dryRun true→false flip clears EVERY topic's shadow — intents are
|
|
215
|
+
* NEVER promoted, at the flip or ever (§14 round-12). Returns the cleared
|
|
216
|
+
* intents so the caller can surface the ONE coalesced expired-intents
|
|
217
|
+
* notice.
|
|
218
|
+
*/
|
|
219
|
+
clearAllShadows(): Promise<Array<{
|
|
220
|
+
topicKey: string;
|
|
221
|
+
shadow: IntendedProfileShadow;
|
|
222
|
+
}>>;
|
|
223
|
+
/** Park the current profile as intended-but-unhealthy and revert. */
|
|
224
|
+
parkAndRevert(topicKey: number | string, reason: string, revertTo: TopicProfile | null): Promise<void>;
|
|
225
|
+
/** The parked pin, for the §5.2(b) re-apply recovery write. */
|
|
226
|
+
parkedFor(topicKey: number | string): ParkedProfile | null;
|
|
227
|
+
/** Clear the parked state (after a successful re-apply). */
|
|
228
|
+
clearParked(topicKey: number | string): Promise<void>;
|
|
229
|
+
/** Increment the attributable spawn-failure counter; returns the new count. */
|
|
230
|
+
incrementBreaker(topicKey: number | string): Promise<number>;
|
|
231
|
+
/** §10.4 — the counter resets on any successful spawn. */
|
|
232
|
+
resetBreaker(topicKey: number | string): Promise<void>;
|
|
233
|
+
/**
|
|
234
|
+
* Explicit cache invalidation — the restore route fires this after a
|
|
235
|
+
* snapshot restore lands on disk (the file is otherwise server-owned
|
|
236
|
+
* single-writer; external edits reconcile only here or at boot).
|
|
237
|
+
*/
|
|
238
|
+
invalidateAndReload(): void;
|
|
239
|
+
private loadFromDisk;
|
|
240
|
+
/**
|
|
241
|
+
* Boot persistence + mirror self-heal (§12). Seeded/reconciled entries are
|
|
242
|
+
* flushed so `topic-profiles.json` exists from first boot, and a mirror
|
|
243
|
+
* that diverges from the profile store is regenerated (the flush path does
|
|
244
|
+
* both). Best-effort and async — boot itself never refuses; the cache is
|
|
245
|
+
* authoritative and the seed is reconstructible at every boot.
|
|
246
|
+
*/
|
|
247
|
+
private bootFinalize;
|
|
248
|
+
/**
|
|
249
|
+
* One-directional read-only seed from the legacy framework store: seed the
|
|
250
|
+
* `framework` field for any topic ABSENT from the profile store. Never
|
|
251
|
+
* overwrites — EXCEPT the §12 rollback-window reconcile: when the legacy
|
|
252
|
+
* file's `updatedAt` differs from the last mirror-write stamp, the legacy
|
|
253
|
+
* file was written by something other than this store's mirror (a rolled-
|
|
254
|
+
* back binary's live `/route` writes), so topics whose framework VALUE
|
|
255
|
+
* differs re-seed the framework arm only, audited. `previous: null` on
|
|
256
|
+
* seeds (§5.1 — undo with no snapshot is refused plainly upstream).
|
|
257
|
+
*/
|
|
258
|
+
private seedFromLegacy;
|
|
259
|
+
/**
|
|
260
|
+
* Serialize flushes store-wide. A flush snapshots the authoritative cache
|
|
261
|
+
* AT FLUSH TIME, so a later-completing flush can never persist an older
|
|
262
|
+
* snapshot. Writes arriving mid-flight coalesce onto ONE trailing flush.
|
|
263
|
+
* Failure: every undurable waiter is refused + the cache rolls back to the
|
|
264
|
+
* last durably-flushed snapshot BEFORE the refusals fire.
|
|
265
|
+
*/
|
|
266
|
+
private flushDurably;
|
|
267
|
+
private writeFileAtomic;
|
|
268
|
+
/**
|
|
269
|
+
* §5.1/§12 — the legacy file becomes a read-only mirror regenerated from
|
|
270
|
+
* the profile store (sole writer = this store), so a binary rollback to
|
|
271
|
+
* the prior release still reads current framework data. Best-effort,
|
|
272
|
+
* SECOND (profile file is the source of truth and flushes first), and only
|
|
273
|
+
* rewritten when the framework view actually changed.
|
|
274
|
+
*/
|
|
275
|
+
private lastMirrorView;
|
|
276
|
+
private regenerateMirror;
|
|
277
|
+
/** The mirror-generation stamp (§12 rollback-window reconcile predicate). */
|
|
278
|
+
getMirrorGeneratedAt(): string | undefined;
|
|
279
|
+
private entryFor;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* §5.3/§10.2 — clamp an ARRIVING (peer-asserted, untrusted) profile through
|
|
283
|
+
* the closed enums, field by field. Unlike the write-surface refusal
|
|
284
|
+
* (first-error, profile unchanged), transfer-apply degrades PER FIELD: a
|
|
285
|
+
* failing field falls to null (the default for that field at resolution)
|
|
286
|
+
* and is reported for the one-line disclosure; valid sibling fields are
|
|
287
|
+
* kept. Provenance (updatedAt/updatedBy) travels verbatim — a malformed
|
|
288
|
+
* provenance pair means the entry is not a well-formed profile at all and
|
|
289
|
+
* is treated as absent (current: null), reported.
|
|
290
|
+
*
|
|
291
|
+
* The arriving model id validates against the arriving entry's OWN
|
|
292
|
+
* framework when that framework is enum-valid, else `fallbackFramework`
|
|
293
|
+
* (§10.2 framework-compat — a model incompatible with the framework falls).
|
|
294
|
+
* A clamped result holding BOTH model and modelTier drops both (§4 hard
|
|
295
|
+
* mutual exclusion — picking a winner silently is the named anti-pattern).
|
|
296
|
+
*/
|
|
297
|
+
export declare function revalidateArrivingProfile(arriving: TopicProfile | null, fallbackFramework: IntelligenceFramework): {
|
|
298
|
+
profile: TopicProfile | null;
|
|
299
|
+
dropped: ProfileValidationError[];
|
|
300
|
+
};
|
|
301
|
+
/** §5.3 — the dry-run shadow travels on the pull and is revalidated the same way. */
|
|
302
|
+
export declare function revalidateArrivingShadow(arriving: IntendedProfileShadow, fallbackFramework: IntelligenceFramework): {
|
|
303
|
+
shadow: IntendedProfileShadow | null;
|
|
304
|
+
dropped: ProfileValidationError[];
|
|
305
|
+
};
|
|
306
|
+
/** Field-level profile equality over the five profile axes (delta detection). */
|
|
307
|
+
export declare function profilesEqual(a: TopicProfile | null, b: TopicProfile | null): boolean;
|
|
308
|
+
//# sourceMappingURL=TopicProfileStore.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TopicProfileStore.d.ts","sourceRoot":"","sources":["../../src/core/TopicProfileStore.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAIH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAG9E,OAAO,EAGL,KAAK,kBAAkB,EACvB,KAAK,gBAAgB,EACrB,KAAK,sBAAsB,EAC3B,KAAK,YAAY,EAClB,MAAM,6BAA6B,CAAC;AAErC,wEAAwE;AACxE,MAAM,WAAW,YAAY;IAC3B,SAAS,CAAC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