@ddtcorex/dsh-maestro-core 0.11.2 → 0.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (86) hide show
  1. package/README.md +18 -1
  2. package/cordis.patch.yml +4 -4
  3. package/lib/client.js +5 -29
  4. package/lib/guard/config.d.ts +3 -43
  5. package/lib/guard/config.js +3 -95
  6. package/lib/guard/index.d.ts +0 -17
  7. package/lib/guard/index.js +4 -54
  8. package/lib/guard/journal.js +11 -1
  9. package/lib/guard/paths.d.ts +0 -6
  10. package/lib/guard/paths.js +0 -12
  11. package/lib/health-poller.d.ts +0 -2
  12. package/lib/health-poller.js +0 -4
  13. package/lib/notifier.d.ts +0 -8
  14. package/lib/notifier.js +0 -19
  15. package/lib/paths.d.ts +2 -3
  16. package/lib/paths.js +3 -8
  17. package/lib/plugin.d.ts +0 -1
  18. package/lib/plugin.js +37 -29
  19. package/lib/preset.js +1 -1
  20. package/lib/restart-exec.d.ts +0 -1
  21. package/lib/restart-exec.js +0 -1
  22. package/lib/restart-guards.d.ts +1 -1
  23. package/lib/restart-guards.js +3 -33
  24. package/lib/self-kill-guard.d.ts +0 -2
  25. package/lib/self-kill-guard.js +0 -4
  26. package/lib/supervisor.d.ts +0 -1
  27. package/lib/supervisor.js +0 -9
  28. package/lib/sync/cli.js +0 -8
  29. package/lib/sync/config.d.ts +1 -19
  30. package/lib/sync/config.js +0 -18
  31. package/lib/sync/index.js +2 -17
  32. package/lib/sync/merge.d.ts +0 -2
  33. package/lib/sync/merge.js +0 -2
  34. package/lib/sync/remote-agent.d.ts +0 -1
  35. package/lib/sync/remote-agent.js +0 -1
  36. package/lib/sync/snapshot.d.ts +0 -5
  37. package/lib/sync/snapshot.js +0 -33
  38. package/lib/sync/sync-service.d.ts +0 -20
  39. package/lib/sync/sync-service.js +0 -13
  40. package/lib/sync/transport.d.ts +1 -1
  41. package/lib/sync/transport.js +0 -4
  42. package/lib/types/client/config/MaestroSettings.d.ts.map +1 -1
  43. package/lib/types/client/config/components/BrandMark.d.ts +5 -2
  44. package/lib/types/client/config/components/BrandMark.d.ts.map +1 -1
  45. package/lib/types/client/config/guard-view.d.ts +7 -10
  46. package/lib/types/client/config/guard-view.d.ts.map +1 -1
  47. package/lib/types/client/sync/ui.d.ts +0 -4
  48. package/lib/types/client/sync/ui.d.ts.map +1 -1
  49. package/package.json +5 -2
  50. package/skills/dsh-safe-restart/scripts/restart-dsh-web.sh +4 -3
  51. package/src/client/config/MaestroSettings.tsx +4 -9
  52. package/src/client/config/components/BrandMark.tsx +5 -2
  53. package/src/client/config/guard-view.ts +10 -37
  54. package/src/client/sync/ui.tsx +1 -17
  55. package/src/host/guard/config.ts +4 -107
  56. package/src/host/guard/index.ts +4 -53
  57. package/src/host/guard/journal.ts +9 -1
  58. package/src/host/guard/paths.ts +0 -11
  59. package/src/host/health-poller.ts +0 -5
  60. package/src/host/notifier.ts +0 -26
  61. package/src/host/paths.ts +3 -7
  62. package/src/host/plugin.ts +34 -28
  63. package/src/host/preset.ts +1 -1
  64. package/src/host/restart-exec.ts +0 -2
  65. package/src/host/restart-guards.ts +3 -27
  66. package/src/host/self-kill-guard.ts +0 -5
  67. package/src/host/supervisor.ts +0 -8
  68. package/src/host/sync/backup-config.ts +0 -1
  69. package/src/host/sync/cli.ts +0 -9
  70. package/src/host/sync/config.ts +1 -24
  71. package/src/host/sync/index.ts +1 -41
  72. package/src/host/sync/merge.ts +0 -3
  73. package/src/host/sync/remote-agent.ts +0 -1
  74. package/src/host/sync/snapshot.ts +0 -30
  75. package/src/host/sync/ssh-mux.ts +0 -1
  76. package/src/host/sync/sync-service.ts +2 -32
  77. package/src/host/sync/transport.ts +2 -7
  78. package/lib/guard/migrate.d.ts +0 -15
  79. package/lib/guard/migrate.js +0 -42
  80. package/lib/sync/session-merge.d.ts +0 -18
  81. package/lib/sync/session-merge.js +0 -191
  82. package/scripts/sync/bench-preview.mjs +0 -43
  83. package/scripts/sync/cdp-sync-probe.mjs +0 -200
  84. package/scripts/sync/cdp-sync-verify.mjs +0 -169
  85. package/src/host/guard/migrate.ts +0 -41
  86. package/src/host/sync/session-merge.ts +0 -220
