@lumenflow/core 1.3.4 → 1.3.6

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 (64) hide show
  1. package/dist/adapters/filesystem-metrics.adapter.d.ts +1 -1
  2. package/dist/adapters/filesystem-metrics.adapter.js +1 -1
  3. package/dist/beacon-migration.d.ts +56 -0
  4. package/dist/beacon-migration.js +101 -0
  5. package/dist/cleanup-lock.js +3 -3
  6. package/dist/commands-logger.d.ts +2 -2
  7. package/dist/commands-logger.js +5 -5
  8. package/dist/core/tool-runner.d.ts +1 -1
  9. package/dist/core/tool-runner.js +2 -2
  10. package/dist/docs-path-validator.d.ts +2 -2
  11. package/dist/docs-path-validator.js +4 -4
  12. package/dist/domain/orchestration.constants.js +3 -3
  13. package/dist/force-bypass-audit.d.ts +2 -2
  14. package/dist/force-bypass-audit.js +8 -7
  15. package/dist/index.d.ts +2 -0
  16. package/dist/index.js +4 -0
  17. package/dist/lane-lock.d.ts +1 -1
  18. package/dist/lane-lock.js +3 -4
  19. package/dist/logs-lib.d.ts +2 -2
  20. package/dist/logs-lib.js +5 -4
  21. package/dist/lumenflow-config-schema.d.ts +1 -1
  22. package/dist/lumenflow-config-schema.js +19 -19
  23. package/dist/lumenflow-config.js +1 -1
  24. package/dist/merge-lock.js +7 -7
  25. package/dist/prompt-linter.js +3 -3
  26. package/dist/prompt-monitor.d.ts +1 -1
  27. package/dist/prompt-monitor.js +5 -5
  28. package/dist/rebase-artifact-cleanup.d.ts +1 -1
  29. package/dist/rebase-artifact-cleanup.js +1 -1
  30. package/dist/spawn-recovery.d.ts +2 -2
  31. package/dist/spawn-recovery.js +6 -6
  32. package/dist/spawn-registry-store.d.ts +2 -2
  33. package/dist/spawn-registry-store.js +2 -2
  34. package/dist/spawn-tree.d.ts +2 -2
  35. package/dist/spawn-tree.js +2 -2
  36. package/dist/stamp-utils.d.ts +1 -1
  37. package/dist/stamp-utils.js +1 -1
  38. package/dist/state-machine.d.ts +1 -0
  39. package/dist/state-machine.js +2 -1
  40. package/dist/telemetry.d.ts +1 -1
  41. package/dist/telemetry.js +1 -1
  42. package/dist/wu-checkpoint.js +4 -4
  43. package/dist/wu-consistency-checker.d.ts +22 -2
  44. package/dist/wu-consistency-checker.js +260 -30
  45. package/dist/wu-constants.d.ts +67 -4
  46. package/dist/wu-constants.js +41 -15
  47. package/dist/wu-done-branch-only.js +2 -2
  48. package/dist/wu-done-inputs.js +1 -1
  49. package/dist/wu-done-validation.js +2 -2
  50. package/dist/wu-done-worktree.js +4 -4
  51. package/dist/wu-paths.js +1 -1
  52. package/dist/wu-recovery.d.ts +4 -4
  53. package/dist/wu-recovery.js +8 -8
  54. package/dist/wu-repair-core.js +4 -4
  55. package/dist/wu-spawn-helpers.d.ts +1 -1
  56. package/dist/wu-spawn-helpers.js +3 -2
  57. package/dist/wu-spawn.js +7 -7
  58. package/dist/wu-state-schema.d.ts +24 -1
  59. package/dist/wu-state-schema.js +13 -0
  60. package/dist/wu-state-store.d.ts +23 -2
  61. package/dist/wu-state-store.js +56 -2
  62. package/package.json +3 -3
  63. package/dist/spec-branch-helpers.d.ts +0 -118
  64. package/dist/spec-branch-helpers.js +0 -199
@@ -4,7 +4,7 @@
4
4
  * Monitors all prompts for token budget drift and hash changes.
5
5
  * Designed to run as a GitHub Actions cron job (nightly at 2 AM).
6
6
  *
7
- * Logs to .beacon/telemetry/prompt-nightly.ndjson and Axiom.
7
+ * Logs to .lumenflow/telemetry/prompt-nightly.ndjson and Axiom.
8
8
  * Alerts if:
9
9
  * - Any prompt ≥400 tokens (approaching cap)
10
10
  * - Any delta >50 tokens since yesterday
