@ddtcorex/dsh-maestro-core 0.11.1 → 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 +13 -3
  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
@@ -29,9 +29,6 @@ export declare const t: {
29
29
  readonly stateWarn: "var(--dsw-alias-state-warn-primary)";
30
30
  readonly shadowLv3: "var(--dsw-shadow-lv3)";
31
31
  };
32
- export declare function MaestroMark(props: {
33
- size?: number;
34
- }): React.JSX.Element;
35
32
  export declare function MaestroLogo(props: {
36
33
  outer?: number;
37
34
  size?: number;
@@ -65,7 +62,6 @@ export declare function Badge(props: {
65
62
  icon?: IconName;
66
63
  }): React.JSX.Element;
67
64
  export declare function formatLastSync(v: string | null): string;
68
- export declare function fileIcon(path: string): IconName;
69
65
  export declare function formatFile(path: string): {
70
66
  icon: IconName;
71
67
  title: string;
@@ -1 +1 @@
1
- {"version":3,"file":"ui.d.ts","sourceRoot":"","sources":["../../../../src/client/sync/ui.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAE9B;;;;;;GAMG;AAEH,eAAO,MAAM,WAAW,EAAG,mBAA4B,CAAA;AAGvD,eAAO,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;CAqBJ,CAAA;AAGV,wBAAgB,WAAW,CAAC,KAAK,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,qBAOnD;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE;IAAE,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,qBA4BpF;AAGD,MAAM,MAAM,QAAQ,GAChB,SAAS,GACT,UAAU,GACV,QAAQ,GACR,MAAM,GACN,MAAM,GACN,QAAQ,GACR,MAAM,GACN,SAAS,GACT,UAAU,GACV,QAAQ,GACR,OAAO,GACP,OAAO,GACP,OAAO,GACP,OAAO,GACP,cAAc,GACd,eAAe,GACf,U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UAAU,CAAC,MAAM,EAAE,GAAG,GAAG,SAAS,GAAG,SAAS,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,CAW1F;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,GAAG,GAAG,MAAM,CAMhD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ddtcorex/dsh-maestro-core",
3
- "version": "0.11.1",
3
+ "version": "0.12.0",
4
4
  "description": "DSH Web supervisor, settings store, tool guard and sync engine",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -12,7 +12,7 @@
12
12
  },
13
13
  "type": "module",
14
14
  "main": "./lib/index.js",
15
- "types": "./lib/types/index.d.ts",
15
+ "types": "./lib/index.d.ts",
16
16
  "exports": {
17
17
  ".": {
18
18
  "types": "./lib/index.d.ts",
@@ -50,6 +50,9 @@
50
50
  "src",
51
51
  "skills",
52
52
  "scripts",
53
+ "!scripts/sync/bench-preview.mjs",
54
+ "!scripts/sync/cdp-sync-probe.mjs",
55
+ "!scripts/sync/cdp-sync-verify.mjs",
53
56
  "systemd",
54
57
  "README.md",
55
58
  "cordis.patch.yml"
@@ -6,9 +6,10 @@ repo="${DSH_REPO:-}"
6
6
  log="${DSH_RESTART_LOG:-/tmp/dsh-web-restart.log}"
7
7
  # Coordination with dsh-web-supervisor (see
8
8
  # <workspace-root>/docs/specs/2026-09-13-supervisor-restart-resilience-design.md): the supervisor treats a
9
- # down poll as a crash unless this marker is fresh, so it never races this
9
+ # down poll as a crash unless this marker is fresh (JSON {ts, ttl}, the format
10
+ # restart-guards.ts parses), so it never races this
10
11
  # script's own kill -> dry-boot -> relaunch sequence with its own rollback.
11
- marker="${DSH_SUPERVISOR_MARKER:-$HOME/.dsh/.supervisor/planned-restart}"
12
+ marker="${DSH_SUPERVISOR_MARKER:-$HOME/.dsh/.supervisor/planned-restart.json}"
12
13
  # Session-log pre-flight env (see lib/session-health.ts): SESSIONS_ROOT is the
13
14
  # operator DSH store's sessions dir (default <dsh home>/sessions) and may be
14
15
  # overridden per invocation. PLUGIN_DIR is this package's root, derived from
@@ -372,7 +373,7 @@ printf '[restart] stopping process tree: %s\n' "$(tr '\n' ' ' <<<"$tree_pids")"
372
373
  mkdir -p "$(dirname "$log")"
373
374
  boot_guard_acquire
374
375
  mkdir -p "$(dirname "$marker")"
375
- date -Iseconds > "$marker"
376
+ printf '{"ts":%s,"ttl":180000}\n' "$(date +%s%3N)" > "$marker"
376
377
  trap 'boot_guard_release; rm -f "$marker"' EXIT
377
378
 
378
379
  # Reload a stale supervisor daemon BEFORE the swap: it is the process that
@@ -487,16 +487,11 @@ export function MaestroSettingsTab({ configRpcCall, supervisorRpcCall }: { confi
487
487
  }
488
488
  // Reset everything the tab owns to the built-in behaviour. Deep-merge cannot
489
489
  // delete keys, so rule overrides are nulled (the runtime drops non-string
490
- // tiers at merge) and legacy booleans are neutralised to their inert values
491
- // (only `false` ever migrated).
490
+ // tiers at merge).
492
491
  const resetGuardDefaults = async () => {
493
492
  const rules: Record<string, GuardTier | null> = {}
494
493
  for (const meta of RULE_META) rules[meta.id] = null
495
494
  await saveGuard({
496
- gitProtection: { enabled: true, branches: ['master', 'main'] },
497
- publishBlocked: true,
498
- cwdContainment: true,
499
- credentialPaths: [],
500
495
  rules,
501
496
  protectedBranches: ['master', 'main'],
502
497
  protectedPaths: [],
@@ -570,8 +565,8 @@ export function MaestroSettingsTab({ configRpcCall, supervisorRpcCall }: { confi
570
565
  { id: 'supervisor', label: 'Supervisor', icon: 'cpu' },
571
566
  ]
572
567
 
573
- // Effective guard state: the stored document may still carry legacy v1 keys,
574
- // so the tab renders through the same precedence the runtime enforces.
568
+ // Effective guard state: the tab renders through the same precedence the
569
+ // runtime enforces.
575
570
  const guardView = effectiveGuardView(guard)
576
571
  const guardCustomCount = guardView.rules.filter((r) => r.source !== 'default').length
577
572
 
@@ -605,7 +600,7 @@ export function MaestroSettingsTab({ configRpcCall, supervisorRpcCall }: { confi
605
600
  ...RULE_META.filter((meta) => meta.group === group).map((meta) => {
606
601
  const current = guardView.rules.find((r) => r.id === meta.id) ?? { ...meta, tier: meta.defaultTier, source: 'default' as const }
607
602
  const stateNote =
608
- current.source === 'stored' ? ' Currently customized.' : current.source === 'legacy' ? ' Currently from an older setting.' : ` Default: ${meta.defaultTier}.`
603
+ current.source === 'stored' ? ' Currently customized.' : ` Default: ${meta.defaultTier}.`
609
604
  return h(SettingRow as any, {
610
605
  title: meta.label,
611
606
  description: `${meta.hint}${stateNote}${meta.locked ? ' Locked: the guard never allows lowering this one.' : ''}`,
@@ -15,8 +15,11 @@
15
15
  * import another's;
16
16
  * - dsh-maestro-remote's copy is a host-side HTML string (the PIN login
17
17
  * badge in `src/host/remote-proxy.ts`), which no client module reaches;
18
- * - dsh-maestro-gateway, -jobs and -sync each carry it in their own client
19
- * bundle for the same reason.
18
+ * - dsh-maestro-gateway and -jobs each carry it in their own client bundle
19
+ * for the same reason.
20
+ *
21
+ * This package's own sync surface shares the single client bundle, so it
22
+ * imports `MaestroMark` from here instead of declaring a second copy.
20
23
  *
21
24
  * Mark: `M2 11 L5 4 L8 9 L11 4 L14 11`, currentColor, strokeWidth 1.6.
22
25
  * Badge: `data-maestro-logo`, outer 28 / size 16 / radius 8, `#0A84FF` tile.
@@ -2,15 +2,13 @@
2
2
  * Guard settings view-model (schema v2).
3
3
  *
4
4
  * The guard runtime (`dsh-maestro-guard/src/host/`) owns the authoritative
5
- * schema (`GuardConfigV2`) and its legacy migration (`mapLegacyConfig`). This
6
- * module mirrors both for DISPLAY ONLY so the Settings tab can render the
7
- * effective state of a stored `domains.guard` document that may still carry
8
- * the v1 keys (`gitProtection` / `publishBlocked` / `cwdContainment` /
9
- * `credentialPaths`).
5
+ * schema (`GuardConfigV2`). This module mirrors it for DISPLAY ONLY so the
6
+ * Settings tab can render the effective state of a stored `domains.guard`
7
+ * document.
10
8
  *
11
9
  * Sync contract: `RULE_META` (ids, groups, default tiers) must match
12
10
  * `RULE_IDS` + `DEFAULT_TIERS` in `dsh-maestro-guard/src/host/rules.ts`, and
13
- * `effectiveGuardView` must match `mapLegacyConfig` + `DEFAULT_CONFIG` in
11
+ * `effectiveGuardView` must match `mergeGuardConfig` + `DEFAULT_CONFIG` in
14
12
  * `dsh-maestro-guard/src/host/config.ts`. `tests/guard-view.spec.ts` pins the
15
13
  * parity against the sibling source; a guard-side rename breaks that test
16
14
  * instead of silently desyncing this tab.
@@ -18,8 +16,6 @@
18
16
 
19
17
  export type GuardTier = 'allow' | 'journal' | 'ask' | 'deny'
20
18
 
21
- export const GUARD_TIERS: readonly GuardTier[] = ['allow', 'journal', 'ask', 'deny']
22
-
23
19
  export function isGuardTier(v: unknown): v is GuardTier {
24
20
  return v === 'allow' || v === 'journal' || v === 'ask' || v === 'deny'
25
21
  }
@@ -56,10 +52,7 @@ export const RULE_META: readonly GuardRuleMeta[] = [
56
52
  { id: 'guard.tamper', group: 'Self-protection', label: 'Edit guard config or journal', hint: 'Any write to the guard settings or its audit trail.', defaultTier: 'deny', locked: true },
57
53
  ]
58
54
 
59
- /** The three git rules the legacy `gitProtection.enabled: false` used to gate. */
60
- const LEGACY_GIT_RULES: readonly string[] = ['git.push.protected', 'git.tag.release', 'git.push.force']
61
-
62
- export type TierSource = 'default' | 'stored' | 'legacy'
55
+ export type TierSource = 'default' | 'stored'
63
56
 
64
57
  export interface GuardRuleView extends GuardRuleMeta {
65
58
  tier: GuardTier
@@ -98,8 +91,8 @@ function isRecord(v: unknown): v is Record<string, unknown> {
98
91
 
99
92
  /**
100
93
  * Compute what the tab shows for a stored `domains.guard` document. Precedence
101
- * mirrors the runtime: an explicit v2 entry wins, a legacy boolean fills the
102
- * gap it used to own, otherwise the built-in default renders.
94
+ * mirrors the runtime: an explicit entry wins, otherwise the built-in default
95
+ * renders.
103
96
  */
104
97
  export function effectiveGuardView(raw: unknown): GuardView {
105
98
  const doc = isRecord(raw) ? raw : {}
@@ -108,23 +101,15 @@ export function effectiveGuardView(raw: unknown): GuardView {
108
101
  const rules: GuardRuleView[] = RULE_META.map((meta) => {
109
102
  const stored = storedRules[meta.id]
110
103
  if (isGuardTier(stored)) return { ...meta, tier: stored, source: 'stored' }
111
- const legacyTier = legacyTierFor(meta.id, doc)
112
- if (legacyTier !== undefined) return { ...meta, tier: legacyTier, source: 'legacy' }
113
104
  return { ...meta, tier: meta.defaultTier, source: 'default' }
114
105
  })
115
106
 
116
107
  const v2Branches = stringArray(doc.protectedBranches)
117
- const legacyBranches = isRecord(doc.gitProtection) ? stringArray(doc.gitProtection.branches) : undefined
118
- const protectedBranches = v2Branches ?? legacyBranches ?? [...DEFAULT_BRANCHES]
108
+ const protectedBranches = v2Branches ?? [...DEFAULT_BRANCHES]
119
109
 
120
- const v2Paths = stringArray(doc.protectedPaths) ?? []
121
- const legacyPaths = stringArray(doc.credentialPaths) ?? []
122
- const protectedPaths = [...new Set([...v2Paths, ...legacyPaths])]
110
+ const protectedPaths = [...new Set(stringArray(doc.protectedPaths) ?? [])]
123
111
 
124
112
  const containmentRaw = isRecord(doc.workingDirContainment) ? doc.workingDirContainment : {}
125
- // Legacy `cwdContainment: false` meant "fs.write.outside journals instead of
126
- // asking"; it never disabled containment, so `enabled` stays true and only
127
- // the rule tier above reflects it.
128
113
  const containment = {
129
114
  enabled: booleanOr(containmentRaw.enabled, true),
130
115
  spillReads: booleanOr(containmentRaw.spillReads, true),
@@ -141,25 +126,13 @@ export function effectiveGuardView(raw: unknown): GuardView {
141
126
  return {
142
127
  rules,
143
128
  protectedBranches,
144
- branchesSource: v2Branches !== undefined ? 'stored' : legacyBranches !== undefined ? 'legacy' : 'default',
129
+ branchesSource: v2Branches !== undefined ? 'stored' : 'default',
145
130
  protectedPaths,
146
131
  containment,
147
132
  journal,
148
133
  }
149
134
  }
150
135
 
151
- /** The tier a legacy v1 document implies for one rule, if any. */
152
- function legacyTierFor(ruleId: string, doc: Record<string, unknown>): GuardTier | undefined {
153
- if (LEGACY_GIT_RULES.includes(ruleId)) {
154
- const gp = doc.gitProtection
155
- if (isRecord(gp) && Object.keys(gp).length > 0 && gp.enabled === false) return 'journal'
156
- return undefined
157
- }
158
- if (ruleId === 'pkg.publish' && doc.publishBlocked === false) return 'journal'
159
- if (ruleId === 'fs.write.outside' && doc.cwdContainment === false) return 'journal'
160
- return undefined
161
- }
162
-
163
136
  /**
164
137
  * Split a comma-separated list field (branches, paths) the way the tab's text
165
138
  * inputs commit it: trim, drop empties, de-duplicate.
@@ -1,4 +1,5 @@
1
1
  import * as React from 'react'
2
+ import { MaestroMark } from '../config/components/BrandMark.js'
2
3
 
3
4
  /**
4
5
  * Sync UI kit — DSH-native primitives, Minimalism & Swiss (design-system/MASTER.md).
@@ -35,15 +36,6 @@ export const t = {
35
36
  } as const
36
37
 
37
38
  // --- Shared Maestro logo (branding rule: same mark/path everywhere) -------------
38
- export function MaestroMark(props: { size?: number }) {
39
- const s = props.size ?? 16
40
- return (
41
- <svg width={s} height={s} viewBox="0 0 16 16" fill="none" aria-hidden="true">
42
- <path d="M2 11 L5 4 L8 9 L11 4 L14 11" stroke="currentColor" strokeWidth={1.6} strokeLinecap="round" strokeLinejoin="round" />
43
- </svg>
44
- )
45
- }
46
-
47
39
  export function MaestroLogo(props: { outer?: number; size?: number; radius?: number }) {
48
40
  const outer = props.outer ?? 28
49
41
  const size = props.size ?? 16
@@ -248,14 +240,6 @@ export function formatLastSync(v: string | null): string {
248
240
  }
249
241
  }
250
242
 
251
- export function fileIcon(path: string): IconName {
252
- if (path.startsWith('dsh-maestro-memory/daily/')) return 'calendar'
253
- if (path.startsWith('dsh-maestro-memory/projects/')) return 'folder'
254
- if (path === 'dsh-maestro-memory/MEMORY.md') return 'star'
255
- if (path.startsWith('sessions/')) return 'message'
256
- return 'file'
257
- }
258
-
259
243
  export function formatFile(path: string): { icon: IconName; title: string; path: string; meta: string } {
260
244
  if (path.startsWith('dsh-maestro-memory/daily/')) {
261
245
  const date = path.replace('dsh-maestro-memory/daily/', '').replace('.md', '')
@@ -7,9 +7,7 @@ import type { Tier } from './tiers.js'
7
7
  * on this object: `classify` produces a rule id, `decide` maps it through
8
8
  * `rules`, and the settings lists feed the classifier's path/branch checks.
9
9
  *
10
- * {@link mapLegacyConfig} carries a document written for schema v1 (the
11
- * `gitProtection` / `publishBlocked` / `cwdContainment` / `credentialPaths`
12
- * booleans) forward; {@link mergeGuardConfig} reads a v2 document.
10
+ * {@link mergeGuardConfig} reads a persisted v2 document.
13
11
  */
14
12
  export interface GuardConfigV2 {
15
13
  rules: Record<string, Tier>
@@ -111,92 +109,6 @@ export function mergeGuardConfig(raw: unknown): GuardConfigV2 {
111
109
  return base
112
110
  }
113
111
 
114
- /**
115
- * The legacy keys schema v2 replaced, and the rules each one used to gate.
116
- * `gitProtection.enabled: false` switched the whole git family off, so all
117
- * three git rules become `journal` (still recorded, never prompted).
118
- */
119
- const LEGACY_GIT_RULES = ['git.push.protected', 'git.tag.release', 'git.push.force'] as const
120
-
121
- /** The four keys schema v2 replaced. They are stripped before the v2 merge. */
122
- const LEGACY_KEYS = new Set(['gitProtection', 'publishBlocked', 'cwdContainment', 'credentialPaths'])
123
-
124
- /**
125
- * Translate a persisted `domains.guard` object that still carries the legacy
126
- * `gitProtection` / `publishBlocked` / `cwdContainment` / `credentialPaths`
127
- * keys onto schema v2.
128
- *
129
- * The legacy translation is applied FIRST and the remaining v2 document is
130
- * merged on top of it: the legacy booleans are the older reading of the
131
- * document, so an explicit v2 `rules` entry must win over the boolean that
132
- * translated onto the same rule id. Nothing is mutated: the arrays, the rule
133
- * table and the nested objects are fresh copies, which matters because
134
- * `DEFAULT_CONFIG` is a module-level object shared by every caller.
135
- *
136
- * `migratedKeys` names the legacy keys that were actually read (a key that is
137
- * absent, or a `gitProtection` that carries no setting at all, is not
138
- * reported; `publishBlocked: true` / `cwdContainment: true` / an empty
139
- * `credentialPaths` changed nothing and stay out). `apply()` journals one
140
- * `config-legacy` note per boot from this list, so an operator can see why the
141
- * gate changed instead of discovering it from a silent behaviour shift.
142
- */
143
- export function mapLegacyConfig(raw: unknown): { config: GuardConfigV2; migratedKeys: string[] } {
144
- if (!isPlainObject(raw)) return { config: mergeGuardConfig(undefined), migratedKeys: [] }
145
- const migratedKeys: string[] = []
146
-
147
- // Stage 1 — translate the legacy keys onto the v2 shape.
148
- const legacyRules: Record<string, Tier> = {}
149
- let legacyBranches: string[] | undefined
150
- let legacyCredentialPaths: string[] | undefined
151
-
152
- const gitProtection = raw.gitProtection
153
- if (isPlainObject(gitProtection) && Object.keys(gitProtection).length > 0) {
154
- migratedKeys.push('gitProtection')
155
- if (gitProtection.enabled === false) {
156
- for (const rule of LEGACY_GIT_RULES) legacyRules[rule] = 'journal'
157
- }
158
- legacyBranches = stringArray(gitProtection.branches)
159
- }
160
-
161
- if (raw.publishBlocked === false) {
162
- migratedKeys.push('publishBlocked')
163
- legacyRules['pkg.publish'] = 'journal'
164
- }
165
-
166
- if (raw.cwdContainment === false) {
167
- migratedKeys.push('cwdContainment')
168
- legacyRules['fs.write.outside'] = 'journal'
169
- }
170
-
171
- const credentialPaths = stringArray(raw.credentialPaths)
172
- if (credentialPaths) {
173
- migratedKeys.push('credentialPaths')
174
- legacyCredentialPaths = credentialPaths
175
- }
176
-
177
- // Stage 2 — the v2 document wins key by key; `rules` merges per rule id so an
178
- // explicit v2 tier beats the legacy boolean that produced the same id.
179
- const v2: Record<string, unknown> = {}
180
- for (const [key, value] of Object.entries(raw)) {
181
- if (!LEGACY_KEYS.has(key)) v2[key] = value
182
- }
183
- const v2Rules = isPlainObject(v2.rules) ? v2.rules : {}
184
- const config = mergeGuardConfig({
185
- ...v2,
186
- rules: { ...legacyRules, ...v2Rules },
187
- protectedBranches: stringArray(v2.protectedBranches) ?? legacyBranches,
188
- })
189
-
190
- // The legacy credential paths are an ADDITION to whatever protected the
191
- // document, never a replacement: narrowing coverage is exactly the failure
192
- // this migration exists to prevent.
193
- if (legacyCredentialPaths) {
194
- config.protectedPaths = [...new Set([...config.protectedPaths, ...legacyCredentialPaths])]
195
- }
196
-
197
- return { config, migratedKeys }
198
- }
199
-
200
112
  /**
201
113
  * Read the raw `domains.guard` value from the shared Maestro settings store. A
202
114
  * missing store, an absent domain or an unreadable file all yield `undefined`:
@@ -221,24 +133,9 @@ async function readGuardDomain(dshHome?: string): Promise<unknown> {
221
133
  }
222
134
 
223
135
  /**
224
- * The migrating read: run the persisted `domains.guard` through
225
- * {@link mapLegacyConfig} and report which legacy keys were translated, so
226
- * `apply()` can journal one `config-legacy` note per boot.
227
- *
228
- * `mapLegacyConfig` is pure and this is the only place a v1 document is
229
- * translated at runtime — before this existed, `loadGuardConfig` called
230
- * `mergeGuardConfig` directly and a persisted v1 document silently lost its
231
- * `credentialPaths` and custom branch list.
232
- */
233
- export async function loadGuardConfigWithMigration(dshHome?: string): Promise<{ config: GuardConfigV2; migratedKeys: string[] }> {
234
- return mapLegacyConfig(await readGuardDomain(dshHome))
235
- }
236
-
237
- /**
238
- * The per-call read the guard handler performs on every tool call: a thin
239
- * wrapper over {@link loadGuardConfigWithMigration} that returns only the
240
- * config. No journaling happens here — that is a once-per-boot concern.
136
+ * The per-call read the guard handler performs on every tool call: the
137
+ * persisted `domains.guard` merged onto the built-in defaults.
241
138
  */
242
139
  export async function loadGuardConfig(dshHome?: string): Promise<GuardConfigV2> {
243
- return (await loadGuardConfigWithMigration(dshHome)).config
140
+ return mergeGuardConfig(await readGuardDomain(dshHome))
244
141
  }
@@ -5,8 +5,7 @@ import { Journal, type AskOutcome } from './journal.js'
5
5
  import { redact } from './redact.js'
6
6
  import { classify } from './rules.js'
7
7
  import { decide, renderReason } from './decide.js'
8
- import { DEFAULT_CONFIG, loadGuardConfig, loadGuardConfigWithMigration, type GuardConfigV2 } from './config.js'
9
- import { retireLegacyStore } from './migrate.js'
8
+ import { DEFAULT_CONFIG, loadGuardConfig, type GuardConfigV2 } from './config.js'
10
9
  import { apply as applyFullScan } from './full-scan-tool.js'
11
10
  import { applyStatusTools } from './status-tool.js'
12
11
  import './validators.js'
@@ -180,59 +179,15 @@ interface NativeApproval {
180
179
  request(req: { agent: unknown; toolName: string; callId?: string; reason: string; signal?: AbortSignal }): Promise<string>
181
180
  }
182
181
 
183
- /**
184
- * Journal an ALREADY-COMPUTED migration result. Split out of
185
- * {@link journalLegacyConfigMigration} so `apply()` can reuse the single
186
- * boot-time config read for both the journal knobs and this note. Never throws.
187
- */
188
- export async function journalConfigMigration(journal: Journal, migratedKeys: string[]): Promise<string[]> {
189
- try {
190
- if (migratedKeys.length === 0) return []
191
- const target = migratedKeys.join(',')
192
- await journal.append({
193
- tool: 'guard',
194
- rule: 'config-legacy',
195
- tier: 'journal',
196
- target,
197
- outcome: 'passed',
198
- note: `legacy domains.guard keys migrated onto schema v2: ${target}`,
199
- })
200
- return migratedKeys
201
- } catch (e) {
202
- console.error('[dsh-maestro-guard] legacy config migration failed:', (e as Error)?.message)
203
- return []
204
- }
205
- }
206
-
207
- /**
208
- * Journal the schema-v1 → v2 config migration ONCE per boot. The handler's
209
- * per-call config read (`loadGuardConfig`) is deliberately mute, so without
210
- * this a persisted `domains.guard` written for schema v1 would change what the
211
- * guard gates without leaving any trace of why.
212
- *
213
- * Exported so the boot effect body is unit-testable. Never throws: a failed
214
- * read or a failed journal write must not stop the guard from booting, and
215
- * `migratedKeys.length === 0` writes nothing at all.
216
- */
217
- export async function journalLegacyConfigMigration(journal: Journal, dshHome?: string): Promise<string[]> {
218
- try {
219
- const { migratedKeys } = await loadGuardConfigWithMigration(dshHome)
220
- return await journalConfigMigration(journal, migratedKeys)
221
- } catch (e) {
222
- console.error('[dsh-maestro-guard] legacy config migration failed:', (e as Error)?.message)
223
- return []
224
- }
225
- }
226
-
227
182
  export default {
228
183
  inject: ['tools'] as const,
229
184
  async apply(ctx: Context) {
230
185
  // `domains.guard.journal` is a BOOT-TIME block: it decides whether the
231
186
  // journal writes at all and which retention defaults `rotate()` uses, so it
232
187
  // is read once here — unlike the per-call rule config, a settings change
233
- // needs a host restart. The same read feeds the one-shot migration note.
234
- const boot = await loadGuardConfigWithMigration().catch(() => ({ config: DEFAULT_CONFIG, migratedKeys: [] as string[] }))
235
- const journal = new Journal(undefined, Date.now, boot.config.journal)
188
+ // needs a host restart.
189
+ const bootConfig = await loadGuardConfig().catch(() => DEFAULT_CONFIG)
190
+ const journal = new Journal(undefined, Date.now, bootConfig.journal)
236
191
  const policy = new PermissionPolicy({ deny: ['danger-tool'] })
237
192
  const requestApproval = async (req: { agent?: unknown; toolName: string; callId?: string; reason: string; signal?: AbortSignal }): Promise<ApprovalResult> => {
238
193
  const approval = ctx.get('approval') as NativeApproval | undefined
@@ -267,10 +222,6 @@ export default {
267
222
  const stop = journal.startDailyRotation()
268
223
  return () => stop()
269
224
  }, 'guard-journal-rotation')
270
- ctx.effect(() => { void retireLegacyStore(journal); return () => {} }, 'guard-retire-legacy-store')
271
- // Journal the v1 -> v2 config migration once per boot, from the boot read
272
- // above; the per-call read stays the cheap `loadGuardConfig`.
273
- ctx.effect(() => { void journalConfigMigration(journal, boot.migratedKeys); return () => {} }, 'guard-journal-legacy-config')
274
225
  // register on-demand full-scan tool (Task 4) alongside guard handler
275
226
  applyFullScan(ctx, {})
276
227
  // Read-only introspection of the journal the handler above writes: the
@@ -164,7 +164,15 @@ export class Journal {
164
164
  const p = journalPath(this.dshHome)
165
165
  await mkdir(dirname(p), { recursive: true, mode: 0o700 })
166
166
  await appendFile(p, line + '\n', { encoding: 'utf8', mode: 0o600 })
167
- await chmod(p, 0o600)
167
+ try {
168
+ await chmod(p, 0o600)
169
+ } catch (e) {
170
+ // Boot-time rotation may rename the live file away after the append
171
+ // above (the entry is already preserved); a file that vanished is the
172
+ // rotation winning the race, not a failure. Anything else rethrows to
173
+ // the failure handler below.
174
+ if ((e as NodeJS.ErrnoException)?.code !== 'ENOENT') throw e
175
+ }
168
176
  } catch (e) {
169
177
  // A journal failure must never change a decision.
170
178
  console.error('[dsh-maestro-guard] journal write failed:', (e as Error)?.message)
@@ -119,17 +119,6 @@ export function pathSpellings(p: string, dshHome?: string): string[] {
119
119
  return [...out]
120
120
  }
121
121
 
122
- /**
123
- * The guard's own paths in every spelling a command may carry — the absolute
124
- * form plus the `~`/`$HOME` forms — derived from {@link guardConfigPaths}, so a
125
- * new guarded file is covered by every spelling at once.
126
- */
127
- export function guardPathSpellings(dshHome?: string): string[] {
128
- const out = new Set<string>()
129
- for (const p of guardConfigPaths(dshHome)) for (const s of pathSpellings(p, dshHome)) out.add(s)
130
- return [...out]
131
- }
132
-
133
122
  /**
134
123
  * True if path points to a blocked credential / secret location.
135
124
  * Covers: the DSH auth file (any expansion), the tunnel auth dir, the registry
@@ -32,11 +32,6 @@ export function getActiveEnterMs(): number | undefined {
32
32
  return undefined
33
33
  }
34
34
 
35
- /** @deprecated kept for callers; identical to getActiveEnterMs(). */
36
- export function getActiveEnterWallMs(): number | undefined {
37
- return getActiveEnterMs()
38
- }
39
-
40
35
  export interface PollHealthOpts {
41
36
  fetch?: () => Promise<{ status: number; text: () => Promise<string> }>
42
37
  psAlive?: () => Promise<boolean>
@@ -1,21 +1,7 @@
1
- import { checkPlannedRestart } from './restart-guards.js'
2
-
3
1
  export interface NotifierOpts {
4
2
  send?: (msg: string) => Promise<void>
5
3
  }
6
4
 
7
- export async function notifyAutoRestart(
8
- reason: string,
9
- opts: NotifierOpts & { httpCode?: string | number; lkgId?: string; reportPath?: string } = {},
10
- ): Promise<void> {
11
- if (checkPlannedRestart()) return
12
- const httpCode = (opts as any).httpCode ?? 'n/a'
13
- const lkgId = (opts as any).lkgId ?? (opts as any).lkg ?? 'n/a'
14
- const reportPath = (opts as any).reportPath ?? (opts as any).report ?? 'n/a'
15
- const msg = `🔄 dsh web auto-restart — ${reason} — ${new Date().toISOString()} — up:${httpCode} — LKG:${lkgId} — report:${reportPath}`
16
- await notify(msg, opts)
17
- }
18
-
19
5
  export async function notify(msg: string, opts: NotifierOpts = {}): Promise<void> {
20
6
  const send = opts.send ?? defaultSend
21
7
  try {
@@ -57,15 +43,3 @@ async function defaultSend(msg: string): Promise<void> {
57
43
  // 3) Fallback — log only, never throw
58
44
  console.log(`[supervisor notify] ${msg}`)
59
45
  }
60
-
61
- export async function notifyCrash(reportPath: string, error: string, opts: NotifierOpts = {}): Promise<void> {
62
- await notify(`CRASH detected → rollback (report: ${reportPath}, error: ${error})`, opts)
63
- }
64
-
65
- export async function notifyDegraded(id: string, error: string, opts: NotifierOpts = {}): Promise<void> {
66
- await notify(`DEGRADED: ${id} failed — ${error}`, opts)
67
- }
68
-
69
- export async function notifyFixed(branch: string, sessions: string[], opts: NotifierOpts = {}): Promise<void> {
70
- await notify(`FIXED: ${branch}, sessions resumed: [${sessions.join(', ')}]`, opts)
71
- }
package/src/host/paths.ts CHANGED
@@ -73,18 +73,14 @@ export function resolveSupervisorPackageDir(): string {
73
73
  /**
74
74
  * Read the shared settings document synchronously from the canonical store
75
75
  * path, `<dsh home>/dsh-maestro-config/settings.json` (`DSH_HOME` wins over
76
- * `~/.dsh`, matching the store). The retired `<dsh home>/maestro/settings.json`
77
- * is consulted only when the canonical file does not exist. Returns `undefined`
78
- * when neither file is present or the chosen one is unreadable.
76
+ * `~/.dsh`, matching the store). Returns `undefined` when the file is absent
77
+ * or unreadable.
79
78
  */
80
79
  export function readSettingsDocSync(): any {
81
80
  const home = process.env.DSH_HOME ?? path.join(os.homedir(), '.dsh')
82
81
  const canonical = path.join(home, 'dsh-maestro-config', 'settings.json')
83
- const legacy = path.join(home, 'maestro', 'settings.json')
84
- const chosen = fs.existsSync(canonical) ? canonical : fs.existsSync(legacy) ? legacy : undefined
85
- if (!chosen) return undefined
86
82
  try {
87
- return JSON.parse(fs.readFileSync(chosen, 'utf-8'))
83
+ return JSON.parse(fs.readFileSync(canonical, 'utf-8'))
88
84
  } catch {
89
85
  return undefined
90
86
  }