@north-light/api 0.3.755 → 0.3.757

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 (75) hide show
  1. package/dist/api/client.d.ts +1 -2
  2. package/dist/api/client.js +0 -3
  3. package/dist/api/contract.d.ts +1 -1
  4. package/dist/api/contract.js +1 -1
  5. package/dist/api/dto/health.d.ts +0 -54
  6. package/dist/api/routes.d.ts +0 -1
  7. package/dist/api/routes.js +0 -1
  8. package/dist/build-root.d.ts +0 -3
  9. package/dist/build-root.js +0 -9
  10. package/dist/commands/profile/new.js +2 -2
  11. package/dist/commands/profile/project.js +2 -1
  12. package/dist/commands/sys/branch.js +1 -1
  13. package/dist/commands/sys/daemon.js +1 -1
  14. package/dist/commands/sys.js +1 -2
  15. package/dist/core/canvas/executions.d.ts +0 -3
  16. package/dist/core/canvas/executions.js +1 -17
  17. package/dist/core/canvas/pid.d.ts +0 -10
  18. package/dist/core/canvas/pid.js +0 -16
  19. package/dist/core/directory/join.js +18 -1
  20. package/dist/core/grants/mirror.d.ts +0 -5
  21. package/dist/core/grants/mirror.js +0 -7
  22. package/dist/core/grants/sync.js +2 -2
  23. package/dist/core/human/page-schema.d.ts +1 -1
  24. package/dist/core/io.js +0 -5
  25. package/dist/core/layout.d.ts +0 -2
  26. package/dist/core/layout.js +2 -19
  27. package/dist/core/profiles/manifest.js +12 -18
  28. package/dist/core/profiles/project-dir.d.ts +3 -0
  29. package/dist/core/profiles/project-dir.js +20 -0
  30. package/dist/daemon/api/map.d.ts +1 -6
  31. package/dist/daemon/api/map.js +0 -16
  32. package/dist/daemon/api/operations.js +0 -1
  33. package/dist/daemon/control.d.ts +0 -8
  34. package/dist/daemon/manage.js +1 -1
  35. package/package.json +1 -1
  36. package/dist/commands/sys/migrate.d.ts +0 -1
  37. package/dist/commands/sys/migrate.js +0 -79
  38. package/dist/core/layout-migrate/index.d.ts +0 -38
  39. package/dist/core/layout-migrate/index.js +0 -523
  40. package/dist/core/layout-migrate/paths.d.ts +0 -30
  41. package/dist/core/layout-migrate/paths.js +0 -118
  42. package/dist/core/layout-migrate/stored-paths.d.ts +0 -9
  43. package/dist/core/layout-migrate/stored-paths.js +0 -424
  44. package/dist/core/layout-migrate/stores.d.ts +0 -30
  45. package/dist/core/layout-migrate/stores.js +0 -543
  46. package/dist/core/locked-file.d.ts +0 -27
  47. package/dist/core/locked-file.js +0 -121
  48. package/dist/core/scoped-state/db.d.ts +0 -17
  49. package/dist/core/scoped-state/db.js +0 -271
  50. package/dist/core/scoped-state/legacy-profiles.d.ts +0 -11
  51. package/dist/core/scoped-state/legacy-profiles.js +0 -65
  52. package/dist/core/scoped-state/migrate.d.ts +0 -15
  53. package/dist/core/scoped-state/migrate.js +0 -332
  54. package/dist/core/scoped-state/schema.d.ts +0 -14
  55. package/dist/core/scoped-state/schema.js +0 -52
  56. package/dist/migrations/004-canvas-documents/apply.d.ts +0 -8
  57. package/dist/migrations/004-canvas-documents/apply.js +0 -113
  58. package/dist/migrations/004-canvas-documents/index.d.ts +0 -16
  59. package/dist/migrations/004-canvas-documents/index.js +0 -89
  60. package/dist/migrations/004-canvas-documents/legacy/discover.d.ts +0 -16
  61. package/dist/migrations/004-canvas-documents/legacy/discover.js +0 -251
  62. package/dist/migrations/004-canvas-documents/legacy/history.d.ts +0 -5
  63. package/dist/migrations/004-canvas-documents/legacy/history.js +0 -37
  64. package/dist/migrations/004-canvas-documents/legacy/nested.d.ts +0 -7
  65. package/dist/migrations/004-canvas-documents/legacy/nested.js +0 -37
  66. package/dist/migrations/004-canvas-documents/legacy/parse.d.ts +0 -14
  67. package/dist/migrations/004-canvas-documents/legacy/parse.js +0 -24
  68. package/dist/migrations/004-canvas-documents/legacy/types.d.ts +0 -91
  69. package/dist/migrations/004-canvas-documents/legacy/types.js +0 -3
  70. package/dist/migrations/004-canvas-documents/plan.d.ts +0 -102
  71. package/dist/migrations/004-canvas-documents/plan.js +0 -410
  72. package/dist/migrations/004-canvas-documents/pointers.d.ts +0 -23
  73. package/dist/migrations/004-canvas-documents/pointers.js +0 -95
  74. package/dist/migrations/activation.d.ts +0 -17
  75. package/dist/migrations/activation.js +0 -46
@@ -2,7 +2,7 @@ import { ApiError } from './errors.js';
2
2
  import type { FeedbackDTO, FeedbackRequest, GitCredentialDTO, GitCredentialRequest, StartBundleDTO } from './dto/execution-start.js';
3
3
  import type { ChargeListDTO, SpendLimitListDTO, SpendLimitRemovedDTO, SpendLimitSetRequest, LimitDTO } from './dto/charges.js';
4
4
  import type { AppLimitsChangeDTO, LimitsDTO, SetAppLimitsRequest } from './dto/limits.js';
