instar 1.3.40 → 1.3.42

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.
@@ -384,6 +384,33 @@ export declare class PostUpdateMigrator {
384
384
  * Idempotent: subsequent runs find no legacy key and skip.
385
385
  */
386
386
  private migrateLegacyMaxSessions;
387
+ /**
388
+ * Retire `mentor.dailySpendCapUsd` — a config field that was DECORATIVE (read nowhere
389
+ * in code; spec MENTOR-LIVE-READINESS §Migration parity called it out as the
390
+ * silent-dead-config bug we shouldn't repeat at migration time). On a Claude
391
+ * subscription there's no per-token dollar charge to cap; the real budget is quota-
392
+ * aware (a separate future PR ships `mentor.stageBTokenCeiling`).
393
+ *
394
+ * Behavior:
395
+ * - field absent → silent skip
396
+ * - field present at the default (0.5) → silent delete (no warning)
397
+ * - field present at a NON-default value → delete + LOUD `result.upgraded` entry with
398
+ * a REVIEW prefix (operator never set this thinking it was enforced; they deserve
399
+ * to know). Don't repeat the original silent-dead-config bug at migration time.
400
+ * Idempotent via the `_instar_migrations` marker.
401
+ */
402
+ private migrateRetireDeadMentorConfig;
403
+ /**
404
+ * Retire the legacy `{stateDir}/mentor-outbox/` directory — the file-based mentor
405
+ * delivery design that Justin's substrate correction replaced (spec MENTOR-LIVE-
406
+ * READINESS §Migration parity). The new mentor delivery goes through the agent-to-
407
+ * agent Telegram comms primitive (sendAgentMessage); the outbox files are now dead
408
+ * state and should be swept so they don't accumulate or mislead a future operator.
409
+ *
410
+ * Idempotent via the `_instar_migrations` marker. The first run deletes if present;
411
+ * subsequent runs are no-ops. Best-effort — a removal failure logs + continues.
412
+ */
413
+ private migrateRetireMentorOutbox;
387
414
  private migrateSelfKnowledgeTree;
388
415
  private migrateGitignore;
389
416
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"PostUpdateMigrator.d.ts","sourceRoot":"","sources":["../../src/core/PostUpdateMigrator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAqCH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O,CAAC,8BAA8B;IA6HtC,OAAO,CAAC,+BAA+B;IAwKvC,OAAO,CAAC,oBAAoB;IAY5B,OAAO,CAAC,qBAAqB;IAqO7B,OAAO,CAAC,qBAAqB;IAqI7B,OAAO,CAAC,qBAAqB;IAuL7B,OAAO,CAAC,6BAA6B;IAkLrC,OAAO,CAAC,0BAA0B;IAgClC,OAAO,CAAC,gBAAgB;IAmJxB,OAAO,CAAC,6BAA6B;CAoCtC"}
@@ -157,6 +157,8 @@ export class PostUpdateMigrator {
157
157
  this.migrateSettings(result);
158
158
  this.migrateConfig(result);
159
159
  this.migrateLegacyMaxSessions(result);
160
+ this.migrateRetireDeadMentorConfig(result);
161
+ this.migrateRetireMentorOutbox(result);
160
162
  this.migratePrPipelineArtifacts(result);
161
163
  this.migrateBackupManifest(result);
162
164
  this.migrateGitignore(result);
@@ -3900,6 +3902,141 @@ Create worktrees for collaborator repos with \`instar worktree create <branch>\`
3900
3902
  result.errors.push(`legacy maxSessions migration write: ${err instanceof Error ? err.message : String(err)}`);
3901
3903
  }
3902
3904
  }
3905
+ /**
3906
+ * Retire `mentor.dailySpendCapUsd` — a config field that was DECORATIVE (read nowhere
3907
+ * in code; spec MENTOR-LIVE-READINESS §Migration parity called it out as the
3908
+ * silent-dead-config bug we shouldn't repeat at migration time). On a Claude
3909
+ * subscription there's no per-token dollar charge to cap; the real budget is quota-
3910
+ * aware (a separate future PR ships `mentor.stageBTokenCeiling`).
3911
+ *
3912
+ * Behavior:
3913
+ * - field absent → silent skip
3914
+ * - field present at the default (0.5) → silent delete (no warning)
3915
+ * - field present at a NON-default value → delete + LOUD `result.upgraded` entry with
3916
+ * a REVIEW prefix (operator never set this thinking it was enforced; they deserve
3917
+ * to know). Don't repeat the original silent-dead-config bug at migration time.
3918
+ * Idempotent via the `_instar_migrations` marker.
3919
+ */
3920
+ migrateRetireDeadMentorConfig(result) {
3921
+ const configPath = path.join(this.config.stateDir, 'config.json');
3922
+ if (!fs.existsSync(configPath)) {
3923
+ result.skipped.push('mentor dailySpendCapUsd retirement (config.json not found)');
3924
+ return;
3925
+ }
3926
+ let config;
3927
+ try {
3928
+ config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
3929
+ }
3930
+ catch (err) {
3931
+ result.errors.push(`mentor dailySpendCapUsd retirement: ${err instanceof Error ? err.message : String(err)}`);
3932
+ return;
3933
+ }
3934
+ const migrations = (config._instar_migrations ?? []);
3935
+ const marker = 'mentor-dailySpendCapUsd-retire-v1';
3936
+ if (migrations.some(m => m.startsWith(marker))) {
3937
+ result.skipped.push('mentor dailySpendCapUsd retirement (already migrated)');
3938
+ return;
3939
+ }
3940
+ const mentor = config.mentor ?? undefined;
3941
+ if (!mentor || !('dailySpendCapUsd' in mentor)) {
3942
+ // Field never present — mark + skip.
3943
+ migrations.push(`${marker}-${new Date().toISOString()}`);
3944
+ config._instar_migrations = migrations;
3945
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
3946
+ result.skipped.push('mentor dailySpendCapUsd retirement (field never present)');
3947
+ return;
3948
+ }
3949
+ const value = mentor.dailySpendCapUsd;
3950
+ const isDefault = value === 0.5;
3951
+ delete mentor.dailySpendCapUsd;
3952
+ config.mentor = mentor;
3953
+ migrations.push(`${marker}-${new Date().toISOString()}`);
3954
+ config._instar_migrations = migrations;
3955
+ try {
3956
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
3957
+ if (isDefault) {
3958
+ result.upgraded.push('mentor.dailySpendCapUsd retired (was default 0.5; field was decorative — never read)');
3959
+ }
3960
+ else {
3961
+ // LOUD prefix so the operator notices in post-update output (this is the
3962
+ // "non-silent removal" the spec specifically calls for).
3963
+ result.upgraded.push(`REVIEW: mentor.dailySpendCapUsd=${JSON.stringify(value)} was retired. ` +
3964
+ `The field was decorative (never enforced) — Echo runs on a Claude subscription, ` +
3965
+ `so there is no per-token dollar charge to cap. A future update introduces ` +
3966
+ `mentor.stageBTokenCeiling (quota-aware) as the real replacement. ` +
3967
+ `If you set this value expecting enforcement, adjust your expectations accordingly.`);
3968
+ }
3969
+ }
3970
+ catch (err) {
3971
+ result.errors.push(`mentor dailySpendCapUsd retirement write: ${err instanceof Error ? err.message : String(err)}`);
3972
+ }
3973
+ }
3974
+ /**
3975
+ * Retire the legacy `{stateDir}/mentor-outbox/` directory — the file-based mentor
3976
+ * delivery design that Justin's substrate correction replaced (spec MENTOR-LIVE-
3977
+ * READINESS §Migration parity). The new mentor delivery goes through the agent-to-
3978
+ * agent Telegram comms primitive (sendAgentMessage); the outbox files are now dead
3979
+ * state and should be swept so they don't accumulate or mislead a future operator.
3980
+ *
3981
+ * Idempotent via the `_instar_migrations` marker. The first run deletes if present;
3982
+ * subsequent runs are no-ops. Best-effort — a removal failure logs + continues.
3983
+ */
3984
+ migrateRetireMentorOutbox(result) {
3985
+ const configPath = path.join(this.config.stateDir, 'config.json');
3986
+ if (!fs.existsSync(configPath)) {
3987
+ // Still try to retire the outbox if present, even without config.json — but mark
3988
+ // via state-file marker since we can't write to config. Simpler: skip entirely.
3989
+ result.skipped.push('mentor outbox retirement (config.json not found)');
3990
+ return;
3991
+ }
3992
+ let config;
3993
+ try {
3994
+ config = JSON.parse(fs.readFileSync(configPath, 'utf-8'));
3995
+ }
3996
+ catch (err) {
3997
+ result.errors.push(`mentor outbox retirement: ${err instanceof Error ? err.message : String(err)}`);
3998
+ return;
3999
+ }
4000
+ const migrations = (config._instar_migrations ?? []);
4001
+ const marker = 'mentor-outbox-retire-v1';
4002
+ if (migrations.some(m => m.startsWith(marker))) {
4003
+ result.skipped.push('mentor outbox retirement (already migrated)');
4004
+ return;
4005
+ }
4006
+ const outboxDir = path.join(this.config.stateDir, 'mentor-outbox');
4007
+ let removed = false;
4008
+ let filesRemoved = 0;
4009
+ if (fs.existsSync(outboxDir)) {
4010
+ try {
4011
+ // Count files before removing for the audit entry.
4012
+ try {
4013
+ filesRemoved = fs.readdirSync(outboxDir).length;
4014
+ }
4015
+ catch { /* ignore, just for the audit */ }
4016
+ SafeFsExecutor.safeRmSync(outboxDir, { recursive: true, force: true, operation: 'migrateRetireMentorOutbox' });
4017
+ removed = true;
4018
+ }
4019
+ catch (err) {
4020
+ result.errors.push(`mentor outbox retirement removeSync failed: ${err instanceof Error ? err.message : String(err)}`);
4021
+ // Don't mark migrated on failure — retry on next run.
4022
+ return;
4023
+ }
4024
+ }
4025
+ migrations.push(`${marker}-${new Date().toISOString()}`);
4026
+ config._instar_migrations = migrations;
4027
+ try {
4028
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
4029
+ if (removed) {
4030
+ result.upgraded.push(`mentor-outbox directory retired (removed ${filesRemoved} file(s) — legacy file-based mentor delivery; replaced by the agent-to-agent Telegram comms primitive)`);
4031
+ }
4032
+ else {
4033
+ result.skipped.push('mentor outbox retirement (directory not present; marker set so we don\'t re-check)');
4034
+ }
4035
+ }
4036
+ catch (err) {
4037
+ result.errors.push(`mentor outbox retirement marker write: ${err instanceof Error ? err.message : String(err)}`);
4038
+ }
4039
+ }
3903
4040
  migrateSelfKnowledgeTree(result) {
3904
4041
  const treeFilePath = path.join(this.config.stateDir, 'self-knowledge-tree.json');
3905
4042
  try {