@@ -17,14 +17,14 @@ import { readFile, writeFile, mkdir, appendFile, access } from 'node:fs/promises
17
17
  import { resolve, dirname } from 'path';
18
18
  import { fileURLToPath } from 'url';
19
19
  import { glob } from 'glob';
20
- import { EXIT_CODES, STRING_LITERALS } from './wu-constants.js';
20
+ import { EXIT_CODES, STRING_LITERALS, LUMENFLOW_PATHS } from './wu-constants.js';
21
21
  const __filename = fileURLToPath(import.meta.url);
22
22
  const __dirname = dirname(__filename);
23
23
  const ROOT_DIR = resolve(__dirname, '../..');
24
24
  // Paths
25
- const YESTERDAY_METRICS_PATH = resolve(ROOT_DIR, '.beacon/telemetry/prompt-metrics-yesterday.json');
26
- const TODAY_METRICS_PATH = resolve(ROOT_DIR, '.beacon/telemetry/prompt-metrics.json');
27
- const NDJSON_LOG_PATH = resolve(ROOT_DIR, '.beacon/telemetry/prompt-nightly.ndjson');
25
+ const YESTERDAY_METRICS_PATH = resolve(ROOT_DIR, LUMENFLOW_PATHS.TELEMETRY, 'prompt-metrics-yesterday.json');
26
+ const TODAY_METRICS_PATH = resolve(ROOT_DIR, LUMENFLOW_PATHS.TELEMETRY, 'prompt-metrics.json');
27
+ const NDJSON_LOG_PATH = resolve(ROOT_DIR, LUMENFLOW_PATHS.TELEMETRY, 'prompt-nightly.ndjson');
28
28
  // Alert thresholds
29
29
  const WARN_THRESHOLD = 400;
30
30
  const DELTA_THRESHOLD = 50;
@@ -23,7 +23,7 @@
23
23
  * lane branch itself) should NOT be cleaned - this was the WU-1816 bug.
24
24
  *
25
25
  * Checks for:
26
- * 1. Stamp files (.beacon/stamps/WU-{id}.done) that exist on origin/main
26
+ * 1. Stamp files (.lumenflow/stamps/WU-{id}.done) that exist on origin/main
27
27
  * 2. WU YAML with status=done that also has status=done on origin/main
28
28
  *
29
29
  * @param {string} worktreePath - Path to the worktree directory
@@ -134,7 +134,7 @@ function writeMarkdownFile(filePath, frontmatter, lines) {
134
134
  * lane branch itself) should NOT be cleaned - this was the WU-1816 bug.
135
135
  *
136
136
  * Checks for:
137
- * 1. Stamp files (.beacon/stamps/WU-{id}.done) that exist on origin/main
137
+ * 1. Stamp files (.lumenflow/stamps/WU-{id}.done) that exist on origin/main
138
138
  * 2. WU YAML with status=done that also has status=done on origin/main
139
139
  *
140
140
  * @param {string} worktreePath - Path to the worktree directory
@@ -9,7 +9,7 @@
9
9
  * 2. Stale lock (>2h) -> auto-release, mark spawn timeout
10
10
  * 3. Active lock + no checkpoint in 1h -> mark stuck, escalate
11
11
  *
12
- * All recovery actions are logged to .beacon/recovery/ for audit.
12
+ * All recovery actions are logged to .lumenflow/recovery/ for audit.
13
13
  *
14
14
  * Library-First Note: This is project-specific spawn recovery code for
15
15
  * PatientPath's custom spawn-registry.jsonl, lane-lock, and memory-store.
@@ -60,7 +60,7 @@ export declare const NO_CHECKPOINT_THRESHOLD_MS: number;
60
60
  * }
61
61
  */
62
62
  export interface RecoverStuckSpawnOptions {
63
- /** Base directory for .beacon/ */
63
+ /** Base directory for .lumenflow/ */
64
64
  baseDir?: string;
65
65
  }