@@ -31,7 +31,6 @@ export * from './resume-tools.js'
31
31
  import {
32
32
  probeToolView,
33
33
  defaultResolveToolScope,
34
- type ToolViewProbe,
35
34
  type ToolViewProbeFn,
36
35
  type ToolScopeResolver,
37
36
  } from './tool-view.js'
@@ -264,10 +263,6 @@ export function isAutoResumePinned(config?: SupervisorPluginConfig): boolean {
264
263
  return typeof config?.autoResumeEnabled === 'boolean'
265
264
  }
266
265
 
267
- export function getAutoResumeEnabledExported(config?: SupervisorPluginConfig): boolean {
268
- return getAutoResumeEnabled(config)
269
- }
270
-
271
266
  /**
272
267
  * Wall-clock ms at which THIS process started, or `undefined` when it cannot
273
268
  * be established.
@@ -1147,11 +1142,40 @@ export function apply(ctx: any, config: SupervisorPluginConfig = {}): void {
1147
1142
  }
1148
1143
  })
1149
1144
 
1150
- try {
1151
- ctx.effect(() => registerSessionHealthService(ctx, config), 'supervisor:session-health')
1152
- } catch (e: any) {
1153
- try { ctx.logger?.warn?.(`[supervisor] session-health effect failed: ${e?.message ?? String(e)}`) } catch {}
1154
- }
1145
+ // RPC registration must wait for the `connection` fiber (DSH 0.2.x resolves
1146
+ // `owner.webServer` on that fiber): registering inline at apply() time
1147
+ // silently skips when `connection` is not active yet and the route stays
1148
+ // unregistered (HTTP 405). The child fiber keeps the top-level `inject`
1149
+ // empty so the boot resume scan is not held up.
1150
+ whenServicesActive(ctx, ['connection'], (scoped) => {
1151
+ try {
1152
+ scoped.effect(() => registerSessionHealthService(scoped, config), 'supervisor:session-health')
1153
+ } catch (e: any) {
1154
+ try { scoped.logger?.warn?.(`[supervisor] session-health effect failed: ${e?.message ?? String(e)}`) } catch {}
1155
+ }
1156
+ })
1157
+
1158
+ whenServicesActive(ctx, ['connection'], (scoped) => {
1159
+ scoped.effect(() => {
1160
+ let disposeRpc: (() => void) | undefined
1161
+ try {
1162
+ const conn = scoped.connection ?? scoped.get?.('connection')
1163
+ if (conn?.rpc?.handle) {
1164
+ disposeRpc = conn.rpc.handle(
1165
+ '/dsh-maestro-supervisor-resume',
1166
+ createResumeRpcHandler(ctx, { config }),
1167
+ )
1168
+ }
1169
+ } catch (e: any) {
1170
+ try {
1171
+ scoped.logger?.warn?.(`[supervisor] auto-resume RPC registration failed: ${e?.message ?? String(e)}`)
1172
+ } catch {}
1173
+ }
1174
+ return () => {
1175
+ try { disposeRpc?.() } catch {}
1176
+ }
1177
+ }, 'supervisor:resume-rpc')
1178
+ })
1155
1179
 
1156
1180
  ctx.effect(() => {
1157
1181
  let disposed = false
@@ -1164,27 +1188,9 @@ export function apply(ctx: any, config: SupervisorPluginConfig = {}): void {
1164
1188
  })
1165
1189
  }, 8000)
1166
1190
 
1167
- let disposeRpc: (() => void) | undefined
1168
- try {
1169
- const conn = ctx.connection ?? ctx.get?.('connection')
1170
- if (conn?.rpc?.handle) {
1171
- disposeRpc = conn.rpc.handle(
1172
- '/dsh-maestro-supervisor-resume',
1173
- createResumeRpcHandler(ctx, { config }),
1174
- )
1175
- }
1176
- } catch (e: any) {
1177
- try {
1178
- ctx.logger?.warn?.(`[supervisor] auto-resume RPC registration failed: ${e?.message ?? String(e)}`)
1179
- } catch {}
1180
- }
1181
-
1182
1191
  return () => {
1183
1192
  disposed = true
1184
1193
  if (timer) clearTimeout(timer)
1185
- if (disposeRpc) {
1186
- try { disposeRpc() } catch {}
1187
- }
1188
1194
  }
1189
1195
  }, 'supervisor:auto-resume')
1190
1196
 
@@ -125,7 +125,7 @@ export function makePresetSetup(
125
125
  if (typeof presets?.mount !== 'function') return Promise.resolve(undefined)
126
126
  return presets.mount(agentCtx, presetId)
127
127
  })
128
- return async (agentCtx: unknown, agent?: unknown) => { await mount(agentCtx, presetId) }
128
+ return async (agentCtx: unknown) => { await mount(agentCtx, presetId) }
129
129
  }
130
130
 
131
131
  /** Outcome of one repair attempt; `reason` is the operator-facing classification. */
