@ricsam/r5d-worker 0.0.163 → 0.0.164

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.
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@ricsam/r5d-worker",
3
- "version": "0.0.163",
3
+ "version": "0.0.164",
4
4
  "type": "commonjs"
5
5
  }
@@ -20605,7 +20605,7 @@ function resolveEntrypointPath(entrypoint) {
20605
20605
  }
20606
20606
  }
20607
20607
  function getR5dctlVersion() {
20608
- if (true) return "0.0.163";
20608
+ if (true) return "0.0.164";
20609
20609
  const entrypoint = process.argv[1] ? resolveEntrypointPath(process.argv[1]) : null;
20610
20610
  let current = entrypoint ? import_node_path2.default.dirname(entrypoint) : process.cwd();
20611
20611
  for (let index = 0; index < 12; index += 1) {
package/dist/mjs/main.mjs CHANGED
@@ -7,7 +7,7 @@ import { startManagerRpc } from "./runtime/releases/rpc-main.mjs";
7
7
  import { ManagerRpcConfig } from "./runtime/releases/rpc-protocol.mjs";
8
8
  const args = process.argv.slice(2);
9
9
  if (args.includes("--version")) {
10
- console.log(`r5d-worker ${true ? "0.0.163" : "development"}`);
10
+ console.log(`r5d-worker ${true ? "0.0.164" : "development"}`);
11
11
  } else if (!args.length || args.includes("--help")) {
12
12
  console.log(
13
13
  "Usage: r5d-worker start --label <label> [--root <dir>] [--base-url <url>] [--token <worker-token>]\n r5d-worker executor /absolute/private/config.json\n r5d-worker manager /absolute/private/config.json\n\nRun independently supervised durable runtime services. Provision configuration with r5dinfra."
@@ -15,7 +15,7 @@ if (args.includes("--version")) {
15
15
  } else if (args[0] === "start") {
16
16
  const runtime = await startPersonalWorker(
17
17
  parsePersonalWorkerOptions(args.slice(1)),
18
- true ? "0.0.163" : "development"
18
+ true ? "0.0.164" : "development"
19
19
  );
20
20
  console.log(`Worker connected: ${runtime.resourceId}`);
21
21
  let closing = false;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@ricsam/r5d-worker",
3
- "version": "0.0.163",
3
+ "version": "0.0.164",
4
4
  "type": "module"
5
5
  }
@@ -22,7 +22,7 @@ import {
22
22
  gitResult,
23
23
  materializeTree,
24
24
  noSymlinkAncestors,
25
- PLATFORM_COMMIT_EMAIL,
25
+ PLATFORM_COMMIT_EMAILS,
26
26
  privateRoot,
27
27
  PROJECT_COMMIT_IDENTITY,
28
28
  readHostRegular,
@@ -1251,7 +1251,8 @@ class WorkspaceAuthority {
1251
1251
  * GitHub tip. Hydration peels them so a checkout's history is its own. */
1252
1252
  async platformSnapshot(repo, commit) {
1253
1253
  const header = (await git(repo, ["cat-file", "commit", commit])).toString("utf8").split("\n\n")[0] ?? "";
1254
- return /^committer .*<workspace@invalid>/m.test(header.replace(PLATFORM_COMMIT_EMAIL, "workspace@invalid"));
1254
+ const committer = /^committer .*<([^>]+)>/m.exec(header)?.[1];
1255
+ return committer !== void 0 && PLATFORM_COMMIT_EMAILS.includes(committer);
1255
1256
  }
1256
1257
  async firstParent(repo, commit) {
1257
1258
  const parents = (await git(repo, ["rev-list", "--parents", "-n", "1", commit])).toString("utf8").trim().split(/\s+/).slice(1);
@@ -1347,11 +1348,18 @@ class WorkspaceAuthority {
1347
1348
  const storage = await this.options.accountStorage(userId);
1348
1349
  const repositoryId = this.accountRepositoryId(userId);
1349
1350
  if (state.blocked?.code === "publication_unknown") {
1350
- const receipt = await storage.read({ method: "operation.get", lookupId: state.blocked.operationId });
1351
- if (receipt.state !== "completed" || receipt.result?.head !== state.blocked.commit)
1352
- throw new WorkspaceError("publication_unknown", "Original workspace publication not proven completed; preserve state for operator review");
1353
- state.publishedHead = state.blocked.commit;
1354
- state.head = state.blocked.commit;
1351
+ const { operationId: operationId2, commit } = state.blocked;
1352
+ const receipt = await storage.read({ method: "operation.get", lookupId: operationId2 }).catch((error) => {
1353
+ if (error instanceof WorkspaceError && error.code === "not_found") return null;
1354
+ throw error;
1355
+ });
1356
+ if (receipt?.state === "completed" && receipt.result?.head !== commit)
1357
+ throw new WorkspaceError("invalid_state", "Workspace publication receipt names another head; maintenance required");
1358
+ const published = receipt?.state === "completed" || await this.remoteHead(storage, repositoryId, OUTER_BRANCH) === commit;
1359
+ if (published) {
1360
+ state.publishedHead = commit;
1361
+ state.head = commit;
1362
+ }
1355
1363
  state.blocked = null;
1356
1364
  await this.saveOuter(state);
1357
1365
  }
@@ -1466,7 +1474,7 @@ class WorkspaceAuthority {
1466
1474
  if (error instanceof WorkspaceError && error.rejectedBeforeAdmission) {
1467
1475
  state.blocked = null;
1468
1476
  await this.saveOuter(state);
1469
- throw new WorkspaceError("mirror_advanced", "The workspace mirror advanced during publication; retried next cycle", true);
1477
+ throw error.code === "conflict" ? new WorkspaceError("mirror_advanced", "The workspace mirror advanced during publication; retried next cycle", true) : error;
1470
1478
  }
1471
1479
  throw error;
1472
1480
  }
@@ -100,7 +100,8 @@ async function durableJson(file, value) {
100
100
  await dir.close();
101
101
  }
102
102
  }
103
- const PLATFORM_COMMIT_EMAIL = "workspace@invalid";
103
+ const PLATFORM_COMMIT_EMAILS = ["workspace@invalid", "migration@r5d.dev"];
104
+ const PLATFORM_COMMIT_EMAIL = PLATFORM_COMMIT_EMAILS[0];
104
105
  const PROJECT_COMMIT_IDENTITY = {
105
106
  GIT_AUTHOR_NAME: "r5d",
106
107
  GIT_AUTHOR_EMAIL: "workspace@r5d.dev",
@@ -439,6 +440,7 @@ async function snapshotTree(repo, cwd, canonicalHead, maxBytes = 128 * 1024 * 10
439
440
  }
440
441
  export {
441
442
  PLATFORM_COMMIT_EMAIL,
443
+ PLATFORM_COMMIT_EMAILS,
442
444
  PROJECT_COMMIT_IDENTITY,
443
445
  WORKBENCH_CONFLICT_CODES,
444
446
  WORKBENCH_OPERATION_MARKERS,
@@ -26,8 +26,11 @@ export type GitOptions = {
26
26
  * the platform's: the platform identity marks snapshots that hydration peels. */
27
27
  env?: Record<string, string>;
28
28
  };
29
- /** Committer of platform-authored snapshot commits, recognised by hydration. */
30
- export declare const PLATFORM_COMMIT_EMAIL = "workspace@invalid";
29
+ /** Committers of platform-authored history that hydration peels so a checkout's
30
+ * history is its own: per-project snapshots, and the one-time legacy import
31
+ * (`scripts/migration/import-project-files.ts`) that seeded canonical storage. */
32
+ export declare const PLATFORM_COMMIT_EMAILS: readonly string[];
33
+ export declare const PLATFORM_COMMIT_EMAIL: string;
31
34
  /** Identity of commits made in a project's own history on the user's behalf. */
32
35
  export declare const PROJECT_COMMIT_IDENTITY: {
33
36
  readonly GIT_AUTHOR_NAME: "r5d";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ricsam/r5d-worker",
3
- "version": "0.0.163",
3
+ "version": "0.0.164",
4
4
  "type": "module",
5
5
  "main": "./dist/mjs/main.mjs",
6
6
  "module": "./dist/mjs/main.mjs",
@@ -21,7 +21,7 @@
21
21
  "r5d-worker": "dist/mjs/main.mjs"
22
22
  },
23
23
  "dependencies": {
24
- "@ricsam/r5d-api": "^0.0.163",
24
+ "@ricsam/r5d-api": "^0.0.164",
25
25
  "node-pty": "1.1.0",
26
26
  "zod": "^4.1.13",
27
27
  "picomatch": "^4.0.3"