66
66
  export declare function recoverStuckSpawn(spawnId: any, options?: RecoverStuckSpawnOptions): Promise<{
@@ -9,7 +9,7 @@
9
9
  * 2. Stale lock (>2h) -> auto-release, mark spawn timeout
10
10
  * 3. Active lock + no checkpoint in 1h -> mark stuck, escalate
11
11
  *
12
- * All recovery actions are logged to .beacon/recovery/ for audit.
12
+ * All recovery actions are logged to .lumenflow/recovery/ for audit.
13
13
  *
14
14
  * Library-First Note: This is project-specific spawn recovery code for
15
15
  * PatientPath's custom spawn-registry.jsonl, lane-lock, and memory-store.
@@ -24,7 +24,7 @@ import path from 'node:path';
24
24
  import { SpawnRegistryStore } from './spawn-registry-store.js';
25
25
  import { SpawnStatus } from './spawn-registry-schema.js';
26
26
  import { isZombieLock, isLockStale, readLockMetadata, getLockFilePath, releaseLaneLock, } from './lane-lock.js';
27
- import { toKebab } from './wu-constants.js';
27
+ import { toKebab, LUMENFLOW_PATHS } from './wu-constants.js';
28
28
  // Optional import from @lumenflow/memory
29
29
  let loadMemory = null;
30
30
  try {
@@ -90,10 +90,10 @@ function laneToKebab(lane) {
90
90
  * Gets the recovery directory path
91
91
  *
92
92
  * @param {string} baseDir - Base directory
93
- * @returns {string} Path to .beacon/recovery/
93
+ * @returns {string} Path to .lumenflow/recovery/
94
94
  */
95
95
  function getRecoveryDir(baseDir) {
96
- return path.join(baseDir, '.beacon', RECOVERY_DIR_NAME);
96
+ return path.join(baseDir, LUMENFLOW_PATHS.BASE, RECOVERY_DIR_NAME);
97
97
  }
98
98
  /**
99
99
  * Creates an audit log entry
@@ -123,7 +123,7 @@ async function getLastCheckpoint(baseDir, wuId) {
123
123
  if (!loadMemory) {
124
124
  return null;
125
125
  }
126
- const memoryDir = path.join(baseDir, '.beacon', 'state');
126
+ const memoryDir = path.join(baseDir, LUMENFLOW_PATHS.STATE_DIR);
127
127
  try {
128
128
  const memory = await loadMemory(memoryDir, wuId);
129
129
  if (!memory) {
@@ -162,7 +162,7 @@ function isCheckpointRecent(checkpointTimestamp) {
162
162
  }
163
163
  export async function recoverStuckSpawn(spawnId, options = {}) {
164
164
  const { baseDir = process.cwd() } = options;
165
- const registryDir = path.join(baseDir, '.beacon', 'state');
165
+ const registryDir = path.join(baseDir, LUMENFLOW_PATHS.STATE_DIR);
166
166
  // Load spawn registry
167
167
  const store = new SpawnRegistryStore(registryDir);
168
168
  try {
@@ -2,7 +2,7 @@
2
2
  * Spawn Registry Store (WU-1944)
3
3
  *
4
4
  * Event-sourced state store for tracking sub-agent spawns.
5
- * Stores events in .beacon/state/spawn-registry.jsonl (append-only, git-friendly).
5
+ * Stores events in .lumenflow/state/spawn-registry.jsonl (append-only, git-friendly).
6
6
  *
7
7
  * Features:
8
8
  * - Event sourcing with replay for current state
@@ -30,7 +30,7 @@ export declare class SpawnRegistryStore {
30
30
  private readonly byParent;
31
31
  private readonly byTarget;
32
32
  /**
33
- * @param {string} baseDir - Directory containing .beacon/state/
33
+ * @param {string} baseDir - Directory containing .lumenflow/state/
34
34
  */
35
35
  constructor(baseDir: string);
36
36
  /**
@@ -2,7 +2,7 @@
2
2
  * Spawn Registry Store (WU-1944)
3
3
  *
4
4
  * Event-sourced state store for tracking sub-agent spawns.
5
- * Stores events in .beacon/state/spawn-registry.jsonl (append-only, git-friendly).
5
+ * Stores events in .lumenflow/state/spawn-registry.jsonl (append-only, git-friendly).
6
6
  *
7
7
  * Features:
8
8
  * - Event sourcing with replay for current state
@@ -32,7 +32,7 @@ export class SpawnRegistryStore {
32
32
  byParent;
33
33
  byTarget;
34
34
  /**
35
- * @param {string} baseDir - Directory containing .beacon/state/
35
+ * @param {string} baseDir - Directory containing .lumenflow/state/
36
36
  */
37
37
  constructor(baseDir) {
38
38
  this.baseDir = baseDir;
@@ -75,7 +75,7 @@ export declare function formatSpawnTree(tree: any): string;
75
75
  * @returns {Promise<import('./spawn-registry-schema.js').SpawnEvent[]>} Array of spawn events
76
76
  *
77
77
  * @example
78
- * const spawns = await getSpawnsByWU('WU-1000', '.beacon/state');
78
+ * const spawns = await getSpawnsByWU('WU-1000', '.lumenflow/state');
79
79
  */
80
80
  export declare function getSpawnsByWU(wuId: any, baseDir: any): Promise<any[]>;
81
81
  /**
@@ -90,7 +90,7 @@ export declare function getSpawnsByWU(wuId: any, baseDir: any): Promise<any[]>;
90
90
  * @returns {Promise<import('./spawn-registry-schema.js').SpawnEvent[]>} Array of spawn events
91
91
  *
92
92
  * @example
93
- * const spawns = await getSpawnsByInitiative('INIT-001', '.beacon/state', 'docs/04-operations/tasks/wu');
93
+ * const spawns = await getSpawnsByInitiative('INIT-001', '.lumenflow/state', 'docs/04-operations/tasks/wu');
94
94
  */
95
95
  export declare function getSpawnsByInitiative(initiativeId: any, registryDir: any, wuDir: any): Promise<{
96
96
  id: string;
@@ -153,7 +153,7 @@ export function formatSpawnTree(tree) {
153
153
  * @returns {Promise<import('./spawn-registry-schema.js').SpawnEvent[]>} Array of spawn events
154
154
  *
155
155
  * @example
156
- * const spawns = await getSpawnsByWU('WU-1000', '.beacon/state');
156
+ * const spawns = await getSpawnsByWU('WU-1000', '.lumenflow/state');
157
157
  */
158
158
  export async function getSpawnsByWU(wuId, baseDir) {
159
159
  const store = new SpawnRegistryStore(baseDir);
@@ -205,7 +205,7 @@ export async function getSpawnsByWU(wuId, baseDir) {
205
205
  * @returns {Promise<import('./spawn-registry-schema.js').SpawnEvent[]>} Array of spawn events
206
206
  *
207
207
  * @example
208
- * const spawns = await getSpawnsByInitiative('INIT-001', '.beacon/state', 'docs/04-operations/tasks/wu');
208
+ * const spawns = await getSpawnsByInitiative('INIT-001', '.lumenflow/state', 'docs/04-operations/tasks/wu');
209
209
  */
210
210
  export async function getSpawnsByInitiative(initiativeId, registryDir, wuDir) {
211
211
  // Get all WUs belonging to initiative
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * WU-2242: Added format validation for corrupted stamp detection
8
8
  *
9
- * Stamp files (.beacon/stamps/WU-{id}.done) serve as completion markers
9
+ * Stamp files (.lumenflow/stamps/WU-{id}.done) serve as completion markers
10
10
  * Used by wu:done, wu:recovery, and validation tools
11
11
  */
12
12
  /**
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * WU-2242: Added format validation for corrupted stamp detection
8
8
  *
9
- * Stamp files (.beacon/stamps/WU-{id}.done) serve as completion markers
9
+ * Stamp files (.lumenflow/stamps/WU-{id}.done) serve as completion markers
10
10
  * Used by wu:done, wu:recovery, and validation tools
11
11
  */
12
12
  /* eslint-disable security/detect-non-literal-fs-filename */
@@ -9,6 +9,7 @@
9
9
  * - in_progress → blocked (block)
10
10
  * - in_progress → waiting (implementation complete, awaiting sign-off)
11
11
  * - in_progress → done (direct completion)
12
+ * - in_progress → ready (release - WU-1080: orphan recovery)
12
13
  * - blocked → in_progress (unblock)
13
14
  * - blocked → done (blocker resolved, direct completion)
14
15
  * - waiting → in_progress (changes requested)
@@ -9,6 +9,7 @@
9
9
  * - in_progress → blocked (block)
10
10
  * - in_progress → waiting (implementation complete, awaiting sign-off)
11
11
  * - in_progress → done (direct completion)
12
+ * - in_progress → ready (release - WU-1080: orphan recovery)
12
13
  * - blocked → in_progress (unblock)
13
14
  * - blocked → done (blocker resolved, direct completion)
14
15
  * - waiting → in_progress (changes requested)
@@ -26,7 +27,7 @@ const VALID_STATES = new Set(['ready', 'in_progress', 'blocked', 'waiting', 'don
26
27
  */
27
28
  const TRANSITIONS = {
28
29
  ready: ['in_progress'],
29
- in_progress: ['blocked', 'waiting', 'done'],
30
+ in_progress: ['blocked', 'waiting', 'done', 'ready'], // WU-1080: 'ready' via release for orphan recovery
30
31
  blocked: ['in_progress', 'done'],
31
32
  waiting: ['in_progress', 'done'],
32
33
  done: [], // Terminal state - no outgoing transitions
@@ -69,7 +69,7 @@ export declare function emitLLMClassificationComplete(data: any, logPath?: strin
69
69
  */
70
70
  export declare function emitLLMClassificationError(data: any, logPath?: string): void;
71
71
  /**
72
- * Emit WU flow telemetry event to .beacon/flow.log
72
+ * Emit WU flow telemetry event to .lumenflow/flow.log
73
73
  *
74
74
  * Used by wu-claim, wu-done, wu-unblock for workflow tracking.
75
75
  * Centralized from duplicated emitTelemetry() functions (WU-1256).
package/dist/telemetry.js CHANGED
@@ -188,7 +188,7 @@ export function emitLLMClassificationError(data, logPath = LLM_CLASSIFICATION_LO
188
188
  emit(logPath, event);
189
189
  }
190
190
  /**
191
- * Emit WU flow telemetry event to .beacon/flow.log
191
+ * Emit WU flow telemetry event to .lumenflow/flow.log
192
192
  *
193
193
  * Used by wu-claim, wu-done, wu-unblock for workflow tracking.
194
194
  * Centralized from duplicated emitTelemetry() functions (WU-1256).
@@ -16,14 +16,14 @@
16
16
  import { existsSync, readFileSync, writeFileSync, unlinkSync, mkdirSync } from 'node:fs';
17
17
  import path from 'node:path';
18
18
  import crypto from 'node:crypto';
19
- import { LOG_PREFIX, EMOJI } from './wu-constants.js';
19
+ import { LOG_PREFIX, EMOJI, LUMENFLOW_PATHS } from './wu-constants.js';
20
20
  /**
21
21
  * Schema version for checkpoint files
22
22
  * Increment when checkpoint format changes
23
23
  */
24
24
  export const CHECKPOINT_SCHEMA_VERSION = 1;
25
25
  /**
26
- * Checkpoint directory within .beacon
26
+ * Checkpoint directory within .lumenflow
27
27
  */
28
28
  const CHECKPOINT_DIR = 'checkpoints';
29
29
  /**
@@ -39,7 +39,7 @@ const CHECKPOINT_MAX_AGE_MS = 24 * 60 * 60 * 1000;
39
39
  */
40
40
  function getCheckpointPath(wuId, options = {}) {
41
41
  const baseDir = options.baseDir || process.cwd();
42
- return path.join(baseDir, '.beacon', CHECKPOINT_DIR, `${wuId}.checkpoint.json`);
42
+ return path.join(baseDir, LUMENFLOW_PATHS.BASE, CHECKPOINT_DIR, `${wuId}.checkpoint.json`);
43
43
  }
44
44
  /**
45
45
  * Ensure checkpoint directory exists
@@ -48,7 +48,7 @@ function getCheckpointPath(wuId, options = {}) {
48
48
  */
49
49
  function ensureCheckpointDir(options = {}) {
50
50
  const baseDir = options.baseDir || process.cwd();
51
- const checkpointDir = path.join(baseDir, '.beacon', CHECKPOINT_DIR);
51
+ const checkpointDir = path.join(baseDir, LUMENFLOW_PATHS.BASE, CHECKPOINT_DIR);
52
52
  if (!existsSync(checkpointDir)) {
53
53
  mkdirSync(checkpointDir, { recursive: true });
54
54
  }
@@ -84,14 +84,34 @@ export interface RepairWUInconsistencyOptions {
84
84
  projectRoot?: string;
85
85
  }
86
86
  /**
87
- * Repair WU inconsistencies
87
+ * Error object structure from checkWUConsistency()
88
+ */
89
+ interface ConsistencyError {
90
+ type: string;
91
+ wuId: string;
92
+ title?: string;
93
+ lane?: string;
94
+ description?: string;
95
+ repairAction?: string;
96
+ canAutoRepair: boolean;
97
+ }
98
+ /**
99
+ * Repair WU inconsistencies using micro-worktree isolation (WU-1078)
100
+ *
101
+ * All file modifications (stamps, YAML, markdown) are made atomically
102
+ * in a micro-worktree, then committed and pushed to origin/main.
103
+ * This prevents direct writes to the main checkout.
88
104
  *
89
105
  * @param {object} report - Report from checkWUConsistency()
90
106
  * @param {RepairWUInconsistencyOptions} [options={}] - Repair options
91
107
  * @returns {Promise<object>} Result with repaired, skipped, and failed counts
92
108
  */
93
- export declare function repairWUInconsistency(report: any, options?: RepairWUInconsistencyOptions): Promise<{
109
+ export declare function repairWUInconsistency(report: {
110
+ valid: boolean;
111
+ errors: ConsistencyError[];
112
+ }, options?: RepairWUInconsistencyOptions): Promise<{
94
113
  repaired: number;
95
114
  skipped: number;
96
115
  failed: number;
97
116
  }>;
117
+ export {};