@evomap/evolver-proxy 2.0.2 → 2.0.12

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.
Files changed (53) hide show
  1. package/dist/bin/evolver-proxy.d.ts +12 -0
  2. package/dist/bin/evolver-proxy.js +192 -59
  3. package/dist/daemon/proxyDaemon.js +10 -0
  4. package/dist/daemon/systemdNotifier.d.ts +2 -0
  5. package/dist/daemon/systemdNotifier.js +11 -1
  6. package/dist/lifecycle/claimNudge.js +1 -1
  7. package/dist/lifecycle/deployGuard.js +1 -1
  8. package/dist/lifecycle/legacyNodeId.js +1 -1
  9. package/dist/lifecycle/manager.js +1 -1
  10. package/dist/llm/bodyCapture.js +1 -1
  11. package/dist/llm/index.js +1 -1
  12. package/dist/llm/server.js +1 -1
  13. package/dist/llm/traceBackfill.js +1 -1
  14. package/dist/llm/traceConfig.js +1 -1
  15. package/dist/llm/traceControl.js +1 -1
  16. package/dist/llm/traceEnvelope.js +1 -1
  17. package/dist/llm/traceSink.js +1 -1
  18. package/dist/llm/traceUploadPayload.js +1 -1
  19. package/dist/llm/upstream.js +1 -1
  20. package/dist/router/cachePassthrough.js +1 -1
  21. package/dist/router/features.js +1 -1
  22. package/dist/router/index.js +1 -1
  23. package/dist/router/messagesRoute.js +1 -1
  24. package/dist/router/modelRouter.js +1 -1
  25. package/dist/router/providerRoutes.js +1 -1
  26. package/dist/router/sseScan.js +1 -1
  27. package/dist/selfUpdate/bootstrap.d.ts +106 -13
  28. package/dist/selfUpdate/bootstrap.js +3418 -176
  29. package/dist/selfUpdate/bootstrapReadiness.d.ts +9 -0
  30. package/dist/selfUpdate/bootstrapReadiness.js +153 -0
  31. package/dist/selfUpdate/controllerLifecycleAuthority.d.ts +45 -0
  32. package/dist/selfUpdate/controllerLifecycleAuthority.js +61 -0
  33. package/dist/selfUpdate/executor.d.ts +17 -6
  34. package/dist/selfUpdate/executor.js +158 -58
  35. package/dist/selfUpdate/index.d.ts +2 -1
  36. package/dist/selfUpdate/index.js +2 -1
  37. package/dist/selfUpdate/migration.d.ts +80 -15
  38. package/dist/selfUpdate/migration.js +2513 -156
  39. package/dist/selfUpdate/policy.js +2 -8
  40. package/dist/selfUpdate/recoveryChildStartGate.d.ts +29 -0
  41. package/dist/selfUpdate/recoveryChildStartGate.js +319 -0
  42. package/dist/selfUpdate/releaseBinary.d.ts +3 -0
  43. package/dist/selfUpdate/releaseBinary.js +46 -3
  44. package/dist/selfUpdate/transaction.d.ts +8 -0
  45. package/dist/selfUpdate/transaction.js +166 -18
  46. package/dist/selfUpdate/unixController.d.ts +8 -0
  47. package/dist/selfUpdate/unixController.js +364 -38
  48. package/dist/selfUpdate/windowsController.d.ts +14 -2
  49. package/dist/selfUpdate/windowsController.js +482 -103
  50. package/dist/selfUpdate/windowsUpdater.d.ts +25 -0
  51. package/dist/selfUpdate/windowsUpdater.js +174 -7
  52. package/dist/sync/engine.js +1 -1
  53. package/package.json +3 -3
@@ -1,7 +1,9 @@
1
1
  import { spawn } from 'node:child_process';
2
+ import { util } from '@evomap/evolver-core';
2
3
  import { type MigrationOptions } from './migration.js';