@@ -58,8 +58,6 @@ export async function serializedSystemdRestart(deps: SerializedRestartDeps = {})
58
58
  exec('systemctl --user start dsh-web.service')
59
59
  }
60
60
 
61
- export const DSH_WEB_UNIT_NAME = 'dsh-web.service'
62
-
63
61
  export function dshWebUnitPath(): string {
64
62
  return process.env.DSH_WEB_UNIT_PATH ?? path.join(os.homedir(), '.config/systemd/user/dsh-web.service')
65
63
  }
@@ -60,8 +60,8 @@ export function isSelfCopyError(message: string): boolean {
60
60
  // that script writes this marker right before it intentionally takes dsh-web
61
61
  // down, so the supervisor's own health poll does not mistake a deliberate
62
62
  // restart (kill -> dry-boot -> relaunch, up to ~130s) for a crash and race it
63
- // with its own rollback + restartWeb(). Presence + freshness is authoritative;
64
- // the marker's content is never parsed.
63
+ // with its own rollback + restartWeb(). The marker is the JSON {ts, ttl}
64
+ // document at planned-restart.json; a plain mtime-only file is no longer read.
65
65
  export const PLANNED_RESTART_TTL_MS = 180_000
66
66
 
67
67
  export function isPlannedRestartFresh(mtimeMs: number, nowMs: number, ttlMs: number = PLANNED_RESTART_TTL_MS): boolean {
@@ -82,16 +82,7 @@ export function writePlannedRestart(ttlMs = 30000): void {
82
82
  markBootBoundary()
83
83
  }
84
84
 
85
- export function checkPlannedRestart(markerPath?: string): boolean {
86
- // Legacy path explicit: check mtime of that file
87
- if (markerPath) {
88
- try {
89
- const stat = fs.statSync(markerPath)
90
- return isPlannedRestartFresh(stat.mtimeMs, Date.now())
91
- } catch {
92
- return false
93
- }
94
- }
85
+ export function checkPlannedRestart(): boolean {
95
86
  // New JSON marker with {ts, ttl}
96
87
  try {
97
88
  const raw = fs.readFileSync(plannedRestartPath(), 'utf8')
@@ -100,26 +91,11 @@ export function checkPlannedRestart(markerPath?: string): boolean {
100
91
  return Date.now() - j.ts < j.ttl
101
92
  }
102
93
  } catch {}
103
- // Fallback: legacy plain file written by dsh-safe-web-update (no .json, mtime-based)
104
- try {
105
- const legacy = path.join(os.homedir(), '.dsh/.supervisor/planned-restart')
106
- const stat = fs.statSync(legacy)
107
- return isPlannedRestartFresh(stat.mtimeMs, Date.now())
108
- } catch {}
109
94
  return false
110
95
  }
111
96
 
112
97
  export function clearPlannedRestart(): void {
113
98
  try { fs.unlinkSync(plannedRestartPath()) } catch {}
114
- // also clear legacy plain file if present (best-effort, avoids stale suppression)
115
- try {
116
- const legacy = path.join(os.homedir(), '.dsh/.supervisor/planned-restart')
117
- if (fs.existsSync(legacy) && legacy !== plannedRestartPath()) {
118
- // only remove legacy if it was created as test artifact; keep conservative
119
- // but clearing both ensures checkPlannedRestart() returns false after clear
120
- try { fs.unlinkSync(legacy) } catch {}
121
- }
122
- } catch {}
123
99
  }
124
100
 
125
101
  // Restart-request variant of planned-restart.json: carries the caller's
@@ -67,11 +67,6 @@ export function treeBoundaryKind(commandLine: string): TreeBoundaryKind {
67
67
  return 'none'
68
68
  }
69
69
 
70
- /** Convenience boolean form of {@link treeBoundaryKind}. */
71
- export function isTreeBoundary(commandLine: string): boolean {
72
- return treeBoundaryKind(commandLine) !== 'none'
73
- }
74
-
75
70
  export interface ProcessRow { pid: number; ppid: number }
76
71
 
77
72
  /**
@@ -285,14 +285,6 @@ export class Supervisor {
285
285
  return 5
286
286
  }
287
287
 
288
- private async getEffectivePollTimeoutMs(): Promise<number> {
289
- try {
290
- const cfg = await readSupervisorConfig()
291
- if (typeof (cfg as any).pollTimeoutMs === 'number' && (cfg as any).pollTimeoutMs > 0) return (cfg as any).pollTimeoutMs
292
- } catch {}
293
- return 20000
294
- }
295
-
296
288
  private async getEffectiveBootGraceMs(): Promise<number> {
297
289
  if (this.deps.bootGraceMs !== undefined) return this.deps.bootGraceMs
298
290
  try {
@@ -10,7 +10,6 @@ import { createHash } from 'node:crypto';
10
10
  import * as os from 'node:os';
11
11
  import * as nodeFs from 'node:fs';
12
12
  import * as nodePath from 'node:path';
13
- import { load } from '../store/index.js';
14
13
 
15
14
  export interface BackupProviderConfig {
16
15
  provider: 'r2' | 'aws';
@@ -128,15 +128,6 @@ export function parseArgs(argv: string[], err: (s: string) => void): CliOpts | n
128
128
  opts.subcommand = rest.shift() as 'check-machines' | 'tunnel-restore' | 'set-peer-host';
129
129
  }
130
130
 
131
- const takeValue = (a: string, i: number, flag: string): string | null => {
132
- const v = rest[i];
133
- if (!v || v.startsWith('-')) {
134
- fail(`${flag} requires a value`);
135
- return null;
136
- }
137
- return v;
138
- };
139
-
140
131
  for (let i = 0; i < rest.length; i++) {
141
132
  const a = rest[i]!;
142
133
  if (a === '--pull' || a === '--push' || a === '--bidirectional') {
@@ -1,7 +1,7 @@
1
1
  import { load } from '../store/index.js';
2
2
  import { validateRemoteTarget } from './validation.js';
3
3
  import { readPeerHost } from './peer-host.js';
4
- import type { RemoteTarget, SyncDirection, SyncRequest } from './sync-types.js';
4
+ import type { SyncDirection, SyncRequest } from './sync-types.js';
5
5
 
6
6
  export interface SyncConfig {
7
7
  remoteHost: string;
@@ -67,14 +67,6 @@ export async function loadSyncConfig(opts: { dshHome?: string } = {}): Promise<S
67
67
  return { remoteHost, remoteDshPath, strategy };
68
68
  }
69
69
 
70
- /**
71
- * Validate and convert a SyncConfig's remote fields into a RemoteTarget.
72
- * Throws if host or dshRoot is not validated absolute.
73
- */
74
- export function configToRemoteTarget(config: SyncConfig): RemoteTarget {
75
- return validateRemoteTarget({ host: config.remoteHost, dshRoot: config.remoteDshPath });
76
- }
77
-
78
70
  /**
79
71
  * Build a validated SyncRequest. Remote is validated via validateRemoteTarget;
80
72
  * localRoot is expected to be an absolute local path (lightly validated as absolute).
@@ -102,18 +94,3 @@ export function buildSyncRequest(params: {
102
94
  remote,
103
95
  };
104
96
  }
105
-
106
- /**
107
- * Helper: resolve effective remote target from config + env + cli overrides,
108
- * but do NOT auto-expand '~'. Caller must handle unresolved '~/.dsh' via
109
- * transport preflight (remoteHome) before building SyncRequest.
110
- */
111
- export function resolveRemoteTargetFromConfig(
112
- config: SyncConfig,
113
- overrides?: { remoteHost?: string; remoteDshPath?: string },
114
- ): { host: string; dshRoot: string; needsPreflight: boolean } {
115
- const host = overrides?.remoteHost ?? config.remoteHost;
116
- const dshRoot = overrides?.remoteDshPath ?? config.remoteDshPath;
117
- const needsPreflight = dshRoot === '~/.dsh' || dshRoot.startsWith('~/');
118
- return { host, dshRoot, needsPreflight };
119
- }
@@ -1,7 +1,5 @@
1
1
  // dsh-maestro-sync — Host index: preview/apply tools + loopback RPC (Task 6).
2
- // Mutation exists only through preview-bound apply(confirm:true); the legacy
3
- // pull/push endpoints and tools are preview-only compatibility aliases.
4
- import * as fs from 'node:fs';
2
+ // Mutation exists only through preview-bound apply(confirm:true).
5
3
  import * as path from 'node:path';
6
4
  import * as os from 'node:os';
7
5
  import { randomBytes } from 'node:crypto';
@@ -308,38 +306,6 @@ export default {
308
306
  ),
309
307
  );
310
308
 
311
- // maestro_sync_pull / maestro_sync_push — preview-only compatibility aliases
312
- ctx.effect(() =>
313
- ctx.tools.register(
314
- textTool(
315
- 'maestro_sync_pull',
316
- 'Deprecated: preview-only pull alias (never writes). Use preview + apply.',
317
- { dryRun: { type: 'boolean', description: 'ignored — always preview-only' } },
318
- async () => {
319
- const svc = await makeService();
320
- const preview = await svc.preview({ direction: 'pull' });
321
- return JSON.stringify({ ok: true, previewId: preview.previewId, revision: preview.revision, summary: preview.summary });
322
- },
323
- ),
324
- ),
325
- );
326
-
327
- ctx.effect(() =>
328
- ctx.tools.register(
329
- textTool(
330
- 'maestro_sync_push',
331
- 'Deprecated: preview-only push alias (never writes). Use preview + apply.',
332
- { dryRun: { type: 'boolean', description: 'ignored — always preview-only' } },
333
- async () => {
334
- const svc = await makeService();
335
- const preview = await svc.preview({ direction: 'push' });
336
- return JSON.stringify({ ok: true, previewId: preview.previewId, revision: preview.revision, summary: preview.summary });
337
- },
338
- ),
339
- ),
340
- );
341
-
342
-
343
309
  // Backup / restore / GC tools (R2 Sync tab; mutation routes are
344
310
  // preview-bound apply(confirm:true) — mirroring the sync tools).
345
311
  ctx.effect(() =>
@@ -404,12 +370,6 @@ export default {
404
370
  const svc = await makeService();
405
371
  try {
406
372
  switch (String(method)) {
407
- case 'pull':
408
- case 'push': {
409
- // preview-only compatibility: no argument (including dryRun) can apply
410
- const preview = await svc.preview({ direction: method === 'push' ? 'push' : 'pull' });
411
- return okCarrier({ previewId: preview.previewId, revision: preview.revision, expiresAt: preview.expiresAt, summary: preview.summary });
412
- }
413
373
  case 'status': {
414
374
  if (args && typeof args.bucket === 'string') {
415
375
  const page = await svc.statusPage({ bucket: args.bucket, cursor: args.cursor, limit: args.limit });
@@ -17,9 +17,6 @@ export function stripId(entry: string): string {
17
17
  return String(entry ?? '').replace(ENTRY_ID_RE, '');
18
18
  }
19
19
 
20
- /** Alias for compatibility. */
21
- export const stripEntryId = stripId;
22
-
23
20
  /**
24
21
  * Extract leading HTML comment header `<!--...-->` if present at start of text.
25
22
  * Returns header (trimmed) and remaining body.
@@ -32,7 +32,6 @@
32
32
  * renames the staged artifact into place (`mv` on the same filesystem).
33
33
  * - Any failure exits non-zero; no partial overwrite ever occurs.
34
34
  */
35
- export const REMOTE_AGENT_NAME = 'maestro-sync-commit';
36
35
  export const REMOTE_AGENT_REL = '.maestro-sync/bin/maestro-sync-commit';
37
36
 
38
37
  export function remoteAgentSource(): string {
@@ -40,7 +40,6 @@ export function collectSnapshots(root: string, fs: any): FileSnapshot[] {
40
40
  }
41
41
 
42
42
  const walk = (dir: string, base: string) => {
43
- let entries: any[] = [];
44
43
  try {
45
44
  if (typeof fsMod.readdirSync !== 'function') return;
46
45
  const raw = fsMod.readdirSync(dir, { withFileTypes: true } as any);
@@ -116,35 +115,6 @@ export function collectSnapshots(root: string, fs: any): FileSnapshot[] {
116
115
  return result;
117
116
  }
118
117
 
119
- /**
120
- * Snapshot a specific list of validated eligible paths under root.
121
- * Useful for hashing staged remote files where we already know the manifest.
122
- */
123
- export function snapshotPaths(root: string, paths: string[], fs: any): FileSnapshot[] {
124
- const fsMod = fs ?? {};
125
- const out: FileSnapshot[] = [];
126
- for (const p of paths) {
127
- let normalized: string;
128
- try {
129
- normalized = normalizeEligiblePath(p);
130
- } catch {
131
- continue;
132
- }
133
- const full = path.join(root, normalized);
134
- try {
135
- if (fsMod.existsSync && !fsMod.existsSync(full)) continue;
136
- if (typeof fsMod.readFileSync !== 'function') continue;
137
- const data = fsMod.readFileSync(full);
138
- const buf = Buffer.isBuffer(data) ? data : Buffer.from(String(data), 'utf-8');
139
- out.push(snapshotFile(normalized, buf));
140
- } catch {
141
- continue;
142
- }
143
- }
144
- out.sort((a, b) => a.path.localeCompare(b.path));
145
- return out;
146
- }
147
-
148
118
  /**
149
119
  * Snapshot from an in-memory map of path -> Buffer (useful for testing staged remote).
150
120
  */
@@ -7,7 +7,6 @@
7
7
  // and is torn down with `-O exit`; a dead master degrades to a fresh handshake.
8
8
  import * as fs from 'node:fs';
9
9
  import * as path from 'node:path';
10
- import { randomBytes } from 'node:crypto';
11
10
  import type { ProcessRunner } from './process-runner.js';
12
11
 
13
12
  export interface SshMux {
@@ -12,7 +12,6 @@
12
12
  * fsync. Push materializes every output below a private operation dir, uploads
13
13
  * to <root>/.maestro-sync/stage/<op>/ and commits through the fixed remote
14
14
  * CAS helper (expectedTargetSha256); a mismatch is CONCURRENT_MODIFICATION.
15
- * - Legacy pull()/push() are preview-only compatibility aliases and never write.
16
15
  */
17
16
  import * as nodeFs from 'node:fs';
18
17
  import * as path from 'node:path';
@@ -20,13 +19,13 @@ import * as os from 'node:os';
20
19
  import { randomBytes } from 'node:crypto';
21
20
  import { mergeDelimited } from './merge.js';
22
21
  import { mergeSessionBuffers } from './session-plan.js';
23
- import { snapshotFile, kindForPath } from './snapshot.js';
22
+ import { kindForPath } from './snapshot.js';
24
23
  import { hashFiles } from './hashing.js';
25
24
  import { loadIndex, saveIndex, probeIndex, matchesStat, statFingerprint } from './fingerprint.js';
26
25
  import type { RemoteManifestEntry } from './remote-manifest.js';
27
26
  import { buildPlan, buildPreview, getPreview, getPreviewDirection, deletePreview, storePreview } from './sync-plan.js';
28
27
  import { normalizeEligiblePath, validateRemoteTarget, validateHost } from './validation.js';
29
- import type { RemoteTarget, SyncDirection, SyncPreview, SyncSummary, SyncFailure, SyncPlan, FileSnapshot, PlannedAction, SyncProgress, SyncScope } from './sync-types.js';
28
+ import type { RemoteTarget, SyncDirection, SyncPreview, SyncSummary, SyncFailure, FileSnapshot, PlannedAction, SyncProgress, SyncScope } from './sync-types.js';
30
29
  import { createProcessRunner, type ProcessRunner } from './process-runner.js';
31
30
  import { createTransport, type SyncTransport } from './transport.js';
32
31
 
@@ -80,20 +79,6 @@ export interface StatusPage {
80
79
  remoteHost: string;
81
80
  }
82
81
 
83
- export interface PullResult {
84
- copied: number;
85
- merged: number;
86
- added: number;
87
- conflicts: number;
88
- }
89
-
90
- export interface PushResult {
91
- copied: number;
92
- merged: number;
93
- added: number;
94
- conflicts: number;
95
- }
96
-
97
82
  export interface PreviewResult extends SyncPreview {
98
83
  connection: ConnectionStatus;
99
84
  remoteHost: string;
@@ -195,7 +180,6 @@ export class SyncService {
195
180
  const result: string[] = [];
196
181
  const fsMod = this.fs;
197
182
  const walk = (dir: string, base: string) => {
198
- let entries: any[] = [];
199
183
  try {
200
184
  if (typeof fsMod.readdirSync !== 'function') return;
201
185
  const raw = fsMod.readdirSync(dir, { withFileTypes: true } as any);
@@ -718,20 +702,6 @@ export class SyncService {
718
702
  }
719
703
  }
720
704
 
721
- // ---- legacy preview-only compatibility (never writes) ----
722
-
723
- /** Deprecated: preview-only alias. `dryRun` is ignored; nothing is ever applied here. */
724
- async pull(_opts: { dryRun?: boolean } = {}): Promise<PullResult> {
725
- const preview = await this.preview({ direction: 'pull' });
726
- return { copied: preview.summary.copied, merged: preview.summary.merged, added: preview.summary.added, conflicts: preview.summary.conflicts };
727
- }
728
-
729
- /** Deprecated: preview-only alias. `dryRun` is ignored; nothing is ever applied here. */
730
- async push(_opts: { dryRun?: boolean } = {}): Promise<PushResult> {
731
- const preview = await this.preview({ direction: 'push' });
732
- return { copied: preview.summary.copied, merged: preview.summary.merged, added: preview.summary.added, conflicts: preview.summary.conflicts };
733
- }
734
-
735
705
  // ---- status ----
736
706
 
737
707
  // Manifest memo for STATUS DISPLAY ONLY (30 s TTL). Preview/apply always
@@ -2,12 +2,12 @@ import { mkdtemp, writeFile, rm } from 'node:fs/promises';
2
2
  import { tmpdir } from 'node:os';
3
3
  import { join } from 'node:path';
4
4
  import type { RemoteTarget, SyncFailure, SyncPhase } from './sync-types.js';
5
- import type { ProcessRunner, ProcessResult } from './process-runner.js';
5
+ import type { ProcessRunner } from './process-runner.js';
6
6
  import { validateRemoteTarget } from './validation.js';
7
7
  import { REMOTE_AGENT_REL, remoteAgentSource, verifyRemoteAgentSource } from './remote-agent.js';
8
8
  import { buildRemoteManifestScript, parseRemoteManifest, type RemoteManifestEntry } from './remote-manifest.js';
9
9
  import { buildWarmCacheScript } from './remote-cache.js';
10
- import { openSshMux, type SshMux } from './ssh-mux.js';
10
+ import type { SshMux } from './ssh-mux.js';
11
11
 
12
12
  export interface SyncTransport {
13
13
  /** Resolve the remote user's $HOME as raw bytes (preflight, never shell ~ expansion). */
@@ -46,11 +46,6 @@ function failure(phase: SyncPhase, code: string, detail: string, path?: string):
46
46
  return { phase, code, detail, path };
47
47
  }
48
48
 
49
- function toFailure(phase: SyncPhase, result: ProcessResult, file: string): SyncFailure {
50
- const detail = result.stderr.toString('utf-8') || `exit ${result.exitCode}`;
51
- return failure(phase, 'TRANSPORT_ERROR', `${file} failed: ${detail}`);
52
- }
53
-
54
49
  export class SshRsyncTransport implements SyncTransport {
55
50
  private mux: SshMux | null = null;
56
51
 
@@ -1,15 +0,0 @@
1
- import { Journal } from './journal.js';
2
- /**
3
- * Retire the legacy ticket store (Task A4). The guard no longer reads tickets —
4
- * the human answers through DSH's native approval service — so the old
5
- * `pending.json` is moved out of its active path into the journal directory,
6
- * where it is kept for reference but never consulted again.
7
- *
8
- * This runs once per boot inside `ctx.effect`; it is idempotent (a missing
9
- * source is a no-op) and never throws, because a failed retirement must not
10
- * stop the guard from booting.
11
- */
12
- export declare function retireLegacyStore(journal: Journal, dshHome?: string): Promise<{
13
- moved: boolean;
14
- to?: string;
15
- }>;
@@ -1,42 +0,0 @@
1
- import { chmod, mkdir, rename, stat } from 'node:fs/promises';
2
- import { join } from 'node:path';
3
- import { journalDir } from './journal.js';
4
- /**
5
- * Retire the legacy ticket store (Task A4). The guard no longer reads tickets —
6
- * the human answers through DSH's native approval service — so the old
7
- * `pending.json` is moved out of its active path into the journal directory,
8
- * where it is kept for reference but never consulted again.
9
- *
10
- * This runs once per boot inside `ctx.effect`; it is idempotent (a missing
11
- * source is a no-op) and never throws, because a failed retirement must not
12
- * stop the guard from booting.
13
- */
14
- export async function retireLegacyStore(journal, dshHome) {
15
- const dir = journalDir(dshHome);
16
- const from = join(dir, 'pending.json');
17
- const to = join(dir, 'legacy-pending.json');
18
- try {
19
- await stat(from);
20
- }
21
- catch {
22
- return { moved: false };
23
- }
24
- try {
25
- await mkdir(dir, { recursive: true, mode: 0o700 });
26
- await rename(from, to);
27
- await chmod(to, 0o600);
28
- await journal.append({
29
- tool: 'guard',
30
- rule: 'guard.migration',
31
- tier: 'journal',
32
- target: to,
33
- outcome: 'passed',
34
- note: 'legacy ticket store retired; retained for reference, no longer read by the guard',
35
- });
36
- return { moved: true, to };
37
- }
38
- catch (e) {
39
- console.error('[dsh-maestro-guard] legacy store retirement failed:', e?.message);
40
- return { moved: false };
41
- }
42
- }
@@ -1,18 +0,0 @@
1
- /**
2
- * Union JSONL lines (or any line-delimited text) by exact line equality.
3
- * Preserves local order then appends remote-only lines.
4
- * Ensures trailing newline when result is non-empty.
5
- */
6
- export declare function mergeZstdLines(localText: string, remoteText: string): {
7
- merged: string;
8
- added: number;
9
- };
10
- /**
11
- * Merge two valid DSH Zstandard session artifacts into the local artifact.
12
- * The original local bytes are copied to a timestamped backup before the
13
- * atomic publish. Invalid, missing, plaintext, or mismatched input never
14
- * replaces the local file.
15
- */
16
- export declare function mergeZstdFiles(localPath: string, remotePath: string): Promise<{
17
- added: number;
18
- }>;