@ricsam/r5d-worker 0.0.165 → 0.0.166

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.165",
3
+ "version": "0.0.166",
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.165";
20608
+ if (true) return "0.0.166";
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.165" : "development"}`);
10
+ console.log(`r5d-worker ${true ? "0.0.166" : "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.165" : "development"
18
+ true ? "0.0.166" : "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.165",
3
+ "version": "0.0.166",
4
4
  "type": "module"
5
5
  }
@@ -146,24 +146,22 @@ class OuterRepository {
146
146
  async snapshot(inners, options = {}) {
147
147
  const limit = options.limitBytes ?? OUTER_SNAPSHOT_LIMIT_BYTES;
148
148
  await this.seed(inners);
149
- const dependencies = nulSplit(
150
- await this.run(["ls-files", "--others", "--exclude-standard", "--directory", "-z", "--", ":(glob)**/node_modules/**"])
151
- );
152
- if (dependencies.length && !options.allowLargeDiff)
153
- throw new OuterSnapshotRefusal("too_large", "An unignored dependency tree exceeds the automatic publication limit", dependencies.slice(0, MAX_REPORTED_PATHS));
154
149
  const others = nulSplit(await this.run(["ls-files", "--others", "--exclude-standard", "-z"]));
155
150
  const foreign = others.filter((file) => file.endsWith("/")).map((file) => file.slice(0, -1));
151
+ const collapsed = nulSplit(await this.run(["ls-files", "--others", "--exclude-standard", "--directory", "-z"])).filter((entry) => entry.endsWith("/") && !foreign.includes(entry.slice(0, -1)));
152
+ const attribute = (paths) => [...new Set(paths.map((file) => collapsed.find((directory) => file.startsWith(directory)) ?? file))].slice(0, MAX_REPORTED_PATHS);
156
153
  const tracked = /* @__PURE__ */ new Map();
154
+ const trackedOf = async (inner) => {
155
+ let set = tracked.get(inner.root);
156
+ if (!set) tracked.set(inner.root, set = await inner.tracked());
157
+ return set;
158
+ };
157
159
  let unexplainedBytes = 0;
158
160
  const unexplainedPaths = [];
159
161
  for (const file of others) {
160
162
  if (file.endsWith("/")) continue;
161
163
  const inner = inners.find((candidate) => withinRoot(file, candidate.root));
162
- if (inner) {
163
- let set = tracked.get(inner.root);
164
- if (!set) tracked.set(inner.root, set = await inner.tracked());
165
- if (set.has(file.slice(inner.root.length + 1))) continue;
166
- }
164
+ if (inner && (await trackedOf(inner)).has(file.slice(inner.root.length + 1))) continue;
167
165
  const stat = await fs.lstat(path.join(this.workTree, file)).catch((error) => {
168
166
  if (error.code === "ENOENT" || error.code === "ENOTDIR") return null;
169
167
  throw error;
@@ -175,7 +173,7 @@ class OuterRepository {
175
173
  throw new OuterSnapshotRefusal(
176
174
  "too_large",
177
175
  `Unexplained workspace content exceeds the ${limit}-byte automatic publication limit`,
178
- unexplainedPaths.slice(0, MAX_REPORTED_PATHS)
176
+ attribute(unexplainedPaths)
179
177
  );
180
178
  }
181
179
  for (const file of unexplainedPaths) {
@@ -192,9 +190,40 @@ class OuterRepository {
192
190
  }
193
191
  await this.run(["add", "-A", "--", ".", ...foreign.map((directory) => `:(exclude,literal)${directory}`)]);
194
192
  await this.stripUnsupported();
193
+ await this.evictIgnored(inners, trackedOf);
195
194
  const tree = GitOid.parse((await this.run(["write-tree"])).toString("utf8").trim());
196
195
  return { tree, unexplainedBytes, unexplainedPaths };
197
196
  }
197
+ /** Under a checkout the outer tree holds exactly what the checkout tracks plus
198
+ * what it shows as untracked-and-not-ignored. Staging never drops a tracked
199
+ * file that has since become ignored — npm's cache, published by a cycle that
200
+ * raced `npm install` while it was still under the limit, then excluded by a
201
+ * restored `.gitignore` — so such files are removed from the index here. The
202
+ * working tree is untouched; a fixed ignore file simply cleans what was
203
+ * published. The seeding invariant holds: a checkout never loses its last
204
+ * outer entry. */
205
+ async evictIgnored(inners, trackedOf) {
206
+ const cached = nulSplit(await this.run(["ls-files", "--cached", "-z"]));
207
+ const tracked = /* @__PURE__ */ new Map(), untracked = /* @__PURE__ */ new Map();
208
+ for (const file of cached) {
209
+ const inner = inners.find((candidate) => withinRoot(file, candidate.root));
210
+ if (!inner) continue;
211
+ if ((await trackedOf(inner)).has(file.slice(inner.root.length + 1))) tracked.set(inner.root, (tracked.get(inner.root) ?? 0) + 1);
212
+ else untracked.set(inner.root, [...untracked.get(inner.root) ?? [], file]);
213
+ }
214
+ const paths = [...untracked.values()].flat();
215
+ if (!paths.length) return;
216
+ const { code, stdout } = await this.result(["check-ignore", "--no-index", "-z", "--stdin"], `${paths.join("\0")}\0`);
217
+ if (code !== 0 && code !== 1) throw new WorkspaceError("git_failed", "Outer repository ignore rules are unreadable");
218
+ const ignored = new Set(nulSplit(stdout));
219
+ const removals = [];
220
+ for (const [root, files] of untracked) {
221
+ const drop = files.filter((file) => ignored.has(file));
222
+ const survivors = (tracked.get(root) ?? 0) + files.length - drop.length;
223
+ removals.push(...survivors ? drop : drop.sort().slice(1));
224
+ }
225
+ if (removals.length) await this.run(["update-index", "--force-remove", "-z", "--stdin"], `${removals.join("\0")}\0`);
226
+ }
198
227
  /** Staging records a symlink as a link entry, and a nested repository that
199
228
  * appeared between the walk and the add as a gitlink. Neither can be
200
229
  * materialized on another host; both are dropped from the index without
@@ -75,6 +75,15 @@ export declare class OuterRepository {
75
75
  allowLargeDiff?: boolean;
76
76
  limitBytes?: number;
77
77
  }): Promise<OuterSnapshot>;
78
+ /** Under a checkout the outer tree holds exactly what the checkout tracks plus
79
+ * what it shows as untracked-and-not-ignored. Staging never drops a tracked
80
+ * file that has since become ignored — npm's cache, published by a cycle that
81
+ * raced `npm install` while it was still under the limit, then excluded by a
82
+ * restored `.gitignore` — so such files are removed from the index here. The
83
+ * working tree is untouched; a fixed ignore file simply cleans what was
84
+ * published. The seeding invariant holds: a checkout never loses its last
85
+ * outer entry. */
86
+ private evictIgnored;
78
87
  /** Staging records a symlink as a link entry, and a nested repository that
79
88
  * appeared between the walk and the add as a gitlink. Neither can be
80
89
  * materialized on another host; both are dropped from the index without
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ricsam/r5d-worker",
3
- "version": "0.0.165",
3
+ "version": "0.0.166",
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.165",
24
+ "@ricsam/r5d-api": "^0.0.166",
25
25
  "node-pty": "1.1.0",
26
26
  "zod": "^4.1.13",
27
27
  "picomatch": "^4.0.3"