@ddtcorex/dsh-maestro-core 0.11.2 → 0.12.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) 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/guard/rules.js +1 -3
  12. package/lib/health-poller.d.ts +0 -2
  13. package/lib/health-poller.js +0 -4
  14. package/lib/notifier.d.ts +0 -8
  15. package/lib/notifier.js +0 -19
  16. package/lib/paths.d.ts +2 -3
  17. package/lib/paths.js +3 -8
  18. package/lib/plugin.d.ts +0 -1
  19. package/lib/plugin.js +37 -29
  20. package/lib/preset.js +1 -1
  21. package/lib/restart-exec.d.ts +0 -1
  22. package/lib/restart-exec.js +0 -1
  23. package/lib/restart-guards.d.ts +1 -1
  24. package/lib/restart-guards.js +3 -33
  25. package/lib/self-kill-guard.d.ts +0 -2
  26. package/lib/self-kill-guard.js +0 -4
  27. package/lib/supervisor.d.ts +0 -1
  28. package/lib/supervisor.js +0 -9
  29. package/lib/sync/cli.js +0 -8
  30. package/lib/sync/config.d.ts +1 -19
  31. package/lib/sync/config.js +0 -18
  32. package/lib/sync/index.js +2 -17
  33. package/lib/sync/merge.d.ts +0 -2
  34. package/lib/sync/merge.js +0 -2
  35. package/lib/sync/remote-agent.d.ts +0 -1
  36. package/lib/sync/remote-agent.js +0 -1
  37. package/lib/sync/snapshot.d.ts +0 -5
  38. package/lib/sync/snapshot.js +0 -33
  39. package/lib/sync/sync-service.d.ts +0 -20
  40. package/lib/sync/sync-service.js +0 -13
  41. package/lib/sync/transport.d.ts +1 -1
  42. package/lib/sync/transport.js +0 -4
  43. package/lib/types/client/config/MaestroSettings.d.ts.map +1 -1
  44. package/lib/types/client/config/components/BrandMark.d.ts +5 -2
  45. package/lib/types/client/config/components/BrandMark.d.ts.map +1 -1
  46. package/lib/types/client/config/guard-view.d.ts +7 -10
  47. package/lib/types/client/config/guard-view.d.ts.map +1 -1
  48. package/lib/types/client/sync/ui.d.ts +0 -4
  49. package/lib/types/client/sync/ui.d.ts.map +1 -1
  50. package/package.json +5 -2
  51. package/skills/dsh-safe-restart/SKILL.md +1 -1
  52. package/skills/dsh-safe-restart/scripts/restart-dsh-web.sh +6 -5
  53. package/src/client/config/MaestroSettings.tsx +4 -9
  54. package/src/client/config/components/BrandMark.tsx +5 -2
  55. package/src/client/config/guard-view.ts +10 -37
  56. package/src/client/sync/ui.tsx +1 -17
  57. package/src/host/guard/config.ts +4 -107
  58. package/src/host/guard/index.ts +4 -53
  59. package/src/host/guard/journal.ts +9 -1
  60. package/src/host/guard/paths.ts +0 -11
  61. package/src/host/guard/rules.ts +1 -3
  62. package/src/host/health-poller.ts +0 -5
  63. package/src/host/notifier.ts +0 -26
  64. package/src/host/paths.ts +3 -7
  65. package/src/host/plugin.ts +34 -28
  66. package/src/host/preset.ts +1 -1
  67. package/src/host/restart-exec.ts +0 -2
  68. package/src/host/restart-guards.ts +3 -27
  69. package/src/host/self-kill-guard.ts +0 -5
  70. package/src/host/supervisor.ts +0 -8
  71. package/src/host/sync/backup-config.ts +0 -1
  72. package/src/host/sync/cli.ts +0 -9
  73. package/src/host/sync/config.ts +1 -24
  74. package/src/host/sync/index.ts +1 -41
  75. package/src/host/sync/merge.ts +0 -3
  76. package/src/host/sync/remote-agent.ts +0 -1
  77. package/src/host/sync/snapshot.ts +0 -30
  78. package/src/host/sync/ssh-mux.ts +0 -1
  79. package/src/host/sync/sync-service.ts +2 -32
  80. package/src/host/sync/transport.ts +2 -7
  81. package/lib/guard/migrate.d.ts +0 -15
  82. package/lib/guard/migrate.js +0 -42
  83. package/lib/sync/session-merge.d.ts +0 -18
  84. package/lib/sync/session-merge.js +0 -191
  85. package/scripts/sync/bench-preview.mjs +0 -43
  86. package/scripts/sync/cdp-sync-probe.mjs +0 -200
  87. package/scripts/sync/cdp-sync-verify.mjs +0 -169
  88. package/src/host/guard/migrate.ts +0 -41
  89. package/src/host/sync/session-merge.ts +0 -220
package/README.md CHANGED
@@ -38,9 +38,14 @@ Host tools registered with `ctx.tools.register`:
38
38
  | `maestro_resume_tool_health` | supervisor | Tool-view health of a resumed session |