3
- export declare const BOOTSTRAP_SUCCESS_FILE = "bootstrap.json";
4
- export type BootstrapSkipReason = 'already_supervised' | 'already_bootstrapped' | 'unsupported_install_shape' | 'policy_not_auto' | 'bootstrap_disabled' | 'ci_environment' | 'container_environment' | 'recent_failure';
4
+ export declare const RECOVERY_CONTROLLER_LIFECYCLE_OWNER_CAPABILITY_ENV = "EVOLVER_INTERNAL_RECOVERY_CONTROLLER_LIFECYCLE_OWNER";
5
+ type BootstrapProcessKill = (pid: number, signal: NodeJS.Signals | 0) => boolean;
6
+ type BootstrapSkipReason = 'already_supervised' | 'already_bootstrapped' | 'unsupported_install_shape' | 'policy_not_auto' | 'bootstrap_disabled' | 'ci_environment' | 'container_environment' | 'recent_failure' | 'migration_ambiguous' | 'bootstrap_attempt_invalid' | 'bootstrap_intent_pending' | 'bootstrap_attempt_pending';
5
7
  export interface BootstrapDecision {
6
8
  proceed: boolean;
7
9
  reason?: BootstrapSkipReason;
@@ -9,23 +11,55 @@ export interface BootstrapDecision {
9
11
  export interface BootstrapOutcome {
10
12
  ok: boolean;
11
13
  /**
12
- * 'bootstrapped' / 'migrated' on success; failure/skip reason otherwise. Migration
13
- * failures record 'migration_failed' / 'migration_timeout' (both cooldown-worthy).
14
+ * 'bootstrapped' / 'bootstrapped_lock_release_unconfirmed' / 'migrated' on success;
15
+ * failure/skip reason otherwise. Migration failures record 'migration_failed' /
16
+ * 'migration_timeout' (both cooldown-worthy).
14
17
  */
15
18
  reason: string;
16
19
  detail?: string;
20
+ /** The child may own manager or IPC state, so the foreground proxy must exit. */
21
+ requiresForegroundExit?: true;
17
22
  }
18
23
  export interface BootstrapRunOptions {
19
24
  env: NodeJS.ProcessEnv;
20
25
  platform?: NodeJS.Platform;
21
26
  execPath?: string;
22
27
  argv1?: string;
28
+ /** Parent force-timeout; it must exceed the child's transaction budget. */
23
29
  timeoutMs?: number;
30
+ /** Absolute child deadline offset. Production uses the complete transaction budget. */
31
+ transactionBudgetMs?: number;
32
+ /** Bounded wait for OS confirmation after force-terminating the process tree. */
33
+ terminationGraceMs?: number;
24
34
  now?: number;
25
35
  exists?: (path: string) => boolean;
26
36
  readFile?: (path: string) => string;
27
37
  writeFile?: (path: string, content: string) => void;
28
38
  spawnFn?: typeof spawn;
39
+ treeKillSpawnFn?: typeof spawn;
40
+ processKill?: BootstrapProcessKill;
41
+ /** Test-only failure seam; production publication always uses the strict exclusive writer. */
42
+ beforeIntentPublish?: () => void;
43
+ /** Test-only crash seam for each durable initial-publication boundary. */
44
+ afterIntentPublicationStep?: (step: 'create' | 'partial_write' | 'file_fsync' | 'link' | 'directory_fsync', path: string) => void;
45
+ /** Test-only crash seams around the atomic terminal/clear state transitions. */
46
+ beforeIntentTerminalFsync?: (path: string) => void;
47
+ afterIntentTerminalPublish?: () => void;
48
+ afterIntentClearRename?: () => void;
49
+ /** Test-only trust seams. Production always uses native owner/DACL validation. */
50
+ assertIntentDirectoryTrust?: (directory: string) => void;
51
+ assertIntentFileTrust?: (path: string) => void;
52
+ assertLegacyProofDirectoryTrust?: (directory: string) => void;
53
+ assertLegacyProofFileTrust?: (path: string) => void;
54
+ afterLegacyProofRead?: (path: string) => void;
55
+ /** Test-only process identity seams; production uses fresh native core observations. */
56
+ readRegistrationProcessStartIdentity?: (pid: number) => util.FileLockProcessStartIdentity | null;
57
+ registrationOwnerProcessStatus?: (owner: Pick<util.FileLockOwnerRecord, 'pid' | 'processStartIdentity'>) => util.FileLockOwnerProcessStatus;
58
+ registrationPublisherProcessStatus?: (publisher: Readonly<{
59
+ pid: number;
60
+ token: string;
61
+ processIdentityDigest: string;
62
+ }>) => util.FileLockOwnerProcessStatus;
29
63
  /**
30
64
  * Extra seams forwarded to the one-time npm/JS → standalone migration (migration.ts).
31
65
  * Bootstrap-level seams (exists/readFile/writeFile/spawnFn/now/execPath) win when both
@@ -35,18 +69,67 @@ export interface BootstrapRunOptions {
35
69
  }
36
70
  /** Lifecycle state dir mirror of evolver-cli lifecyclePaths (kept dependency-free across packages). */
37
71
  export declare function resolveBootstrapStateDir(env: NodeJS.ProcessEnv): string;
72
+ export declare function withRecoveryControllerLifecycleOwnerCapability(env: NodeJS.ProcessEnv, owner: util.FileLockOwnerRecord): NodeJS.ProcessEnv;
73
+ export interface PreparedRecoveryControllerLifecycleOwnerCapability {
74
+ env: NodeJS.ProcessEnv;
75
+ startupAckToken: string;
76
+ }
77
+ export declare function prepareRecoveryControllerLifecycleOwnerCapability(env: NodeJS.ProcessEnv, owner: util.FileLockOwnerRecord): PreparedRecoveryControllerLifecycleOwnerCapability;
78
+ export declare function clearRecoveryControllerLifecycleOwnerCapability(env: NodeJS.ProcessEnv): void;
79
+ export declare function publishRecoveryControllerLifecycleStartupAttestation(env: NodeJS.ProcessEnv, descriptor?: number): boolean;
80
+ export declare function lifecycleBootstrapStatePresent(env: NodeJS.ProcessEnv, exists?: (path: string) => boolean): boolean;
81
+ export type BootstrapDurableStateOptions = Pick<BootstrapRunOptions, 'exists' | 'readFile' | 'assertIntentFileTrust' | 'assertLegacyProofDirectoryTrust' | 'assertLegacyProofFileTrust' | 'afterLegacyProofRead' | 'registrationOwnerProcessStatus' | 'now'> & {
82
+ /** Exact owner currently holding the shared lifecycle mutation lock. */
83
+ expectedRecoveryOwner?: util.FileLockOwnerRecord;
84
+ };
85
+ export interface LifecycleBootstrapOwnerLease {
86
+ readonly path: string;
87
+ readonly owner: util.FileLockOwnerRecord;
88
+ assertOwned(): void;
89
+ armProcess(pid: number): util.FileLockOwnerRecord;
90
+ disarmProcess(): void;
91
+ retainProcess(): void;
92
+ transferToProcess(pid: number): util.FileLockOwnerRecord;
93
+ release(): void;
94
+ }
95
+ export declare function assertSupervisedLifecycleBootstrapState(env: NodeJS.ProcessEnv, options?: BootstrapDurableStateOptions & {
96
+ requireLifecycleState?: boolean;
97
+ /** Test-only parent identity seam; production always binds to process.ppid. */
98
+ recoveryControllerParentPid?: number;
99
+ }): void;
100
+ /**
101
+ * Revalidate the narrow parent-owned activation window used by a newly launched recovery
102
+ * controller. This deliberately rejects committed supervision: callers use it only as delegated
103
+ * authority while the lifecycle parent still owns the mutation lock and is waiting for readiness.
104
+ */
105
+ export declare function assertActiveSupervisedLifecycleBootstrapDelegation(env: NodeJS.ProcessEnv, options?: BootstrapDurableStateOptions): void;
106
+ /**
107
+ * Revalidate a transaction-bound launcher before any self-update operation. Unlike the startup
108
+ * assertion above, this never accepts the narrow activating window used to publish readiness.
109
+ */
110
+ export declare function assertCommittedLifecycleBootstrapState(env: NodeJS.ProcessEnv, options?: BootstrapDurableStateOptions): void;
111
+ /**
112
+ * Serialize self-update with every lifecycle bootstrap, recovery, and manual-transition writer.
113
+ * Acquisition is deliberately fail-fast: a heartbeat must not block the daemon while another
114
+ * lifecycle owner is active. Transaction-bound launchers revalidate the committed receipt under
115
+ * the exact acquired generation; legacy launchers still hold and recheck the shared owner lock.
116
+ */
117
+ export declare function acquireLifecycleBootstrapOwnerLease(env: NodeJS.ProcessEnv, lockOptions?: {
118
+ maxTries?: number;
119
+ waitMs?: number;
120
+ }): LifecycleBootstrapOwnerLease;
38
121
  export declare function looksLikeContainer(exists: (path: string) => boolean, readFile: (path: string) => string): boolean;
39
122
  /** True when a recent bootstrap/migration attempt failed within the cooldown window. */
40
- export declare function recentBootstrapFailure(env: NodeJS.ProcessEnv, readFile: (path: string) => string, now: number): boolean;
123
+ export declare function recentBootstrapFailure(env: NodeJS.ProcessEnv, optionsOrReadFile: Pick<BootstrapRunOptions, 'exists' | 'readFile' | 'assertIntentFileTrust'> | ((path: string) => string), now: number): boolean;
41
124
  /**
42
125
  * Decide whether an unsupervised (degraded) startup should attempt first-run bootstrap.
43
126
  * Pure — filesystem access is injectable for tests.
44
127
  */
45
- export declare function shouldBootstrap(env: NodeJS.ProcessEnv, platform?: NodeJS.Platform, options?: Pick<BootstrapRunOptions, 'exists' | 'readFile' | 'now' | 'execPath'>): BootstrapDecision;
128
+ export declare function shouldBootstrap(env: NodeJS.ProcessEnv, platform?: NodeJS.Platform, options?: Pick<BootstrapRunOptions, 'exists' | 'readFile' | 'now' | 'execPath' | 'assertIntentFileTrust'>): BootstrapDecision;
46
129
  /**
47
130
  * Resolve the `lifecycle bootstrap` invocation for the current install shape: standalone binary,
48
131
  * CLI entry through node, or the npm-installed @evomap/evolver-cli sibling. Returns undefined when
49
- * no CLI can be located (degrade to the existing warning instead of failing startup).
132
+ * no CLI can be located. The caller may continue only after confirming durable state is clean.
50
133
  */
51
134
  export declare function resolveBootstrapCliInvocation(options?: Pick<BootstrapRunOptions, 'execPath' | 'argv1' | 'exists'>): {
52
135
  command: string;
@@ -56,14 +139,24 @@ export declare function resolveBootstrapCliInvocation(options?: Pick<BootstrapRu
56
139
  export declare function recordBootstrapAttempt(env: NodeJS.ProcessEnv, outcome: BootstrapOutcome, options?: Pick<BootstrapRunOptions, 'writeFile' | 'now'>): void;
57
140
  /** Spawn `evolver lifecycle bootstrap` and await its result within a bounded timeout. */
58
141
  export declare function runBootstrap(options: BootstrapRunOptions): Promise<BootstrapOutcome>;
59
- export interface DegradedStartupBootstrapResult {
60
- /** True when bootstrap succeeded and startup should exit so the new service takes over. */
61
- handedOver: boolean;
62
- /** Operator-facing single-line message (stdout when handed over, stderr otherwise). */
142
+ export type DegradedStartupBootstrapResult = {
143
+ disposition: 'continue';
144
+ handedOver: false;
63
145
  message: string;
64
- }
146
+ } | {
147
+ disposition: 'handoff';
148
+ handedOver: true;
149
+ exitCode: 0;
150
+ message: string;
151
+ } | {
152
+ disposition: 'fail_closed';
153
+ handedOver: false;
154
+ exitCode: 1;
155
+ message: string;
156
+ };
65
157
  /**
66
158
  * Orchestrate bootstrap for a degraded (default-auto, unsupervised) startup: decide, attempt,
67
159
  * record, and produce the operator message. Never throws.
68
160
  */
69
- export declare function bootstrapDegradedSelfUpdateStartup(env: NodeJS.ProcessEnv, platform?: NodeJS.Platform, options?: Omit<BootstrapRunOptions, 'env' | 'platform'>): Promise<DegradedStartupBootstrapResult>;
161
+ export declare function bootstrapDegradedSelfUpdateStartup(env: NodeJS.ProcessEnv, platform?: NodeJS.Platform, options?: Omit<BootstrapRunOptions, 'env' | 'platform'>): Promise<DegradedStartupBootstrapResult>;
162
+ export {};