5
- import type { DaemonAdmitDTO, DaemonDrainDTO, DaemonDrainRequest, DaemonRestartDTO, DueDTO, HealthDTO, ReadyDTO, MigrateStateDTO, MigrateStateRequest, StatusDTO } from './dto/health.js';
5
+ import type { DaemonAdmitDTO, DaemonDrainDTO, DaemonDrainRequest, DaemonRestartDTO, DueDTO, HealthDTO, ReadyDTO, StatusDTO } from './dto/health.js';
6
6
  import type { BashJobOutputDTO, BashJobOutputQuery, BashJobStatusDTO, BashJobStopResultDTO } from './dto/bash-jobs.js';
7
7
  import type { ContextListDTO, CreateNodeRequest, ListNodesQuery, NodeDetailDTO, NodeMessagesPageDTO, NodeMessagesQuery, NodeSessionDTO, NodeSnapshotDTO, NodeSubjectDTO, NodeSummaryDTO, TranscriptDTO, TranscriptQuery } from './dto/nodes.js';
8
8
  import type { NodeOutcomeResponseDTO, OutcomeDeliveryDTO, RegisterOutcomeDeliveryRequest } from './dto/node-outcomes.js';
@@ -145,7 +145,6 @@ export declare class CrtrClient {
145
145
  drainDaemon(req?: DaemonDrainRequest): Promise<DaemonDrainDTO>;
146
146
  endDaemonDrain(): Promise<DaemonDrainDTO>;
147
147
  admitDaemon(): Promise<DaemonAdmitDTO>;
148
- migrateState(req: MigrateStateRequest): Promise<MigrateStateDTO>;
149
148
  appendNodeLog(id: string, req: NodeLogAppendRequest): Promise<NodeLogAppendResultDTO>;
150
149
  putNodeTelemetry(id: string, req: NodeTelemetryRecordRequest): Promise<void>;
151
150
  putNodeSummaries(id: string, req: NodeSummariesRecordRequest): Promise<void>;
@@ -151,9 +151,6 @@ export class CrtrClient {
151
151
  admitDaemon() {
152
152
  return this.request('POST', routes.daemonAdmit());
153
153
  }
154
- migrateState(req) {
155
- return this.request('POST', routes.daemonMigrate(), req);
156
- }
157
154
  // Nodes
158
155
  appendNodeLog(id, req) {
159
156
  return this.request('POST', routes.nodeLog(this.nodePath(id)), req);
@@ -1,5 +1,5 @@
1
1
  /** The contract level this build serves and requires. Written by `scripts/contract.mjs release`; never edit by hand. */
2
- export declare const CONTRACT_LEVEL = "1.77";
2
+ export declare const CONTRACT_LEVEL = "1.78";
3
3
  /** Request header naming the one contract level the caller needs, e.g. `1.3`. Optional: absent means no check. */
4
4
  export declare const REQUIRED_CONTRACT_HEADER = "Crouter-Required-Contract";
5
5
  /** Response header listing the contract levels the server serves, comma-separated, one per major, e.g. `1.3`. */
@@ -12,7 +12,7 @@
12
12
  //
13
13
  // PURITY (spec §3.1): Node built-ins + `src/api/*` only.
14
14
  /** The contract level this build serves and requires. Written by `scripts/contract.mjs release`; never edit by hand. */
15
- export const CONTRACT_LEVEL = '1.77';
15
+ export const CONTRACT_LEVEL = '1.78';
16
16
  /** Request header naming the one contract level the caller needs, e.g. `1.3`. Optional: absent means no check. */
17
17
  export const REQUIRED_CONTRACT_HEADER = 'Crouter-Required-Contract';
18
18
  /** Response header listing the contract levels the server serves, comma-separated, one per major, e.g. `1.3`. */
@@ -61,60 +61,6 @@ export interface DueDTO {
61
61
  busy: boolean;
62
62
  next_due_at: string | null;
63
63
  }
64
- /** `POST /v1/daemon/restart` — the ack for a daemon-owned handover.
65
- *
66
- * The daemon answers BEFORE it tears anything down: the caller is normally a
67
- * node's own bash tool, whose broker this handover will kill, so the ack must
68
- * be a settled tool result in that node's transcript before the SIGTERM lands.
69
- * `accepted` is therefore a promise about the future, not a completed action —
70
- * the successor daemon is spawned after `grace_ms`, and every node the
71
- * teardown interrupts is resumed by it. */
72
- export interface MigrateStateRequest {
73
- dry_run?: boolean;
74
- }
75
- /** `crtr sys migrate`: the canvas import (004-canvas-documents) plan or result. */
76
- export interface MigrateStateDTO {
77
- /** Loose-key moves/imports (paths and names only). */
78
- loose_keys?: string[];
79
- /** Every store root the import found, with its owner and document count. */
80
- stores: {
81
- root: string;
82
- owner: Record<string, unknown>;
83
- docs: number;
84
- skipped?: string;
85
- }[];
86
- /** `documents.<kind>`, `documents.owner.<type>`, `revisions`, `documents.rewritten`, `owners`, … */
87
- counts: Record<string, number>;
88
- rewrites: {
89
- path: string;
90
- from: string;
91
- to: string;
92
- }[];
93
- dropped_fields: {
94
- path: string;
95
- field: string;
96
- }[];
97
- skipped: {
98
- path: string;
99
- reason: string;
100
- }[];
101
- /** Each clash or unreadable source the import resolved itself, one line each. */
102
- resolutions: {
103
- kind: string;
104
- message: string;
105
- paths: string[];
106
- }[];
107
- blockers: {
108
- kind: string;
109
- message: string;
110
- paths: string[];
111
- }[];
112
- dryRun: boolean;
113
- /** True while the import has not been written. */
114
- pending: boolean;
115
- resumed: boolean;
116
- resume_error?: string;
117
- }
118
64
  /** `POST /v1/daemon/drain` and `DELETE /v1/daemon/drain`: the import's pause of this daemon. Drained means no new wake, no cron
119
65
  * fire, no warm-pool fill and no push-receiver delivery; turns in flight settle. */
120
66
  export interface DaemonDrainRequest {
@@ -7,7 +7,6 @@ export declare const routes: {
7
7
  readonly status: () => string;
8
8
  readonly due: () => string;
9
9
  readonly daemonRestart: () => string;
10
- readonly daemonMigrate: () => string;
11
10
  readonly daemonDrain: () => string;
12
11
  readonly daemonAdmit: () => string;
13
12
  readonly nodes: () => string;
@@ -21,7 +21,6 @@ export const routes = {
21
21
  status: () => `${V}/status`,
22
22
  due: () => `${V}/due`,
23
23
  daemonRestart: () => `${V}/daemon/restart`,
24
- daemonMigrate: () => `${V}/daemon/migrate`,
25
24
  daemonDrain: () => `${V}/daemon/drain`,
26
25
  daemonAdmit: () => `${V}/daemon/admit`,
27
26
  // Nodes — collection + item
@@ -27,11 +27,8 @@ export declare function isDaemonControlInvocation(argv: readonly string[]): bool
27
27
  export declare function isPkgInstallInvocation(argv: readonly string[]): boolean;
28
28
  export declare function isSignInInvocation(argv: readonly string[]): boolean;
29
29
  export declare function isJoinInvocation(argv: readonly string[]): boolean;
30
- export declare function isLayoutMigrationInvocation(argv: readonly string[]): boolean;
31
30
  /** Assemble the canonical daemon-control definitions without loading settings or plugin discovery. This path exists so `crtr sys daemon restart` can start the new generation that converts pre-SQL user state. */
32
31
  export declare function resolveDaemonControlRoot(): Promise<RootDef>;
33
- /** Migration runs offline before command plugins can read or initialize scoped state. */
34
- export declare function resolveLayoutMigrationRoot(): Promise<RootDef>;
35
32
  /** Build a root that contains only the subtree `first` dispatches into.
36
33
  * Returns the FULL root when `first` is not a recognized subtree — bare `crtr`,
37
34
  * `-h`/`--help`, `--version`, and any unknown leading token all need the
@@ -290,20 +290,11 @@ export function isPkgInstallInvocation(argv) {
290
290
  }
291
291
  export function isSignInInvocation(argv) { return isSysInvocation(argv, 'signin') || isSysInvocation(argv, 'signout'); }
292
292
  export function isJoinInvocation(argv) { return isSysInvocation(argv, 'join'); }
293
- export function isLayoutMigrationInvocation(argv) { return isSysInvocation(argv, 'migrate'); }
294
293
  /** Assemble the canonical daemon-control definitions without loading settings or plugin discovery. This path exists so `crtr sys daemon restart` can start the new generation that converts pre-SQL user state. */
295
294
  export async function resolveDaemonControlRoot() {
296
295
  const { registerDaemonControlSys } = await import('./commands/sys/daemon.js');
297
296
  return defineRoot({ tagline: TAGLINE, globals: GLOBALS, subtrees: [registerDaemonControlSys()] });
298
297
  }
299
- /** Migration runs offline before command plugins can read or initialize scoped state. */
300
- export async function resolveLayoutMigrationRoot() {
301
- const [{ defineSysBranch }, { sysMigrateLeaf }] = await Promise.all([
302
- import('./commands/sys/branch.js'),
303
- import('./commands/sys/migrate.js'),
304
- ]);
305
- return defineRoot({ tagline: TAGLINE, globals: GLOBALS, subtrees: [defineSysBranch([sysMigrateLeaf])] });
306
- }
307
298
  /** Build a root that contains only the subtree `first` dispatches into.
308
299
  * Returns the FULL root when `first` is not a recognized subtree — bare `crtr`,
309
300
  * `-h`/`--help`, `--version`, and any unknown leading token all need the
@@ -1,6 +1,6 @@
1
1
  import { defineLeaf } from '../../core/command.js';
2
2
  import { usage } from '../../core/errors.js';
3
- import { resolve } from 'node:path';
3
+ import { resolveExistingProjectDir } from '../../core/profiles/project-dir.js';
4
4
  import { cliClient } from '../api-client.js';
5
5
  import { resolveMetaPairs } from './meta.js';
6
6
  export const newLeaf = defineLeaf({
@@ -87,7 +87,7 @@ export const newLeaf = defineLeaf({
87
87
  throw usage('provide `--name <name>` to create a profile, or `--root` to provision the stable root profile.');
88
88
  return newProfileOutput(await cliClient().createProfile({
89
89
  name,
90
- ...(project !== undefined ? { projects: [{ path: resolve(project) }] } : {}),
90
+ ...(project !== undefined ? { projects: [{ path: resolveExistingProjectDir(project) }] } : {}),
91
91
  ...(repos.length > 0 ? { repositories: repos } : {}),
92
92
  ...(defaultKind !== undefined ? { default_kind: defaultKind } : {}),
93
93
  ...(Object.keys(metadata).length > 0 ? { metadata } : {}),
@@ -1,6 +1,7 @@
1
1
  // `crtr profile project` manages purview relationships and per-owner automatic delivery limits.
2
2
  import { defineLeaf, defineBranch } from '../../core/command.js';
3
3
  import { resolve } from 'node:path';
4
+ import { resolveExistingProjectDir } from '../../core/profiles/project-dir.js';
4
5
  import { usage } from '../../core/errors.js';
5
6
  import { cliClient } from '../api-client.js';
6
7
  import { resolveProfileViaDaemon } from './daemon-profiles.js';
@@ -48,7 +49,7 @@ const addLeaf = defineLeaf({
48
49
  if ((dir === undefined) === (repo === undefined))
49
50
  throw usage('pass exactly one of --dir and --repo', { next: 'Use --dir <directory> for a folder or --repo <handle> for a repo with no folder.' });
50
51
  const updated = await cliClient().updateProfile(id, {
51
- add_project: dir !== undefined ? { path: resolve(dir) } : { repo: repo },
52
+ add_project: dir !== undefined ? { path: resolveExistingProjectDir(dir) } : { repo: repo },
52
53
  });
53
54
  return { profile_id: updated.id, projects: updated.projects };
54
55
  },
@@ -1,7 +1,7 @@
1
1
  import { defineBranch } from '../../core/command.js';
2
2
  const SYS_ROOT_ENTRY = {
3
3
  concept: 'crtr configuration, diagnostics, and self-management',
4
- desc: 'settings, config, connect, setup, tutorial, doctor, context, sync, migrate, join, update, version, feedback, logs, retry-delivery, support, limits, daemon',
4
+ desc: 'settings, config, connect, setup, tutorial, doctor, context, sync, join, update, version, feedback, logs, retry-delivery, support, limits, daemon',
5
5
  useWhen: 'managing the crtr installation, inspecting diagnostics, operating the crtrd supervisor process, or registering a hosted runtime with its directory before first boot',
6
6
  };
7
7
  const SYS_HELP = {
@@ -78,7 +78,7 @@ async function awaitDaemonPhase(phase, timeoutMs) {
78
78
  message: health.startup_blocked ?? 'daemon startup is blocked',
79
79
  received: health.startup_phase,
80
80
  field: 'phase',
81
- next: 'Repair the reported blocker paths with `crtr sys migrate`, then retry the await.',
81
+ next: 'Fix the reported blocker, then retry the await.',
82
82
  });
83
83
  }
84
84
  if (health.startup_phase === phase)
@@ -17,7 +17,6 @@ import { tutorialBranch } from './sys/tutorial/branch.js';
17
17
  import { supportBranch } from './sys/support.js';
18
18
  import { contextBranch } from './sys/context.js';
19
19
  import { sysSyncBranch } from './sys/sync.js';
20
- import { sysMigrateLeaf } from './sys/migrate.js';
21
20
  import { sysJoinLeaf } from './sys/join.js';
22
21
  import { sysImportBranch } from './sys/import/start.js';
23
22
  import { sysMachineBranch } from './sys/machine/rotate.js';
@@ -25,5 +24,5 @@ import { sysDesktopBranch } from './sys/desktop.js';
25
24
  import { sysSigninLeaf, sysSignoutLeaf } from './sys/signin.js';
26
25
  import { sysUpdateLeaf, sysVersionLeaf } from './sys/update.js';
27
26
  export function registerSys() {
28
- return defineSysBranch([sysSettingsLeaf, configBranch, sysEnvBranch, sysSetupLeaf, tutorialBranch, sysDoctorLeaf, contextBranch, sysFeedbackLeaf, sysLogsLeaf, sysWorktreesLeaf, sysRetryDeliveryLeaf, sysSpacesLeaf, sysLimitsBranch, sysSpendBranch, supportBranch, sysUpdateLeaf, sysVersionLeaf, sysMigrateLeaf, sysJoinLeaf, sysSyncBranch, sysImportBranch, sysMachineBranch, sysSigninLeaf, sysSignoutLeaf, sysDesktopBranch, daemonBranch]);
27
+ return defineSysBranch([sysSettingsLeaf, configBranch, sysEnvBranch, sysSetupLeaf, tutorialBranch, sysDoctorLeaf, contextBranch, sysFeedbackLeaf, sysLogsLeaf, sysWorktreesLeaf, sysRetryDeliveryLeaf, sysSpacesLeaf, sysLimitsBranch, sysSpendBranch, supportBranch, sysUpdateLeaf, sysVersionLeaf, sysJoinLeaf, sysSyncBranch, sysImportBranch, sysMachineBranch, sysSigninLeaf, sysSignoutLeaf, sysDesktopBranch, daemonBranch]);
29
28
  }
@@ -77,9 +77,6 @@ export declare function abortExecution(executionId: string, input: {
77
77
  export declare function endLiveExecution(nodeId: string, input: {
78
78
  reason: ExecutionEndReason;
79
79
  }): Promise<boolean>;
80
- export declare function migrateLegacyExecutionIdentities(captureIdentity?: (pid: number) => string | undefined): Promise<{
81
- migrated: string[];
82
- }>;
83
80
  /** Records a stop request on the node's live execution; the first request's time and reason stand. */
84
81
  export declare function requestExecutionStop(nodeId: string, input: {
85
82
  afterTurn: boolean;
@@ -1,6 +1,6 @@
1
1
  import { randomUUID } from 'node:crypto';
2
2
  import { openDb, withCanvasWrite } from './db.js';
3
- import { capturePidIdentities, captureLivenessSnapshot, identitiesMatch, recordedPidLiveness, isBootScopedIdentity, isLegacyTicksIdentity } from './pid.js';
3
+ import { capturePidIdentities, captureLivenessSnapshot, recordedPidLiveness } from './pid.js';
4
4
  import { existsSync, readFileSync } from 'node:fs';
5
5
  import { LAUNCHER_SOCKET } from '../../launcher/spec.js';
6
6
  import { revokeNodeTokens } from './node-tokens.js';
@@ -187,22 +187,6 @@ export async function endLiveExecution(nodeId, input) {
187
187
  return Number(ended.changes) === 1;
188
188
  });
189
189
  }
190
- export async function migrateLegacyExecutionIdentities(captureIdentity = (pid) => capturePidIdentities([pid])?.get(pid)) {
191
- const db = await openDb();
192
- const rows = await db.prepare("SELECT execution_id, pid, process_identity FROM executions WHERE state = 'running' AND pid IS NOT NULL AND process_identity IS NOT NULL").all();
193
- const update = db.prepare("UPDATE executions SET process_identity = ? WHERE execution_id = ? AND pid = ? AND process_identity = ? AND state = 'running'");
194
- const migrated = [];
195
- for (const row of rows) {
196
- if (!isLegacyTicksIdentity(row.process_identity))
197
- continue;
198
- const current = captureIdentity(row.pid);
199
- if (current === undefined || !isBootScopedIdentity(current) || !identitiesMatch(current, row.process_identity))
200
- continue;
201
- if ((await update.run(current, row.execution_id, row.pid, row.process_identity)).changes > 0)
202
- migrated.push(row.execution_id);
203
- }
204
- return { migrated };
205
- }
206
190
  /** Records a stop request on the node's live execution; the first request's time and reason stand. */
207
191
  export async function requestExecutionStop(nodeId, input) {
208
192
  const updated = await (await openDb()).prepare("UPDATE executions SET stop_requested_at = COALESCE(stop_requested_at, ?), stop_after_turn = CASE WHEN stop_requested_at IS NULL THEN ? ELSE stop_after_turn END, stop_reason = COALESCE(stop_reason, ?) WHERE node_id = ? AND state != 'exited'").run(now(), input.afterTurn ? 1 : 0, input.reason, nodeId);
@@ -115,16 +115,6 @@ export declare function killProcessGroup(pid: number, signal?: NodeJS.Signals):
115
115
  * no-boot_id host is not hammered with a synchronous throwing read on every
116
116
  * identity composition. `now` is injectable for tests. */
117
117
  export declare function makeBootIdCache(read: () => string | null, now?: () => number, negativeTtlMs?: number): () => string | null;
118
- /** Is `identity` a LEGACY (pre-boot-scoped) baseline — a `<lstart>#<ticks>` row
119
- * whose base is NOT a boot_id UUID but which DOES carry ticks? These are the
120
- * rows the one-time startup migration re-records once this platform can
121
- * compose boot-scoped identities (see `migrateLegacyPidIdentities`). */
122
- export declare function isLegacyTicksIdentity(identity: string): boolean;
123
- /** Is `identity` a NEW-format boot-scoped baseline — `<bootId>#<ticks>` with a
124
- * real boot_id UUID base AND ticks? The startup migration only re-records a
125
- * legacy row when the pid's CURRENT identity comes out in this shape (i.e. the
126
- * platform now composes new-format), never otherwise. */
127
- export declare function isBootScopedIdentity(identity: string): boolean;
128
118
  /** Compose the stable, BOOT-SCOPED process-identity fingerprint used
129
119
  * everywhere in this module. ALWAYS used to build an identity string, never a
130
120
  * raw field directly, so every identity captured anywhere (launch-time
@@ -304,22 +304,6 @@ export function makeBootIdCache(read, now = Date.now, negativeTtlMs = BOOT_ID_NE
304
304
  };
305
305
  }
306
306
  const bootIdBase = makeBootIdCache(readKernelBootId);
307
- /** Is `identity` a LEGACY (pre-boot-scoped) baseline — a `<lstart>#<ticks>` row
308
- * whose base is NOT a boot_id UUID but which DOES carry ticks? These are the
309
- * rows the one-time startup migration re-records once this platform can
310
- * compose boot-scoped identities (see `migrateLegacyPidIdentities`). */
311
- export function isLegacyTicksIdentity(identity) {
312
- const { base, ticks } = splitIdentity(identity);
313
- return ticks !== undefined && !BOOT_ID_RE.test(base);
314
- }
315
- /** Is `identity` a NEW-format boot-scoped baseline — `<bootId>#<ticks>` with a
316
- * real boot_id UUID base AND ticks? The startup migration only re-records a
317
- * legacy row when the pid's CURRENT identity comes out in this shape (i.e. the
318
- * platform now composes new-format), never otherwise. */
319
- export function isBootScopedIdentity(identity) {
320
- const { base, ticks } = splitIdentity(identity);
321
- return ticks !== undefined && BOOT_ID_RE.test(base);
322
- }
323
307
  /** Compose the stable, BOOT-SCOPED process-identity fingerprint used
324
308
  * everywhere in this module. ALWAYS used to build an identity string, never a
325
309
  * raw field directly, so every identity captured anywhere (launch-time
@@ -3,13 +3,13 @@
3
3
  // It writes no settings (the daemon applies them at its start); the private key never leaves this computer.
4
4
  import { createHash, generateKeyPairSync, randomUUID } from 'node:crypto';
5
5
  import { existsSync, mkdirSync, readdirSync, rmSync } from 'node:fs';
6
+ import { request } from 'node:http';
6
7
  import { hostname } from 'node:os';
7
8
  import { join } from 'node:path';
8
9
  import { InputError } from '../io.js';
9
10
  import { network } from '../errors.js';
10
11
  import { secretsDir } from '../layout.js';
11
12
  import { apiSocketPath } from '../canvas/paths.js';
12
- import { daemonAnswers } from '../layout-migrate/index.js';
13
13
  import { atomicWriteJson, readJsonIfExists } from '../fs-utils.js';
14
14
  import { launcherPresent } from '../grants/sandboxes.js';
15
15
  import { crtrVersion } from '../../shared/crtr-version.js';
@@ -151,6 +151,23 @@ async function registerAndStore(directory, credential, name, retry) {
151
151
  }
152
152
  return { ...joined, registered };
153
153
  }
154
+ /** True when a daemon answers /healthz on the socket (a blocked daemon still answers and owns its files). */
155
+ function daemonAnswers(socketPath) {
156
+ return new Promise(resolve => {
157
+ const req = request({ socketPath, path: '/healthz', method: 'GET', timeout: 1000 }, res => {
158
+ res.resume();
159
+ resolve(true);
160
+ });
161
+ req.on('timeout', () => req.destroy(new Error('daemon probe timed out')));
162
+ req.on('error', error => {
163
+ if (error.code === 'ENOENT' || error.code === 'ECONNREFUSED')
164
+ resolve(false);
165
+ else
166
+ resolve(true); // Uncertain probe: do not touch an owned volume.
167
+ });
168
+ req.end();
169
+ });
170
+ }
154
171
  /** A hosted runtime's first boot: register with the provisioning enrollment token before any daemon exists. Refuses `daemon_running` when one answers. */
155
172
  export async function joinDirectory(directory, token, name = hostname()) {
156
173
  const socket = apiSocketPath();
@@ -179,11 +179,6 @@ export declare function hasSyncedGrants(source: string): Promise<boolean>;
179
179
  * the install's person full local scopes and is not the directory's. Delete it so no
180
180
  * grant exists until grant sync installs the directory's mirror. */
181
181
  export declare function dropLocalGrantMirror(db: CanvasDb): Promise<number>;
182
- /** Mark rows a build older than C-D2 wrote as computed for their revision. That build computed every column locally in the same
183
- * write but never set `computed_rev`, so its rows are complete; left NULL they read as no grant until the next successful
184
- * sync rewrites them, and the terminal grant then refuses every launch (NL-550). A directory-written row with lagging
185
- * columns has NULL scopes, so it is never matched. Returns the rows changed. */
186
- export declare function backfillComputedRev(): Promise<number>;
187
182
  /** The directory response is complete; commit it or keep the prior snapshot intact. */
188
183
  /** A directory team the runtime's owner belongs to: `team` is `team:<id>`, `members` are `user:<id>`. */
189
184
  export interface TeamRecord {
@@ -417,13 +417,6 @@ export async function dropLocalGrantMirror(db) {
417
417
  await db.prepare("DELETE FROM runtime_state WHERE key = 'grants_source'").run();
418
418
  return Number((await db.prepare('DELETE FROM grants').run()).changes);
419
419
  }
420
- /** Mark rows a build older than C-D2 wrote as computed for their revision. That build computed every column locally in the same
421
- * write but never set `computed_rev`, so its rows are complete; left NULL they read as no grant until the next successful
422
- * sync rewrites them, and the terminal grant then refuses every launch (NL-550). A directory-written row with lagging
423
- * columns has NULL scopes, so it is never matched. Returns the rows changed. */
424
- export async function backfillComputedRev() {
425
- return await withCanvasWrite(async (db) => Number((await db.prepare('UPDATE grants SET computed_rev = rev WHERE computed_rev IS NULL AND scopes_json IS NOT NULL AND resolved_scopes_json IS NOT NULL').run()).changes));
426
- }
427
420
  /** The `teams` a grant sync answer carried; absent (an unjoined install, an older directory) reads as none. Team
428
421
  * membership is advisory next to the grants the same answer carries, so an entry that is not a directory team
429
422
  * (`team:<id>`, e.g. a canvas group row echoed back) is dropped rather than failing the sync. */
@@ -8,9 +8,9 @@ import { isUnsandboxedMachine } from '../runtime/unsandboxed.js';
8
8
  import { emitEvent } from '../events/emit.js';
9
9
  import { describeOutboundFailure, outboundFetch, outboundJson, outboundRefusal } from '../events/outbound.js';
10
10
  import { dependenciesOf, endpointPays, inferenceEndpointOf, principalPayer, replaceGrants, teamsOf } from './mirror.js';
11
+ import { loadPersonSettings } from '../scoped-state/person-rows.js';
11
12
  import { onGrantSync } from './on-sync.js';
12
13
  import { hostedEndpointOf, paymentSetupUrlOf, storeHostedEndpoint } from './hosted-endpoint.js';
13
- import { adoptInstallPerson } from '../scoped-state/migrate.js';
14
14
  import { PersonOutsideRequestError, PersonUnresolvedError, personId, resolvePerson, retireLocalPerson, setPersonId } from '../canvas/person.js';
15
15
  export const GRANT_SYNC_INTERVAL_S = 300;
16
16
  /** A `private_key_jwt` client assertion for `endpoint` (the directory's token endpoint), signed by the runtime client key. */
@@ -135,7 +135,7 @@ async function pullPerson() {
135
135
  /** Bind a person resolved on a hosted first boot and run the boot one-shot. */
136
136
  async function bindLatePerson(resolved) {
137
137
  setPersonId(resolved.id);
138
- await adoptInstallPerson(resolved.id);
138
+ await loadPersonSettings(resolved.id);
139
139
  const result = await retireLocalPerson();
140
140
  // The boot reconcile was skipped while the person was unresolved.
141
141
  await withCanvasWrite(async (db) => await reconcilePackages(db));
@@ -186,8 +186,8 @@ export declare const chartDataRowsSchema: z.ZodArray<z.ZodRecord<z.ZodString, z.
186
186
  export declare const chartConfigSchema: z.ZodObject<{
187
187
  kind: z.ZodEnum<{
188
188
  line: "line";
189
- bar: "bar";
190
189
  area: "area";
190
+ bar: "bar";
191
191
  }>;
192
192
  x: z.ZodString;
193
193
  y: z.ZodArray<z.ZodObject<{
package/dist/core/io.js CHANGED
@@ -300,11 +300,6 @@ export function apiErrorToCliError(err, next, options = {}) {
300
300
  next: 'crtrd is now on the new generation — retry the command.',
301
301
  });
302
302
  }
303
- if (err.code === 'layout_migration_required') {
304
- return new CrtrError('layout_migration_required', err.message, ExitCode.NETWORK, {
305
- next: 'Run `crtr sys migrate` while the runtime is offline, then restart it.',
306
- });
307
- }
308
303
  if (err.code === 'daemon_unavailable') {
309
304
  return new CrtrError('daemon_unavailable', err.message, ExitCode.NETWORK, {
310
305
  next: 'Start it with `crtr sys daemon start`, then retry.',
@@ -39,6 +39,4 @@ export declare function describeLayoutMarker(bytes: Uint8Array): string;
39
39
  * never rewritten: an empty or damaged one means the volume lost a write, and
40
40
  * stamping the current version over it would assert a layout nobody verified. */
41
41
  export declare function assertSupportedLayoutMarker(path: string): void;
42
- /** A missing version on an occupied volume is never initialized by daemon startup. */
43
- export declare function layoutNeedsMigration(): boolean;
44
42
  export declare function initializeEmptyLayout(): void;
@@ -102,26 +102,9 @@ export function assertSupportedLayoutMarker(path) {
102
102
  throw new Error(`unsupported runtime layout version: ${path} holds ${describeLayoutMarker(bytes)}; expected "${LAYOUT_VERSION}"`);
103
103
  }
104
104
  }
105
- /** A missing version on an occupied volume is never initialized by daemon startup. */
106
- export function layoutNeedsMigration() {
107
- if (process.env['CRTR_LAYOUT_REFUSE'] === '1')
108
- return true;
109
- if (existsSync(layoutVersionFile())) {
110
- assertSupportedLayoutMarker(layoutVersionFile());
111
- return false;
112
- }
113
- const root = layoutRoot();
114
- const volume = process.platform === 'linux' && root === '/' && existsSync('/volume') ? '/volume' : root;
115
- if (existsSync(join(volume, 'canvas')) || existsSync(join(volume, 'canvas.db')))
116
- return true;
117
- // A moved canvas.db without a layout version is an unfinished offline
118
- // migration. Node records move before the DB, so the old or moved DB always
119
- // accompanies them; entrypoint-created directories are a fresh volume.
120
- return existsSync(join(runtimeRoot(), 'canvas.db'));
121
- }
122
105
  export function initializeEmptyLayout() {
123
- if (layoutNeedsMigration())
124
- throw new Error('layout_migration_required');
106
+ if (existsSync(layoutVersionFile()))
107
+ assertSupportedLayoutMarker(layoutVersionFile());
125
108
  for (const dir of [runtimeRoot(), userRoot(), appsRoot(), secretsDir()]) {
126
109
  // mkdir returns the first directory it had to create; every entry from there down to
127
110
  // `dir` is new, and so is the entry for the first one in its (existing) parent.
@@ -1,7 +1,8 @@
1
1
  // Profile definitions live in scoped state; memory and environment have separate roots.
2
2
  import { randomUUID } from 'node:crypto';
3
- import { existsSync, realpathSync, rmSync, statSync } from 'node:fs';
4
- import { resolve as resolvePath } from 'node:path';
3
+ import { realpathSync, rmSync } from 'node:fs';
4
+ import { isAbsolute, resolve as resolvePath } from 'node:path';
5
+ import { resolveExistingProjectDir } from './project-dir.js';
5
6
  import { SCHEMA_VERSION } from '../../types.js';
6
7
  import { profileSpace } from '../layout.js';
7
8
  import { PROFILE_PROJECT_MEMORY_VALUES } from '../../api/dto/profiles.js';
@@ -165,20 +166,13 @@ export function matchProfileOperand(all, operand, key) {
165
166
  }
166
167
  // Project dirs — resolved to absolute real paths, must exist + be a directory
167
168
  // on add/create, deduped by real path, stored in manifest order.
168
- function resolveExistingProjectDir(dir) {
169
- const abs = resolvePath(dir);
170
- if (!existsSync(abs) || !statSync(abs).isDirectory()) {
171
- throw usage(`project directory does not exist or is not a directory: ${dir}`, {
172
- received: dir,
173
- next: 'Pass an existing directory path.',
174
- });
175
- }
176
- try {
177
- return realpathSync(abs);
178
- }
179
- catch {
180
- return abs;
181
- }
169
+ /** A cloud role cannot see the caller's disk: the caller's CLI already resolved the path on its own machine, so it is stored as sent. */
170
+ function storedProjectDir(dir) {
171
+ if (!isCloudRole())
172
+ return resolveExistingProjectDir(dir);
173
+ if (!isAbsolute(dir))
174
+ throw usage(`project directory must be an absolute path: ${dir}`, { received: dir });
175
+ return dir;
182
176
  }
183
177
  /** First-wins by resolved path; by repo only among entries with no path. A folder entry for a repo that has a repo-only entry merges into it
184
178
  * (one entry, both fields, the repo-only entry's position). */
@@ -342,7 +336,7 @@ export async function createProfile(name, projects = [], opts = {}) {
342
336
  if (opts.metadata !== undefined)
343
337
  assertProfileMetadata(opts.metadata);
344
338
  assertProfileProjects(projects);
345
- const resolvedProjects = dedupeProjects(projects.map((p) => ({ ...(p.repo === undefined ? {} : { repo: p.repo }), ...(p.path === undefined ? {} : { path: resolveExistingProjectDir(p.path) }) })));
339
+ const resolvedProjects = dedupeProjects(projects.map((p) => ({ ...(p.repo === undefined ? {} : { repo: p.repo }), ...(p.path === undefined ? {} : { path: storedProjectDir(p.path) }) })));
346
340
  const profileId = generateProfileId(trimmed);
347
341
  const manifest = {
348
342
  schema_version: SCHEMA_VERSION,
@@ -505,7 +499,7 @@ export async function renameProfile(profileId, name) {
505
499
  * a folder no repo identifies keeps `path` only. A listed entry with that path but no repo gains the repo in place. */
506
500
  export async function addProfileProject(profileId, dir, repo) {
507
501
  assertProfileProjects([{ path: dir, ...(repo === undefined ? {} : { repo }) }]);
508
- const resolved = resolveExistingProjectDir(dir);
502
+ const resolved = storedProjectDir(dir);
509
503
  return await mutateManifest(profileId, (m) => ({
510
504
  ...m,
511
505
  projects: dedupeProjects(m.projects.some((p) => p.path === resolved)
@@ -0,0 +1,3 @@
1
+ /** A project directory as an absolute real path; it must exist and be a directory on THIS machine's disk.
2
+ * The CLI runs this on the caller's machine before sending a path to a canvas that may live in the cloud. */
3
+ export declare function resolveExistingProjectDir(dir: string): string;
@@ -0,0 +1,20 @@
1
+ import { existsSync, realpathSync, statSync } from 'node:fs';
2
+ import { resolve as resolvePath } from 'node:path';
3
+ import { usage } from '../errors.js';
4
+ /** A project directory as an absolute real path; it must exist and be a directory on THIS machine's disk.
5
+ * The CLI runs this on the caller's machine before sending a path to a canvas that may live in the cloud. */
6
+ export function resolveExistingProjectDir(dir) {
7
+ const abs = resolvePath(dir);
8
+ if (!existsSync(abs) || !statSync(abs).isDirectory()) {
9
+ throw usage(`project directory does not exist or is not a directory: ${dir}`, {
10
+ received: dir,
11
+ next: 'Pass an existing directory path.',
12
+ });
13
+ }
14
+ try {
15
+ return realpathSync(abs);
16
+ }
17
+ catch {
18
+ return abs;
19
+ }
20
+ }
@@ -6,12 +6,7 @@ import type { ReviveResult } from '../../core/runtime/revive.js';
6
6
  import type { CloseNodeResult } from '../../core/runtime/close.js';
7
7
  import { type PushResult } from '../../core/feed/feed.js';
8
8
  import type { PageFeedback, PageFeedbackComment } from '../../core/human/feedback.js';
9
- import type { CanvasImportResult } from '../../migrations/activation.js';
10
- import type { CloseResultDTO, CronDTO, CronRunDTO, ErrorBody, NodeEdgesDTO, NodeOutcomeDTO, RunOutcomeDTO, NodeOutcomeSummaryDTO, NodePathsDTO, NodeStatusDTO, OutcomeDeliveryDTO, NodeSummaryDTO, NodeDetailDTO, NodeWorktreeDTO, ProfileDTO, ReviewCommentDTO, ReviewCommentEventDTO, ReviewDTO, FeedbackResultDTO, GraphNodeDTO, PageFeedbackCommentDTO, PageFeedbackDTO, PushReportResultDTO, ReviveResultDTO, MigrateStateDTO, SubscriptionDTO } from '../../api/index.js';
11
- export declare function toMigrateStateDTO(result: CanvasImportResult, options: {
12
- resumed: boolean;
13
- resumeError?: string;
14
- }): MigrateStateDTO;
9
+ import type { CloseResultDTO, CronDTO, CronRunDTO, ErrorBody, NodeEdgesDTO, NodeOutcomeDTO, RunOutcomeDTO, NodeOutcomeSummaryDTO, NodePathsDTO, NodeStatusDTO, OutcomeDeliveryDTO, NodeSummaryDTO, NodeDetailDTO, NodeWorktreeDTO, ProfileDTO, ReviewCommentDTO, ReviewCommentEventDTO, ReviewDTO, FeedbackResultDTO, GraphNodeDTO, PageFeedbackCommentDTO, PageFeedbackDTO, PushReportResultDTO, ReviveResultDTO, SubscriptionDTO } from '../../api/index.js';
15
10
  /** Project the list-row outcome, or null while this node remains unsettled. */
16
11
  export declare function toNodeOutcomeSummaryDTO(node: NodeRuntime): NodeOutcomeSummaryDTO | null;
17
12
  /** Project the full outcome, or null while this node remains unsettled. */
@@ -27,22 +27,6 @@ import { WorktreeError } from '../../core/worktree.js';
27
27
  import { ApiError } from '../../api/errors.js';
28
28
  import { RunError } from '../../core/runs/operations.js';
29
29
  import { ExitCode } from '../../types.js';
30
- export function toMigrateStateDTO(result, options) {
31
- const { report } = result;
32
- return {
33
- stores: report.stores.map((s) => ({ root: s.root, owner: { ...s.owner }, docs: s.docs, ...(s.skipped === undefined ? {} : { skipped: s.skipped }) })),
34
- counts: report.counts,
35
- rewrites: report.rewrites,
36
- dropped_fields: report.droppedFields,
37
- skipped: report.skipped,
38
- resolutions: report.resolutions.map((r) => ({ kind: r.kind, message: r.message, paths: r.paths })),
39
- blockers: result.blockers.map((b) => ({ kind: b.kind, message: b.message, paths: b.paths })),
40
- dryRun: result.dryRun,
41
- pending: result.pending,
42
- resumed: options.resumed,
43
- ...(options.resumeError === undefined ? {} : { resume_error: options.resumeError }),
44
- };
45
- }
46
30
  // Node projections
47
31
  /** Read the optional machine result without letting a missing or malformed sidecar obscure the durable outcome row. */
48
32
  async function readStructuredResult(nodeId) {
@@ -235,7 +235,6 @@ export const OPERATIONS = [
235
235
  { name: 'canvas.get.131', method: 'GET', path: '/v1/canvas/graph', classes: ['person', 'broker'], resource: 'canvas-read' },
236
236
  { name: 'canvas.post.132', method: 'POST', path: '/v1/canvas/prune', classes: ['person', 'broker'], resource: 'none' },
237
237
  { name: 'daemon.post.133', method: 'POST', path: '/v1/daemon/restart', classes: ['person', 'broker'], resource: 'daemon-control' },
238
- { name: 'daemon.post.134', method: 'POST', path: '/v1/daemon/migrate', classes: ['person', 'broker'], resource: 'daemon-control' },
239
238
  { name: 'daemon.drain.start', method: 'POST', path: '/v1/daemon/drain', classes: ['person'], resource: 'daemon-control' },
240
239
  { name: 'daemon.drain.end', method: 'DELETE', path: '/v1/daemon/drain', classes: ['person'], resource: 'daemon-control' },
241
240
  { name: 'daemon.post.135', method: 'POST', path: '/v1/daemon/admit', classes: ['person', 'broker'], resource: 'daemon-control' },
@@ -23,14 +23,6 @@ export interface DaemonControl {
23
23
  } | null;
24
24
  /** Admit normal work after the daemon has prepared its storage. */
25
25
  admitStartup(): Promise<DaemonAdmitDTO>;
26
- /** Plan or run the canvas import and resume normal startup when it completes. */
27
- repairMigrations(req: {
28
- dryRun: boolean;
29
- }): Promise<{
30
- result: import('../migrations/activation.js').CanvasImportResult;
31
- resumed: boolean;
32
- resumeError?: string;
33
- }>;
34
26
  }
35
27
  /** Bind this process's control surface. Called once, by `runDaemon`. */
36
28
  export declare function bindDaemonControl(control: DaemonControl): void;