39
39
  | `maestro_repair_session_preset` | supervisor | Re-link an agent that joined no preset |
40
40
  | `maestro_guard_status`, `maestro_guard_stats`, `maestro_full_scan` | guard | Guard state, counters and a full rule scan |
41
- | `maestro_sync_status`, `maestro_sync_check_machines`, `maestro_sync_preview`, `maestro_sync_apply`, `maestro_sync_pull`, `maestro_sync_push`, `maestro_sync_bidirectional_preview`, `maestro_sync_bidirectional_apply`, `maestro_sync_tunnel_restore` | sync | Two-machine sync, preview first |
41
+ | `maestro_sync_status`, `maestro_sync_check_machines`, `maestro_sync_preview`, `maestro_sync_apply`, `maestro_sync_bidirectional_preview`, `maestro_sync_bidirectional_apply`, `maestro_sync_tunnel_restore` | sync | Two-machine sync, preview first |
42
42
  | `maestro_backup_preview`, `maestro_backup_apply`, `maestro_backup_gc_preview`, `maestro_backup_gc_apply`, `maestro_restore_preview`, `maestro_restore_apply` | sync | Backup, retention GC and restore, preview first |
43
43
 
44
+ ## Requirements
45
+
46
+ - Node.js `^22.19.0 || >=24.0.0` and pnpm 11+. A shell that defaults to Node 20 fails with `No such built-in module: node:sqlite`; put a Node 22 `bin` first on `PATH` before running `dsh` or `pnpm`.
47
+ - DSH 0.1.x or 0.2.x (peer range `<0.3.0-0`).
48
+
44
49
  ## Install
45
50
 
46
51
  One package, one command:
@@ -49,6 +54,18 @@ One package, one command:
49
54
  dsh plugin --profile web add @ddtcorex/dsh-maestro-core
50
55
  ```
51
56
 
57
+ The package ships its own `cordis.patch.yml`, applied automatically. It includes a
58
+ `connection` entry that declares `webServer`, which DSH 0.2.x needs before
59
+ `rpc.handle` can register a channel. Do not copy it into the profile patch, and do not
60
+ add the rows by hand (duplicate ids crash the loader). Restart `dsh web` after install.
61
+
62
+ To get an exact release instead of whatever the package manager resolves, pin it:
63
+ `dsh plugin --profile web add @ddtcorex/dsh-maestro-core@<version>`.
64
+
65
+ Installed with `link:` from a checkout? After every `git pull`, run `pnpm install && pnpm build`
66
+ (`lib/` is gitignored) and restart `dsh web`.
67
+
68
+
52
69
  In a workspace checkout, build and link instead:
53
70
 
54
71
  ```bash
package/cordis.patch.yml CHANGED
@@ -22,7 +22,7 @@
22
22
  channel: /dsh-maestro-sync
23
23
  # rpc.handle registers a webServer route inside an effect fiber
24
24
  # which carries only the row's inject (not the module's);
25
- # without webServer the row fails on harnesses that provide webServer after rows apply (DSH 0.1.5-rc.1+).
25
+ # not sufficient on DSH 0.2.x on its own: see the `connection` entry at the end of this file.
26
26
  inject: ['tools', 'connection', 'webServer']
27
27
 
28
28
  # Guard rules, journal and approval prompts. The channel is declared by the
@@ -38,16 +38,16 @@
38
38
  name: '@ddtcorex/dsh-maestro-core/lib/config/index.js'
39
39
  # rpc.handle registers a webServer route inside an effect fiber which
40
40
  # carries only the row's inject (not the module's); without webServer
41
- # the row fails on harnesses that provide webServer after rows apply (DSH 0.1.5-rc.1+).
41
+ # the row fails on harnesses that provide webServer after rows apply (DSH 0.1.5-rc.1+); on DSH 0.2.x it is not sufficient on its own, see the `connection` entry at the end of this file.
42
42
  inject: ['connection', 'webServer']
43
43
  config: {}
44
44
 
45
45
  # DSH 0.2.x resolves `webServer` for `ctx.connection.rpc.handle` on the
46
46
  # `connection` row own fiber, so a row-level inject cannot reach it. `inject`
47
- # replaces the base list, hence `webRuntime` (the base row needs it for
47
+ # replaces the base list, hence `webStartup` (the base row needs it for
48
48
  # trustedHosts) is repeated. Identical in every maestro package that registers
49
49
  # RPC channels, so each one stays installable alone.
50
50
  - id: connection
51
51
  inject:
52
- - webRuntime
52
+ - webStartup
53
53
  - webServer
package/lib/client.js CHANGED
@@ -150,7 +150,6 @@ var RULE_META = [
150
150
  { id: "net.exec.remote", group: "Network", label: "Remote execution", hint: "ssh / cloudflared-tunnelled commands.", defaultTier: "ask" },
151
151
  { 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 }
152
152
  ];
153
- var LEGACY_GIT_RULES = ["git.push.protected", "git.tag.release", "git.push.force"];
154
153
  var DEFAULT_BRANCHES = ["master", "main"];
