@neat.is/core 0.4.17 → 0.4.18

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.
package/dist/index.d.cts CHANGED
@@ -355,8 +355,25 @@ declare function computeGraphDiff(liveGraph: NeatGraph, baseSnapshot: PersistedS
355
355
  * - Auto-restart on crash. PID file is the supervisor handoff.
356
356
  */
357
357
 
358
+ interface DaemonPorts {
359
+ rest: number;
360
+ otlp: number;
361
+ web: number;
362
+ }
363
+ interface DaemonRecord {
364
+ project: string;
365
+ projectPath: string;
366
+ pid: number;
367
+ status: 'running' | 'stopped';
368
+ ports: DaemonPorts;
369
+ startedAt: string;
370
+ neatVersion: string;
371
+ }
358
372
  interface DaemonOptions {
359
373
  neatHome?: string;
374
+ project?: string;
375
+ projectPath?: string;
376
+ webPort?: number;
360
377
  restPort?: number;
361
378
  otlpPort?: number;
362
379
  host?: string;
@@ -390,6 +407,7 @@ interface DaemonHandle {
390
407
  otlpAddress: string;
391
408
  bootstrap: BootstrapTracker;
392
409
  initialBootstrap: Promise<void>;
410
+ daemonRecord: DaemonRecord | null;
393
411
  }
394
412
  /**
395
413
  * Resolve which project's graph an OTel span belongs to. Looks up the
@@ -427,22 +445,34 @@ declare function routeSpanToProject(serviceName: string | undefined, projects: R
427
445
  declare function startDaemon(opts?: DaemonOptions): Promise<DaemonHandle>;
428
446
 
429
447
  /**
430
- * Machine-level project registry (ADR-048).
448
+ * Machine-level project registry + machine-wide daemon discovery.
449
+ *
450
+ * This module owns two surfaces under `~/.neat/`:
451
+ *
452
+ * 1. The legacy project registry at `~/.neat/projects.json` (ADR-048). One
453
+ * file, per-user, machine-local, not synced. Under the project-daemon
454
+ * contract (ADR-096) it is no longer the coordination point — it is read
455
+ * once for migration and otherwise left to the additive writes the daemon
456
+ * and orchestrator still perform. The read-modify-write helpers below keep
457
+ * their atomic-write + exclusive-lock machinery for that legacy surface.
431
458
  *
432
- * One file: `~/.neat/projects.json`. Per-user, machine-local. Not synced.
433
- * `registry.ts` is the only module that opens it. Everything else — `init`,
434
- * `daemon`, `cli` calls into the helpers below.
459
+ * 2. The machine-wide daemon discovery directory at `~/.neat/daemons/`
460
+ * (ADR-096 §6). One file per running daemon `<project>.json` each owned
461
+ * solely by the daemon that wrote it (on start) and removes it (on graceful
462
+ * stop). Discovery is **append-only and lock-free**: a reader scans the
463
+ * directory and reconciles liveness; it never acquires a shared lock, so it
464
+ * can never deadlock against a daemon (#506). Losing or rebuilding the
465
+ * directory costs discovery convenience, not correctness — each project's
466
+ * own `neat-out/daemon.json` stays authoritative.
435
467
  *
436
- * Two safety properties matter:
437
- * 1. Atomic writes. We tmp + fsync + rename so the daemon never sees a torn
438
- * file when init races against it.
439
- * 2. Cross-process exclusion. We hold an exclusive lock on
440
- * `~/.neat/projects.json.lock` for the read-modify-write window. Two
441
- * concurrent `neat init` runs cannot both win and overwrite each other.
468
+ * `neat ps` / `neat list` and the per-daemon `pause` / `resume` / `uninstall`
469
+ * verbs read discovery, falling back to the legacy registry where no daemon
470
+ * file is present yet (the migration window before every daemon self-describes).
442
471
  *
443
- * The lock is a file we exclusively-create (`O_EXCL`), hold while we mutate,
444
- * and unlink on the way out. Crude but cross-platform; matches what
445
- * `proper-lockfile` does internally without pulling the dep in.
472
+ * The legacy lock is a file we exclusively-create (`O_EXCL`), hold while we
473
+ * mutate, and unlink on the way out. Crude but cross-platform; matches what
474
+ * `proper-lockfile` does internally without pulling the dep in. It never sits
475
+ * on the discovery path.
446
476
  */
447
477
 
448
478
  declare function registryPath(): string;
package/dist/index.d.ts CHANGED
@@ -355,8 +355,25 @@ declare function computeGraphDiff(liveGraph: NeatGraph, baseSnapshot: PersistedS
355
355
  * - Auto-restart on crash. PID file is the supervisor handoff.
356
356
  */
357
357
 
358
+ interface DaemonPorts {
359
+ rest: number;
360
+ otlp: number;
361
+ web: number;
362
+ }
363
+ interface DaemonRecord {
364
+ project: string;
365
+ projectPath: string;
366
+ pid: number;
367
+ status: 'running' | 'stopped';
368
+ ports: DaemonPorts;
369
+ startedAt: string;
370
+ neatVersion: string;
371
+ }
358
372
  interface DaemonOptions {
359
373
  neatHome?: string;
374
+ project?: string;
375
+ projectPath?: string;
376
+ webPort?: number;
360
377
  restPort?: number;
361
378
  otlpPort?: number;
362
379
  host?: string;
@@ -390,6 +407,7 @@ interface DaemonHandle {
390
407
  otlpAddress: string;
391
408
  bootstrap: BootstrapTracker;
392
409
  initialBootstrap: Promise<void>;
410
+ daemonRecord: DaemonRecord | null;
393
411
  }
394
412
  /**
395
413
  * Resolve which project's graph an OTel span belongs to. Looks up the
@@ -427,22 +445,34 @@ declare function routeSpanToProject(serviceName: string | undefined, projects: R
427
445
  declare function startDaemon(opts?: DaemonOptions): Promise<DaemonHandle>;
428
446
 
429
447
  /**
430
- * Machine-level project registry (ADR-048).
448
+ * Machine-level project registry + machine-wide daemon discovery.
449
+ *
450
+ * This module owns two surfaces under `~/.neat/`:
451
+ *
452
+ * 1. The legacy project registry at `~/.neat/projects.json` (ADR-048). One
453
+ * file, per-user, machine-local, not synced. Under the project-daemon
454
+ * contract (ADR-096) it is no longer the coordination point — it is read
455
+ * once for migration and otherwise left to the additive writes the daemon
456
+ * and orchestrator still perform. The read-modify-write helpers below keep
457
+ * their atomic-write + exclusive-lock machinery for that legacy surface.
431
458
  *
432
- * One file: `~/.neat/projects.json`. Per-user, machine-local. Not synced.
433
- * `registry.ts` is the only module that opens it. Everything else — `init`,
434
- * `daemon`, `cli` calls into the helpers below.
459
+ * 2. The machine-wide daemon discovery directory at `~/.neat/daemons/`
460
+ * (ADR-096 §6). One file per running daemon `<project>.json` each owned
461
+ * solely by the daemon that wrote it (on start) and removes it (on graceful
462
+ * stop). Discovery is **append-only and lock-free**: a reader scans the
463
+ * directory and reconciles liveness; it never acquires a shared lock, so it
464
+ * can never deadlock against a daemon (#506). Losing or rebuilding the
465
+ * directory costs discovery convenience, not correctness — each project's
466
+ * own `neat-out/daemon.json` stays authoritative.
435
467
  *
436
- * Two safety properties matter:
437
- * 1. Atomic writes. We tmp + fsync + rename so the daemon never sees a torn
438
- * file when init races against it.
439
- * 2. Cross-process exclusion. We hold an exclusive lock on
440
- * `~/.neat/projects.json.lock` for the read-modify-write window. Two
441
- * concurrent `neat init` runs cannot both win and overwrite each other.
468
+ * `neat ps` / `neat list` and the per-daemon `pause` / `resume` / `uninstall`
469
+ * verbs read discovery, falling back to the legacy registry where no daemon
470
+ * file is present yet (the migration window before every daemon self-describes).
442
471
  *
443
- * The lock is a file we exclusively-create (`O_EXCL`), hold while we mutate,
444
- * and unlink on the way out. Crude but cross-platform; matches what
445
- * `proper-lockfile` does internally without pulling the dep in.
472
+ * The legacy lock is a file we exclusively-create (`O_EXCL`), hold while we
473
+ * mutate, and unlink on the way out. Crude but cross-platform; matches what
474
+ * `proper-lockfile` does internally without pulling the dep in. It never sits
475
+ * on the discovery path.
446
476
  */
447
477
 
448
478
  declare function registryPath(): string;
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  routeSpanToProject,
3
3
  startDaemon
4
- } from "./chunk-CEDXXMGO.js";
4
+ } from "./chunk-GXWBMJDJ.js";
5
5
  import {
6
6
  ProjectNameCollisionError,
7
7
  addProject,
@@ -37,15 +37,15 @@ import {
37
37
  thresholdForEdgeType,
38
38
  touchLastSeen,
39
39
  writeAtomically
40
- } from "./chunk-LUDSPX5N.js";
40
+ } from "./chunk-T3X6XJPU.js";
41
41
  import {
42
42
  startOtelGrpcReceiver
43
- } from "./chunk-GHPHVXYM.js";
43
+ } from "./chunk-MTXF77TN.js";
44
44
  import {
45
45
  buildOtelReceiver,
46
46
  logSpanHandler,
47
47
  parseOtlpRequest
48
- } from "./chunk-6CO7C4IU.js";
48
+ } from "./chunk-BGPWBRLU.js";
49
49
  export {
50
50
  ProjectNameCollisionError,
51
51
  addProject,