155
154
  function stringArray(v) {
156
155
  if (!Array.isArray(v)) return void 0;
@@ -172,16 +171,11 @@ function effectiveGuardView(raw) {
172
171
  const rules = RULE_META.map((meta) => {
173
172
  const stored = storedRules[meta.id];
174
173
  if (isGuardTier(stored)) return { ...meta, tier: stored, source: "stored" };
175
- const legacyTier = legacyTierFor(meta.id, doc);
176
- if (legacyTier !== void 0) return { ...meta, tier: legacyTier, source: "legacy" };
177
174
  return { ...meta, tier: meta.defaultTier, source: "default" };
178
175
  });
179
176
  const v2Branches = stringArray(doc.protectedBranches);
180
- const legacyBranches = isRecord(doc.gitProtection) ? stringArray(doc.gitProtection.branches) : void 0;
181
- const protectedBranches = v2Branches ?? legacyBranches ?? [...DEFAULT_BRANCHES];
182
- const v2Paths = stringArray(doc.protectedPaths) ?? [];
183
- const legacyPaths = stringArray(doc.credentialPaths) ?? [];
184
- const protectedPaths = [.../* @__PURE__ */ new Set([...v2Paths, ...legacyPaths])];
177
+ const protectedBranches = v2Branches ?? [...DEFAULT_BRANCHES];
178
+ const protectedPaths = [...new Set(stringArray(doc.protectedPaths) ?? [])];
185
179
  const containmentRaw = isRecord(doc.workingDirContainment) ? doc.workingDirContainment : {};
186
180
  const containment = {
187
181
  enabled: booleanOr(containmentRaw.enabled, true),
@@ -197,22 +191,12 @@ function effectiveGuardView(raw) {
197
191
  return {
198
192
  rules,
199
193
  protectedBranches,
200
- branchesSource: v2Branches !== void 0 ? "stored" : legacyBranches !== void 0 ? "legacy" : "default",
194
+ branchesSource: v2Branches !== void 0 ? "stored" : "default",
201
195
  protectedPaths,
202
196
  containment,
203
197
  journal
204
198
  };
205
199
  }
206
- function legacyTierFor(ruleId, doc) {
207
- if (LEGACY_GIT_RULES.includes(ruleId)) {
208
- const gp = doc.gitProtection;
209
- if (isRecord(gp) && Object.keys(gp).length > 0 && gp.enabled === false) return "journal";
210
- return void 0;
211
- }
212
- if (ruleId === "pkg.publish" && doc.publishBlocked === false) return "journal";
213
- if (ruleId === "fs.write.outside" && doc.cwdContainment === false) return "journal";
214
- return void 0;
215
- }
216
200
  function ruleTierPatch(ruleId, tier) {
217
201
  return { [ruleId]: tier === "default" ? null : tier };
218
202
  }
@@ -689,10 +673,6 @@ function MaestroSettingsTab({ configRpcCall, supervisorRpcCall }) {
689
673
  const rules = {};
690
674
  for (const meta of RULE_META) rules[meta.id] = null;
691
675
  await saveGuard({
692
- gitProtection: { enabled: true, branches: ["master", "main"] },
693
- publishBlocked: true,
694
- cwdContainment: true,
695
- credentialPaths: [],
696
676
  rules,
697
677
  protectedBranches: ["master", "main"],
698
678
  protectedPaths: [],
@@ -771,7 +751,7 @@ function MaestroSettingsTab({ configRpcCall, supervisorRpcCall }) {
771
751
  (0, import_react2.createElement)("div", { style: { fontSize: 13, fontWeight: 600, color: t.labelPrimary, padding: "12px 0 4px" } }, group),
772
752
  ...RULE_META.filter((meta) => meta.group === group).map((meta) => {
773
753
  const current = guardView.rules.find((r) => r.id === meta.id) ?? { ...meta, tier: meta.defaultTier, source: "default" };
774
- const stateNote = current.source === "stored" ? " Currently customized." : current.source === "legacy" ? " Currently from an older setting." : ` Default: ${meta.defaultTier}.`;
754
+ const stateNote = current.source === "stored" ? " Currently customized." : ` Default: ${meta.defaultTier}.`;
775
755
  return (0, import_react2.createElement)(SettingRow, {
776
756
  title: meta.label,
777
757
  description: `${meta.hint}${stateNote}${meta.locked ? " Locked: the guard never allows lowering this one." : ""}`,
@@ -1105,10 +1085,6 @@ var t2 = {
1105
1085
  stateWarn: "var(--dsw-alias-state-warn-primary)",
1106
1086
  shadowLv3: "var(--dsw-shadow-lv3)"
1107
1087
  };
1108
- function MaestroMark2(props) {
1109
- const s = props.size ?? 16;
1110
- return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("svg", { width: s, height: s, viewBox: "0 0 16 16", fill: "none", "aria-hidden": "true", children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("path", { d: "M2 11 L5 4 L8 9 L11 4 L14 11", stroke: "currentColor", strokeWidth: 1.6, strokeLinecap: "round", strokeLinejoin: "round" }) });
1111
- }
1112
1088
  function MaestroLogo(props) {
1113
1089
  const outer = props.outer ?? 28;
1114
1090
  const size = props.size ?? 16;
@@ -1134,7 +1110,7 @@ function MaestroLogo(props) {
1134
1110
  alignSelf: "flex-start",
1135
1111
  marginTop: 2
1136
1112
  },
1137
- children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MaestroMark2, { size })
1113
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MaestroMark, { size })
1138
1114
  }
1139
1115
  );
1140
1116
  }
@@ -4,9 +4,7 @@ import type { Tier } from './tiers.js';
4
4
  * on this object: `classify` produces a rule id, `decide` maps it through
5
5
  * `rules`, and the settings lists feed the classifier's path/branch checks.
6
6
  *
7
- * {@link mapLegacyConfig} carries a document written for schema v1 (the
8
- * `gitProtection` / `publishBlocked` / `cwdContainment` / `credentialPaths`
9
- * booleans) forward; {@link mergeGuardConfig} reads a v2 document.
7
+ * {@link mergeGuardConfig} reads a persisted v2 document.
10
8
  */
11
9
  export interface GuardConfigV2 {
12
10
  rules: Record<string, Tier>;
@@ -38,45 +36,7 @@ export declare const DEFAULT_CONFIG: GuardConfigV2;
38
36
  */
39
37
  export declare function mergeGuardConfig(raw: unknown): GuardConfigV2;
40
38
  /**
41
- * Translate a persisted `domains.guard` object that still carries the legacy
42
- * `gitProtection` / `publishBlocked` / `cwdContainment` / `credentialPaths`
43
- * keys onto schema v2.
44
- *
45
- * The legacy translation is applied FIRST and the remaining v2 document is
46
- * merged on top of it: the legacy booleans are the older reading of the
47
- * document, so an explicit v2 `rules` entry must win over the boolean that
48
- * translated onto the same rule id. Nothing is mutated: the arrays, the rule
49
- * table and the nested objects are fresh copies, which matters because
50
- * `DEFAULT_CONFIG` is a module-level object shared by every caller.
51
- *
52
- * `migratedKeys` names the legacy keys that were actually read (a key that is
53
- * absent, or a `gitProtection` that carries no setting at all, is not
54
- * reported; `publishBlocked: true` / `cwdContainment: true` / an empty
55
- * `credentialPaths` changed nothing and stay out). `apply()` journals one
56
- * `config-legacy` note per boot from this list, so an operator can see why the
57
- * gate changed instead of discovering it from a silent behaviour shift.
58
- */
59
- export declare function mapLegacyConfig(raw: unknown): {
60
- config: GuardConfigV2;
61
- migratedKeys: string[];
62
- };
63
- /**
64
- * The migrating read: run the persisted `domains.guard` through
65
- * {@link mapLegacyConfig} and report which legacy keys were translated, so
66
- * `apply()` can journal one `config-legacy` note per boot.
67
- *
68
- * `mapLegacyConfig` is pure and this is the only place a v1 document is
69
- * translated at runtime — before this existed, `loadGuardConfig` called
70
- * `mergeGuardConfig` directly and a persisted v1 document silently lost its
71
- * `credentialPaths` and custom branch list.
72
- */
73
- export declare function loadGuardConfigWithMigration(dshHome?: string): Promise<{
74
- config: GuardConfigV2;
75
- migratedKeys: string[];
76
- }>;
77
- /**
78
- * The per-call read the guard handler performs on every tool call: a thin
79
- * wrapper over {@link loadGuardConfigWithMigration} that returns only the
80
- * config. No journaling happens here — that is a once-per-boot concern.
39
+ * The per-call read the guard handler performs on every tool call: the
40
+ * persisted `domains.guard` merged onto the built-in defaults.
81
41
  */
82
42
  export declare function loadGuardConfig(dshHome?: string): Promise<GuardConfigV2>;
@@ -87,84 +87,6 @@ export function mergeGuardConfig(raw) {
87
87
  }
88
88
  return base;
89
89
  }
90
- /**
91
- * The legacy keys schema v2 replaced, and the rules each one used to gate.
92
- * `gitProtection.enabled: false` switched the whole git family off, so all
93
- * three git rules become `journal` (still recorded, never prompted).
94
- */
95
- const LEGACY_GIT_RULES = ['git.push.protected', 'git.tag.release', 'git.push.force'];
96
- /** The four keys schema v2 replaced. They are stripped before the v2 merge. */
97
- const LEGACY_KEYS = new Set(['gitProtection', 'publishBlocked', 'cwdContainment', 'credentialPaths']);
98
- /**
99
- * Translate a persisted `domains.guard` object that still carries the legacy
100
- * `gitProtection` / `publishBlocked` / `cwdContainment` / `credentialPaths`
101
- * keys onto schema v2.
102
- *
103
- * The legacy translation is applied FIRST and the remaining v2 document is
104
- * merged on top of it: the legacy booleans are the older reading of the
105
- * document, so an explicit v2 `rules` entry must win over the boolean that
106
- * translated onto the same rule id. Nothing is mutated: the arrays, the rule
107
- * table and the nested objects are fresh copies, which matters because
108
- * `DEFAULT_CONFIG` is a module-level object shared by every caller.
109
- *
110
- * `migratedKeys` names the legacy keys that were actually read (a key that is
111
- * absent, or a `gitProtection` that carries no setting at all, is not
112
- * reported; `publishBlocked: true` / `cwdContainment: true` / an empty
113
- * `credentialPaths` changed nothing and stay out). `apply()` journals one
114
- * `config-legacy` note per boot from this list, so an operator can see why the
115
- * gate changed instead of discovering it from a silent behaviour shift.
116
- */
117
- export function mapLegacyConfig(raw) {
118
- if (!isPlainObject(raw))
119
- return { config: mergeGuardConfig(undefined), migratedKeys: [] };
120
- const migratedKeys = [];
121
- // Stage 1 — translate the legacy keys onto the v2 shape.
122
- const legacyRules = {};
123
- let legacyBranches;
124
- let legacyCredentialPaths;
125
- const gitProtection = raw.gitProtection;
126
- if (isPlainObject(gitProtection) && Object.keys(gitProtection).length > 0) {
127
- migratedKeys.push('gitProtection');
128
- if (gitProtection.enabled === false) {
129
- for (const rule of LEGACY_GIT_RULES)
130
- legacyRules[rule] = 'journal';
131
- }
132
- legacyBranches = stringArray(gitProtection.branches);
133
- }
134
- if (raw.publishBlocked === false) {
135
- migratedKeys.push('publishBlocked');
136
- legacyRules['pkg.publish'] = 'journal';
137
- }
138
- if (raw.cwdContainment === false) {
139
- migratedKeys.push('cwdContainment');
140
- legacyRules['fs.write.outside'] = 'journal';
141
- }
142
- const credentialPaths = stringArray(raw.credentialPaths);
143
- if (credentialPaths) {
144
- migratedKeys.push('credentialPaths');
145
- legacyCredentialPaths = credentialPaths;
146
- }
147
- // Stage 2 — the v2 document wins key by key; `rules` merges per rule id so an
148
- // explicit v2 tier beats the legacy boolean that produced the same id.
149
- const v2 = {};
150
- for (const [key, value] of Object.entries(raw)) {
151
- if (!LEGACY_KEYS.has(key))
152
- v2[key] = value;
153
- }
154
- const v2Rules = isPlainObject(v2.rules) ? v2.rules : {};
155
- const config = mergeGuardConfig({
156
- ...v2,
157
- rules: { ...legacyRules, ...v2Rules },
158
- protectedBranches: stringArray(v2.protectedBranches) ?? legacyBranches,
159
- });
160
- // The legacy credential paths are an ADDITION to whatever protected the
161
- // document, never a replacement: narrowing coverage is exactly the failure
162
- // this migration exists to prevent.
163
- if (legacyCredentialPaths) {
164
- config.protectedPaths = [...new Set([...config.protectedPaths, ...legacyCredentialPaths])];
165
- }
166
- return { config, migratedKeys };
167
- }
168
90
  /**
169
91
  * Read the raw `domains.guard` value from the shared Maestro settings store. A
170
92
  * missing store, an absent domain or an unreadable file all yield `undefined`:
@@ -189,23 +111,9 @@ async function readGuardDomain(dshHome) {
189
111
  return undefined;
190
112
  }
191
113
  /**
192
- * The migrating read: run the persisted `domains.guard` through
193
- * {@link mapLegacyConfig} and report which legacy keys were translated, so
194
- * `apply()` can journal one `config-legacy` note per boot.
195
- *
196
- * `mapLegacyConfig` is pure and this is the only place a v1 document is
197
- * translated at runtime — before this existed, `loadGuardConfig` called
198
- * `mergeGuardConfig` directly and a persisted v1 document silently lost its
199
- * `credentialPaths` and custom branch list.
200
- */
201
- export async function loadGuardConfigWithMigration(dshHome) {
202
- return mapLegacyConfig(await readGuardDomain(dshHome));
203
- }
204
- /**
205
- * The per-call read the guard handler performs on every tool call: a thin
206
- * wrapper over {@link loadGuardConfigWithMigration} that returns only the
207
- * config. No journaling happens here — that is a once-per-boot concern.
114
+ * The per-call read the guard handler performs on every tool call: the
115
+ * persisted `domains.guard` merged onto the built-in defaults.
208
116
  */
209
117
  export async function loadGuardConfig(dshHome) {
210
- return (await loadGuardConfigWithMigration(dshHome)).config;
118
+ return mergeGuardConfig(await readGuardDomain(dshHome));
211
119
  }
@@ -61,23 +61,6 @@ export declare function createGuardHandler(deps: GuardDeps): (exec: GuardToolExe
61
61
  * the false positives the repo resolution exists to remove.
62
62
  */
63
63
  export declare function branchOf(dir: string): string | undefined;
64
- /**
65
- * Journal an ALREADY-COMPUTED migration result. Split out of
66
- * {@link journalLegacyConfigMigration} so `apply()` can reuse the single
67
- * boot-time config read for both the journal knobs and this note. Never throws.
68
- */
69
- export declare function journalConfigMigration(journal: Journal, migratedKeys: string[]): Promise<string[]>;
70
- /**
71
- * Journal the schema-v1 → v2 config migration ONCE per boot. The handler's
72
- * per-call config read (`loadGuardConfig`) is deliberately mute, so without
73
- * this a persisted `domains.guard` written for schema v1 would change what the
74
- * guard gates without leaving any trace of why.
75
- *
76
- * Exported so the boot effect body is unit-testable. Never throws: a failed
77
- * read or a failed journal write must not stop the guard from booting, and
78
- * `migratedKeys.length === 0` writes nothing at all.
79
- */
80
- export declare function journalLegacyConfigMigration(journal: Journal, dshHome?: string): Promise<string[]>;
81
64
  declare const _default: {
82
65
  inject: readonly ["tools"];
83
66
  apply(ctx: Context): Promise<void>;
@@ -4,8 +4,7 @@ import { Journal } from './journal.js';
4
4
  import { redact } from './redact.js';
5
5
  import { classify } from './rules.js';
6
6
  import { decide, renderReason } from './decide.js';
7
- import { DEFAULT_CONFIG, loadGuardConfig, loadGuardConfigWithMigration } from './config.js';
8
- import { retireLegacyStore } from './migrate.js';
7
+ import { DEFAULT_CONFIG, loadGuardConfig } from './config.js';
9
8
  import { apply as applyFullScan } from './full-scan-tool.js';
10
9
  import { applyStatusTools } from './status-tool.js';
11
10
  import './validators.js';
@@ -150,60 +149,15 @@ export function branchOf(dir) {
150
149
  return undefined;
151
150
  }
152
151
  }
153
- /**
154
- * Journal an ALREADY-COMPUTED migration result. Split out of
155
- * {@link journalLegacyConfigMigration} so `apply()` can reuse the single
156
- * boot-time config read for both the journal knobs and this note. Never throws.
157
- */
158
- export async function journalConfigMigration(journal, migratedKeys) {
159
- try {
160
- if (migratedKeys.length === 0)
161
- return [];
162
- const target = migratedKeys.join(',');
163
- await journal.append({
164
- tool: 'guard',
165
- rule: 'config-legacy',
166
- tier: 'journal',
167
- target,
168
- outcome: 'passed',
169
- note: `legacy domains.guard keys migrated onto schema v2: ${target}`,
170
- });
171
- return migratedKeys;
172
- }
173
- catch (e) {
174
- console.error('[dsh-maestro-guard] legacy config migration failed:', e?.message);
175
- return [];
176
- }
177
- }
178
- /**
179
- * Journal the schema-v1 → v2 config migration ONCE per boot. The handler's
180
- * per-call config read (`loadGuardConfig`) is deliberately mute, so without
181
- * this a persisted `domains.guard` written for schema v1 would change what the
182
- * guard gates without leaving any trace of why.
183
- *
184
- * Exported so the boot effect body is unit-testable. Never throws: a failed
185
- * read or a failed journal write must not stop the guard from booting, and
186
- * `migratedKeys.length === 0` writes nothing at all.
187
- */
188
- export async function journalLegacyConfigMigration(journal, dshHome) {
189
- try {
190
- const { migratedKeys } = await loadGuardConfigWithMigration(dshHome);
191
- return await journalConfigMigration(journal, migratedKeys);
192
- }
193
- catch (e) {
194
- console.error('[dsh-maestro-guard] legacy config migration failed:', e?.message);
195
- return [];
196
- }
197
- }
198
152
  export default {
199
153
  inject: ['tools'],
200
154
  async apply(ctx) {
201
155
  // `domains.guard.journal` is a BOOT-TIME block: it decides whether the
202
156
  // journal writes at all and which retention defaults `rotate()` uses, so it
203
157
  // is read once here — unlike the per-call rule config, a settings change
204
- // needs a host restart. The same read feeds the one-shot migration note.
205
- const boot = await loadGuardConfigWithMigration().catch(() => ({ config: DEFAULT_CONFIG, migratedKeys: [] }));
206
- const journal = new Journal(undefined, Date.now, boot.config.journal);
158
+ // needs a host restart.
159
+ const bootConfig = await loadGuardConfig().catch(() => DEFAULT_CONFIG);
160
+ const journal = new Journal(undefined, Date.now, bootConfig.journal);
207
161
  const policy = new PermissionPolicy({ deny: ['danger-tool'] });
208
162
  const requestApproval = async (req) => {
209
163
  const approval = ctx.get('approval');
@@ -240,10 +194,6 @@ export default {
240
194
  const stop = journal.startDailyRotation();
241
195
  return () => stop();
242
196
  }, 'guard-journal-rotation');
243
- ctx.effect(() => { void retireLegacyStore(journal); return () => { }; }, 'guard-retire-legacy-store');
244
- // Journal the v1 -> v2 config migration once per boot, from the boot read
245
- // above; the per-call read stays the cheap `loadGuardConfig`.
246
- ctx.effect(() => { void journalConfigMigration(journal, boot.migratedKeys); return () => { }; }, 'guard-journal-legacy-config');
247
197
  // register on-demand full-scan tool (Task 4) alongside guard handler
248
198
  applyFullScan(ctx, {});
249
199
  // Read-only introspection of the journal the handler above writes: the
@@ -108,7 +108,17 @@ export class Journal {
108
108
  const p = journalPath(this.dshHome);
109
109
  await mkdir(dirname(p), { recursive: true, mode: 0o700 });
110
110
  await appendFile(p, line + '\n', { encoding: 'utf8', mode: 0o600 });
111
- await chmod(p, 0o600);
111
+ try {
112
+ await chmod(p, 0o600);
113
+ }
114
+ catch (e) {
115
+ // Boot-time rotation may rename the live file away after the append
116
+ // above (the entry is already preserved); a file that vanished is the
117
+ // rotation winning the race, not a failure. Anything else rethrows to
118
+ // the failure handler below.
119
+ if (e?.code !== 'ENOENT')
120
+ throw e;
121
+ }
112
122
  }
113
123
  catch (e) {
114
124
  // A journal failure must never change a decision.
@@ -48,12 +48,6 @@ export declare function guardConfigPaths(dshHome?: string): string[];
48
48
  * command that reached the guard config through `~`/`$HOME` walked past it.
49
49
  */
50
50
  export declare function pathSpellings(p: string, dshHome?: string): string[];
51
- /**
52
- * The guard's own paths in every spelling a command may carry — the absolute
53
- * form plus the `~`/`$HOME` forms — derived from {@link guardConfigPaths}, so a
54
- * new guarded file is covered by every spelling at once.
55
- */
56
- export declare function guardPathSpellings(dshHome?: string): string[];
57
51
  /**
58
52
  * True if path points to a blocked credential / secret location.
59
53
  * Covers: the DSH auth file (any expansion), the tunnel auth dir, the registry
@@ -119,18 +119,6 @@ export function pathSpellings(p, dshHome) {
119
119
  }
120
120
  return [...out];
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) {
128
- const out = new Set();
129
- for (const p of guardConfigPaths(dshHome))
130
- for (const s of pathSpellings(p, dshHome))
131
- out.add(s);
132
- return [...out];
133
- }
134
122
  /**
135
123
  * True if path points to a blocked credential / secret location.
136
124
  * Covers: the DSH auth file (any expansion), the tunnel auth dir, the registry
@@ -37,14 +37,12 @@ const FILE_TOOLS = new Set([
37
37
  'read',
38
38
  'write',
39
39
  'edit',
40
- 'maestro_read_file',
41
- 'maestro_write_file',
42
40
  'fs_read',
43
41
  'fs_write',
44
42
  'read_file',
45
43
  'write_file',
46
44
  ]);
47
- const WRITE_FILE_TOOLS = new Set(['write', 'edit', 'maestro_write_file', 'fs_write', 'write_file']);
45
+ const WRITE_FILE_TOOLS = new Set(['write', 'edit', 'fs_write', 'write_file']);
48
46
  /** Verbs that actually touch file contents — a protected path next to one is an access. */
49
47
  const ACCESS_VERBS = /\b(cat|bat|head|tail|less|more|cp|scp|rsync|curl|wget|source|tee|dd|install|xxd|base64|openssl|gpg|tar|zip)\b/;
50
48
  /**
@@ -14,8 +14,6 @@ export interface HealthState {
14
14
  * cannot be compared with a timestamp-less append-only log.
15
15
  */
16
16
  export declare function getActiveEnterMs(): number | undefined;
17
- /** @deprecated kept for callers; identical to getActiveEnterMs(). */
18
- export declare function getActiveEnterWallMs(): number | undefined;
19
17
  export interface PollHealthOpts {
20
18
  fetch?: () => Promise<{
21
19
  status: number;
@@ -24,10 +24,6 @@ export function getActiveEnterMs() {
24
24
  catch { }
25
25
  return undefined;
26
26
  }
27
- /** @deprecated kept for callers; identical to getActiveEnterMs(). */
28
- export function getActiveEnterWallMs() {
29
- return getActiveEnterMs();
30
- }
31
27
  // Specific parse/boot-failure markers only. Bare 'JSON'/'YAML' were removed
32
28
  // (2026-08-31): they matched any line whose payload merely *contained* those
33
29
  // substrings — e.g. maestro-sync's status JSON listing session.jsonl.zstd /
package/lib/notifier.d.ts CHANGED
@@ -1,12 +1,4 @@
1
1
  export interface NotifierOpts {
2
2
  send?: (msg: string) => Promise<void>;
3
3
  }
4
- export declare function notifyAutoRestart(reason: string, opts?: NotifierOpts & {
5
- httpCode?: string | number;
6
- lkgId?: string;
7
- reportPath?: string;
8
- }): Promise<void>;
9
4
  export declare function notify(msg: string, opts?: NotifierOpts): Promise<void>;
10
- export declare function notifyCrash(reportPath: string, error: string, opts?: NotifierOpts): Promise<void>;
11
- export declare function notifyDegraded(id: string, error: string, opts?: NotifierOpts): Promise<void>;
12
- export declare function notifyFixed(branch: string, sessions: string[], opts?: NotifierOpts): Promise<void>;
package/lib/notifier.js CHANGED
@@ -1,13 +1,3 @@
1
- import { checkPlannedRestart } from './restart-guards.js';
2
- export async function notifyAutoRestart(reason, opts = {}) {
3
- if (checkPlannedRestart())
4
- return;
5
- const httpCode = opts.httpCode ?? 'n/a';
6
- const lkgId = opts.lkgId ?? opts.lkg ?? 'n/a';
7
- const reportPath = opts.reportPath ?? opts.report ?? 'n/a';
8
- const msg = `🔄 dsh web auto-restart — ${reason} — ${new Date().toISOString()} — up:${httpCode} — LKG:${lkgId} — report:${reportPath}`;
9
- await notify(msg, opts);
10
- }
11
1
  export async function notify(msg, opts = {}) {
12
2
  const send = opts.send ?? defaultSend;
13
3
  try {
@@ -51,12 +41,3 @@ async function defaultSend(msg) {
51
41
  // 3) Fallback — log only, never throw
52
42
  console.log(`[supervisor notify] ${msg}`);
53
43
  }
54
- export async function notifyCrash(reportPath, error, opts = {}) {
55
- await notify(`CRASH detected → rollback (report: ${reportPath}, error: ${error})`, opts);
56
- }
57
- export async function notifyDegraded(id, error, opts = {}) {
58
- await notify(`DEGRADED: ${id} failed — ${error}`, opts);
59
- }
60
- export async function notifyFixed(branch, sessions, opts = {}) {
61
- await notify(`FIXED: ${branch}, sessions resumed: [${sessions.join(', ')}]`, opts);
62
- }
package/lib/paths.d.ts CHANGED
@@ -14,8 +14,7 @@ export declare function resolveSupervisorPackageDir(): string;
14
14
  /**
15
15
  * Read the shared settings document synchronously from the canonical store
16
16
  * path, `<dsh home>/dsh-maestro-config/settings.json` (`DSH_HOME` wins over
17
- * `~/.dsh`, matching the store). The retired `<dsh home>/maestro/settings.json`
18
- * is consulted only when the canonical file does not exist. Returns `undefined`
19
- * when neither file is present or the chosen one is unreadable.
17
+ * `~/.dsh`, matching the store). Returns `undefined` when the file is absent
18
+ * or unreadable.
20
19
  */
21
20
  export declare function readSettingsDocSync(): any;
package/lib/paths.js CHANGED
@@ -72,19 +72,14 @@ export function resolveSupervisorPackageDir() {
72
72
  /**
73
73
  * Read the shared settings document synchronously from the canonical store
74
74
  * path, `<dsh home>/dsh-maestro-config/settings.json` (`DSH_HOME` wins over
75
- * `~/.dsh`, matching the store). The retired `<dsh home>/maestro/settings.json`
76
- * is consulted only when the canonical file does not exist. Returns `undefined`
77
- * when neither file is present or the chosen one is unreadable.
75
+ * `~/.dsh`, matching the store). Returns `undefined` when the file is absent
76
+ * or unreadable.
78
77
  */
79
78
  export function readSettingsDocSync() {
80
79
  const home = process.env.DSH_HOME ?? path.join(os.homedir(), '.dsh');
81
80
  const canonical = path.join(home, 'dsh-maestro-config', 'settings.json');
82
- const legacy = path.join(home, 'maestro', 'settings.json');
83
- const chosen = fs.existsSync(canonical) ? canonical : fs.existsSync(legacy) ? legacy : undefined;
84
- if (!chosen)
85
- return undefined;
86
81
  try {
87
- return JSON.parse(fs.readFileSync(chosen, 'utf-8'));
82
+ return JSON.parse(fs.readFileSync(canonical, 'utf-8'));
88
83
  }
89
84
  catch {
90
85
  return undefined;
package/lib/plugin.d.ts CHANGED
@@ -56,7 +56,6 @@ export type ResumeCoreToolPolicy = 'warn' | 'park';
56
56
  * an interactive toggle that has no effect.
57
57
  */
58
58
  export declare function isAutoResumePinned(config?: SupervisorPluginConfig): boolean;
59
- export declare function getAutoResumeEnabledExported(config?: SupervisorPluginConfig): boolean;
60
59
  export declare function processStartedAtMs(): number | undefined;
61
60
  export declare function runAutoResume(ctx: any, opts?: {
62
61
  findInterrupted?: typeof defaultFindInterrupted;