@claudexor/workspace 4.8.2 → 5.0.1

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 (136) hide show
  1. package/dist/anchor-store.d.ts +20 -9
  2. package/dist/anchor-store.d.ts.map +1 -1
  3. package/dist/anchor-store.js +89 -14
  4. package/dist/anchor-store.js.map +1 -1
  5. package/dist/capture-failure.d.ts.map +1 -1
  6. package/dist/capture-failure.js +7 -2
  7. package/dist/capture-failure.js.map +1 -1
  8. package/dist/capture-inventory.d.ts +10 -0
  9. package/dist/capture-inventory.d.ts.map +1 -0
  10. package/dist/capture-inventory.js +63 -0
  11. package/dist/capture-inventory.js.map +1 -0
  12. package/dist/capture-objects.d.ts +32 -0
  13. package/dist/capture-objects.d.ts.map +1 -0
  14. package/dist/capture-objects.js +129 -0
  15. package/dist/capture-objects.js.map +1 -0
  16. package/dist/cleanup-fault.d.ts +18 -0
  17. package/dist/cleanup-fault.d.ts.map +1 -0
  18. package/dist/cleanup-fault.js +45 -0
  19. package/dist/cleanup-fault.js.map +1 -0
  20. package/dist/continuation-evidence.d.ts +61 -15
  21. package/dist/continuation-evidence.d.ts.map +1 -1
  22. package/dist/continuation-evidence.js +151 -36
  23. package/dist/continuation-evidence.js.map +1 -1
  24. package/dist/continuation-facts.d.ts +93 -0
  25. package/dist/continuation-facts.d.ts.map +1 -0
  26. package/dist/continuation-facts.js +162 -0
  27. package/dist/continuation-facts.js.map +1 -0
  28. package/dist/directory-workspace.d.ts.map +1 -1
  29. package/dist/directory-workspace.js +1 -3
  30. package/dist/directory-workspace.js.map +1 -1
  31. package/dist/files-io.d.ts.map +1 -1
  32. package/dist/files-io.js +1 -7
  33. package/dist/files-io.js.map +1 -1
  34. package/dist/fs-presence.d.ts +12 -0
  35. package/dist/fs-presence.d.ts.map +1 -0
  36. package/dist/fs-presence.js +35 -0
  37. package/dist/fs-presence.js.map +1 -0
  38. package/dist/git-nested-repositories.d.ts.map +1 -1
  39. package/dist/git-nested-repositories.js +11 -2
  40. package/dist/git-nested-repositories.js.map +1 -1
  41. package/dist/git-observed.d.ts +75 -0
  42. package/dist/git-observed.d.ts.map +1 -0
  43. package/dist/git-observed.js +172 -0
  44. package/dist/git-observed.js.map +1 -0
  45. package/dist/git-result.d.ts +36 -0
  46. package/dist/git-result.d.ts.map +1 -0
  47. package/dist/git-result.js +96 -0
  48. package/dist/git-result.js.map +1 -0
  49. package/dist/git-run.d.ts +11 -0
  50. package/dist/git-run.d.ts.map +1 -1
  51. package/dist/git-run.js +24 -0
  52. package/dist/git-run.js.map +1 -1
  53. package/dist/git-snapshot.d.ts +40 -0
  54. package/dist/git-snapshot.d.ts.map +1 -0
  55. package/dist/git-snapshot.js +238 -0
  56. package/dist/git-snapshot.js.map +1 -0
  57. package/dist/git-transient-capture.d.ts +63 -16
  58. package/dist/git-transient-capture.d.ts.map +1 -1
  59. package/dist/git-transient-capture.js +170 -57
  60. package/dist/git-transient-capture.js.map +1 -1
  61. package/dist/git.d.ts +46 -21
  62. package/dist/git.d.ts.map +1 -1
  63. package/dist/git.js +164 -103
  64. package/dist/git.js.map +1 -1
  65. package/dist/index.d.ts +9 -1
  66. package/dist/index.d.ts.map +1 -1
  67. package/dist/index.js +9 -1
  68. package/dist/index.js.map +1 -1
  69. package/dist/lanes.d.ts +2 -1
  70. package/dist/lanes.d.ts.map +1 -1
  71. package/dist/lanes.js +7 -6
  72. package/dist/lanes.js.map +1 -1
  73. package/dist/manager.d.ts +21 -7
  74. package/dist/manager.d.ts.map +1 -1
  75. package/dist/manager.js +30 -17
  76. package/dist/manager.js.map +1 -1
  77. package/dist/object-compose.d.ts +58 -0
  78. package/dist/object-compose.d.ts.map +1 -0
  79. package/dist/object-compose.js +444 -0
  80. package/dist/object-compose.js.map +1 -0
  81. package/dist/object-materialize.d.ts +52 -0
  82. package/dist/object-materialize.d.ts.map +1 -0
  83. package/dist/object-materialize.js +467 -0
  84. package/dist/object-materialize.js.map +1 -0
  85. package/dist/object-occupied.d.ts +27 -0
  86. package/dist/object-occupied.d.ts.map +1 -0
  87. package/dist/object-occupied.js +131 -0
  88. package/dist/object-occupied.js.map +1 -0
  89. package/dist/object-revert.d.ts +45 -0
  90. package/dist/object-revert.d.ts.map +1 -0
  91. package/dist/object-revert.js +265 -0
  92. package/dist/object-revert.js.map +1 -0
  93. package/dist/object-saved-files.d.ts +50 -0
  94. package/dist/object-saved-files.d.ts.map +1 -0
  95. package/dist/object-saved-files.js +176 -0
  96. package/dist/object-saved-files.js.map +1 -0
  97. package/dist/object-sparse.d.ts +22 -0
  98. package/dist/object-sparse.d.ts.map +1 -0
  99. package/dist/object-sparse.js +72 -0
  100. package/dist/object-sparse.js.map +1 -0
  101. package/dist/object-store-leases.d.ts +41 -0
  102. package/dist/object-store-leases.d.ts.map +1 -0
  103. package/dist/object-store-leases.js +277 -0
  104. package/dist/object-store-leases.js.map +1 -0
  105. package/dist/object-store-roots.d.ts +25 -0
  106. package/dist/object-store-roots.d.ts.map +1 -0
  107. package/dist/object-store-roots.js +114 -0
  108. package/dist/object-store-roots.js.map +1 -0
  109. package/dist/object-store.d.ts +110 -0
  110. package/dist/object-store.d.ts.map +1 -0
  111. package/dist/object-store.js +404 -0
  112. package/dist/object-store.js.map +1 -0
  113. package/dist/object-transfer.d.ts +41 -0
  114. package/dist/object-transfer.d.ts.map +1 -0
  115. package/dist/object-transfer.js +267 -0
  116. package/dist/object-transfer.js.map +1 -0
  117. package/dist/plain-diff-capture.d.ts +1 -2
  118. package/dist/plain-diff-capture.d.ts.map +1 -1
  119. package/dist/plain-diff-capture.js +2 -7
  120. package/dist/plain-diff-capture.js.map +1 -1
  121. package/dist/plain-diff.d.ts +0 -4
  122. package/dist/plain-diff.d.ts.map +1 -1
  123. package/dist/plain-diff.js +2 -44
  124. package/dist/plain-diff.js.map +1 -1
  125. package/dist/raw-patch.d.ts.map +1 -1
  126. package/dist/raw-patch.js +5 -8
  127. package/dist/raw-patch.js.map +1 -1
  128. package/dist/run-expiry.d.ts +3 -0
  129. package/dist/run-expiry.d.ts.map +1 -0
  130. package/dist/run-expiry.js +15 -0
  131. package/dist/run-expiry.js.map +1 -0
  132. package/dist/thread-tree.d.ts +36 -2
  133. package/dist/thread-tree.d.ts.map +1 -1
  134. package/dist/thread-tree.js +87 -11
  135. package/dist/thread-tree.js.map +1 -1
  136. package/package.json +5 -5
@@ -0,0 +1,110 @@
1
+ import type { GitDeliveryPair, GitObjectFormat } from "@claudexor/schema";
2
+ import { type ObjectEndpoint, type TransferResult } from "./object-transfer.js";
3
+ /**
4
+ * The project object store (D): one private bare repository per project under
5
+ * Claudexor's runtime directory. It is NEVER an alternate of the user's
6
+ * repository; user-repo operations import exactly the objects they need first.
7
+ * Objects enter after capture and after delivery and are verified against the
8
+ * store alone. Retention prunes by reachability from recorded roots.
9
+ */
10
+ export declare function objectStorePath(projectRoot: string): string;
11
+ export { beginPendingRoots, endPendingRoots, type PendingRoots } from "./object-store-leases.js";
12
+ /** Git sees the store alone: no alternates, no repository discovery, no locks on reads. */
13
+ export declare function storeEnv(store: string): Record<string, string>;
14
+ export declare function storeEndpoint(store: string): ObjectEndpoint;
15
+ /** The user's repository as a transfer endpoint (its own object directory). */
16
+ export declare function repositoryEndpoint(repo: string): Promise<ObjectEndpoint>;
17
+ /**
18
+ * One store serves all of a project's execution roots, so one project keeps one
19
+ * Git object format: a repository of the other one is refused, typed and naming
20
+ * both, before any of its objects, or a store of its format, is made or mounted.
21
+ */
22
+ export declare function assertProjectObjectFormat(projectRoot: string, format: GitObjectFormat): Promise<void>;
23
+ export declare function ensureObjectStore(projectRoot: string, objectFormat?: GitObjectFormat): Promise<{
24
+ store: string;
25
+ objectFormat: GitObjectFormat;
26
+ }>;
27
+ export { liveRootRecords, writeRootRecord } from "./object-store-roots.js";
28
+ /** The newest delivery pair kept under `owner` whose post-tree is `postTree` (see retainedPairOf). */
29
+ export declare function retainedDeliveryPair(projectRoot: string, owner: string, postTree: string): GitDeliveryPair | null;
30
+ export interface RetainResult extends TransferResult {
31
+ store: string;
32
+ objects: number;
33
+ /** The durable root record now owning these objects. */
34
+ rootRecord: string;
35
+ }
36
+ /**
37
+ * Copy what a result needs beyond its boundary into the project store, verify
38
+ * it against the store alone, then record its roots durably under `owner`. A
39
+ * pending record covers the import itself (two-flag protocol with prune).
40
+ */
41
+ export declare function retainInObjectStore(input: {
42
+ projectRoot: string;
43
+ source: ObjectEndpoint;
44
+ roots: string[];
45
+ boundary: {
46
+ commit: string;
47
+ tree: string;
48
+ } | null;
49
+ objectFormat: GitObjectFormat;
50
+ /** Path whose existence keeps these roots live (a run or thread directory). */
51
+ owner: string;
52
+ /** The delivery pair these roots keep, recorded for a later replay. */
53
+ pair?: GitDeliveryPair;
54
+ }): Promise<RetainResult>;
55
+ export interface RepositoryImport extends TransferResult {
56
+ /** Objects neither the user's repository nor the project store holds. */
57
+ missing: string[];
58
+ /** The store keeps objects of another format than the repository's: it was not read. */
59
+ formatMismatch?: {
60
+ kept: GitObjectFormat;
61
+ repository: GitObjectFormat;
62
+ };
63
+ }
64
+ /** Objects a read-only check cannot reach through `endpoint`: missing roots, else
65
+ * what a traversal from them reports missing (nothing is imported). */
66
+ export declare function unreachableObjects(endpoint: ObjectEndpoint, roots: readonly string[]): Promise<string[]>;
67
+ /**
68
+ * D(1): before a traversal, the start objects are checked with `cat-file --batch-check`;
69
+ * a missing one is imported from the store (rev-list cannot start from a missing
70
+ * object). The traversal then reports missing interior objects, imported the
71
+ * same way, round by round, until none is left or neither side has them.
72
+ */
73
+ export declare function importIntoRepository(input: {
74
+ projectRoot: string;
75
+ repo: string;
76
+ roots: string[];
77
+ }): Promise<RepositoryImport>;
78
+ /** Unreferenced store objects younger than this are never pruned. */
79
+ export declare const OBJECT_STORE_GRACE_MS: number;
80
+ /** Retention's entry: prune one project runtime directory's store, if it has one.
81
+ * `retiredOwners`: run directories this pass retires (a dry run included). */
82
+ export declare function pruneProjectObjectStore(runtimeDir: string, options: {
83
+ dryRun: boolean;
84
+ graceMs?: number;
85
+ retiredOwners?: ReadonlySet<string>;
86
+ }): Promise<{
87
+ freedBytes: number;
88
+ yielded: boolean;
89
+ }>;
90
+ /**
91
+ * Prune the store by reachability: keep everything reachable from `roots` plus
92
+ * live pending records, and everything younger than `graceMs`. Packs whose
93
+ * objects are all unreachable and old are removed; mixed old packs are
94
+ * rewritten with their kept objects. Returns the bytes freed. A pass that finds
95
+ * a live import yields without deleting anything.
96
+ */
97
+ export declare function pruneObjectStore(input: {
98
+ store: string;
99
+ /** Extra live roots beyond the store's own live root records. */
100
+ roots?: readonly string[];
101
+ graceMs: number;
102
+ dryRun?: boolean;
103
+ objectFormat: GitObjectFormat;
104
+ /** Owners retired by the calling retention pass (see liveRootRecords). */
105
+ retiredOwners?: ReadonlySet<string>;
106
+ }): Promise<{
107
+ freedBytes: number;
108
+ yielded: boolean;
109
+ }>;
110
+ //# sourceMappingURL=object-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object-store.d.ts","sourceRoot":"","sources":["../src/object-store.ts"],"names":[],"mappings":"AAaA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAa1E,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,cAAc,EACpB,MAAM,sBAAsB,CAAC;AAE9B;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAE3D;AAED,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,KAAK,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAIjG,2FAA2F;AAC3F,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAO9D;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,cAAc,CAE3D;AAED,+EAA+E;AAC/E,wBAAsB,kBAAkB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC,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ync, rmSync, rmdirSync, statSync, unlinkSync, } from "node:fs";
2
+ import { dirname, join } from "node:path";
3
+ import { randomUUID } from "node:crypto";
4
+ import { setImmediate as nextTurn } from "node:timers/promises";
5
+ import { WorkspaceError } from "@claudexor/core";
6
+ import { projectRuntimeDir } from "@claudexor/util";
7
+ import { gitObserved, GitOperationError } from "./git-observed.js";
8
+ import { repositoryObjectFormat, repositoryObjectFormatOrNull } from "./git-result.js";
9
+ import { liveRootRecords, retainedPairOf, writeRootRecord } from "./object-store-roots.js";
10
+ import { acquirePruneLock, beginPendingRoots, controlDir, endPendingRoots, livePendingRecords, } from "./object-store-leases.js";
11
+ import { missingObjects, packIndexObjectIds, transferObjects, } from "./object-transfer.js";
12
+ /**
13
+ * The project object store (D): one private bare repository per project under
14
+ * Claudexor's runtime directory. It is NEVER an alternate of the user's
15
+ * repository; user-repo operations import exactly the objects they need first.
16
+ * Objects enter after capture and after delivery and are verified against the
17
+ * store alone. Retention prunes by reachability from recorded roots.
18
+ */
19
+ export function objectStorePath(projectRoot) {
20
+ return join(projectRuntimeDir(projectRoot), "git-store");
21
+ }
22
+ export { beginPendingRoots, endPendingRoots } from "./object-store-leases.js";
23
+ const HASH_LENGTH = { sha1: 20, sha256: 32 };
24
+ /** Git sees the store alone: no alternates, no repository discovery, no locks on reads. */
25
+ export function storeEnv(store) {
26
+ return {
27
+ GIT_DIR: store,
28
+ GIT_OBJECT_DIRECTORY: join(store, "objects"),
29
+ GIT_ALTERNATE_OBJECT_DIRECTORIES: "",
30
+ GIT_OPTIONAL_LOCKS: "0",
31
+ };
32
+ }
33
+ export function storeEndpoint(store) {
34
+ return { cwd: store, env: storeEnv(store), objectsDir: join(store, "objects") };
35
+ }
36
+ /** The user's repository as a transfer endpoint (its own object directory). */
37
+ export async function repositoryEndpoint(repo) {
38
+ const objects = await gitObserved(repo, ["rev-parse", "--path-format=absolute", "--git-path", "objects"], { label: "rev-parse objects" });
39
+ return { cwd: repo, env: { GIT_OPTIONAL_LOCKS: "0" }, objectsDir: objects.stdout.trim() };
40
+ }
41
+ /** One in-flight initialization per store in this process. */
42
+ const initializing = new Map();
43
+ /** Initialize atomically: a complete store appears by one rename, so concurrent
44
+ * captures (a best-of-n wave, another process) never see a half-made store. */
45
+ async function initializeStore(store, format) {
46
+ mkdirSync(dirname(store), { recursive: true, mode: 0o700 });
47
+ const temp = `${store}.init-${process.pid}-${randomUUID()}`;
48
+ try {
49
+ await gitObserved(dirname(store), [
50
+ "init",
51
+ "--bare",
52
+ "--quiet",
53
+ "--template=",
54
+ ...(format === "sha256" ? ["--object-format=sha256"] : []),
55
+ temp,
56
+ ], {
57
+ env: {
58
+ GIT_DIR: null,
59
+ GIT_OBJECT_DIRECTORY: null,
60
+ GIT_INDEX_FILE: null,
61
+ GIT_WORK_TREE: null,
62
+ },
63
+ label: "init object store",
64
+ });
65
+ // The store is only ever pruned by Claudexor's reachability pass.
66
+ await gitObserved(temp, ["config", "gc.auto", "0"], { env: storeEnv(temp), label: "config" });
67
+ for (const name of ["pending", "tmp", "roots"])
68
+ mkdirSync(controlDir(temp, name), { recursive: true });
69
+ try {
70
+ renameSync(temp, store);
71
+ }
72
+ catch (error) {
73
+ const code = error.code;
74
+ if (code !== "EEXIST" && code !== "ENOTEMPTY")
75
+ throw error;
76
+ }
77
+ }
78
+ finally {
79
+ rmSync(temp, { recursive: true, force: true });
80
+ }
81
+ }
82
+ /** The object format a project keeps: its store's, else its own repository's;
83
+ * null for a project in no Git repository that has no store yet. */
84
+ async function projectObjectFormat(projectRoot) {
85
+ const store = objectStorePath(projectRoot);
86
+ if (existsSync(join(store, "objects")) && existsSync(join(store, "HEAD")))
87
+ return repositoryObjectFormat(store, storeEnv(store));
88
+ return repositoryObjectFormatOrNull(projectRoot);
89
+ }
90
+ const formatRefusal = (projectRoot, kept, format) => `this repository uses ${format} Git objects, but project ${projectRoot} keeps ${kept} objects (one project keeps one object format); refused before anything was written`;
91
+ /**
92
+ * One store serves all of a project's execution roots, so one project keeps one
93
+ * Git object format: a repository of the other one is refused, typed and naming
94
+ * both, before any of its objects, or a store of its format, is made or mounted.
95
+ */
96
+ export async function assertProjectObjectFormat(projectRoot, format) {
97
+ const kept = await projectObjectFormat(projectRoot);
98
+ if (kept !== null && kept !== format)
99
+ throw new GitOperationError("capture_failed", formatRefusal(projectRoot, kept, format));
100
+ }
101
+ export async function ensureObjectStore(projectRoot, objectFormat) {
102
+ const store = objectStorePath(projectRoot);
103
+ const format = objectFormat ?? (await repositoryObjectFormat(projectRoot));
104
+ if (!existsSync(join(store, "objects")) || !existsSync(join(store, "HEAD"))) {
105
+ // A store takes its project's format, never one a foreign repository brings.
106
+ await assertProjectObjectFormat(projectRoot, format);
107
+ const pending = initializing.get(store) ?? initializeStore(store, format);
108
+ initializing.set(store, pending);
109
+ try {
110
+ await pending;
111
+ }
112
+ finally {
113
+ if (initializing.get(store) === pending)
114
+ initializing.delete(store);
115
+ }
116
+ }
117
+ if (existsSync(join(store, "objects", "info", "alternates")))
118
+ throw new WorkspaceError(`object store ${store} has alternates; refusing to use it`);
119
+ const stored = await repositoryObjectFormat(store, storeEnv(store));
120
+ if (stored !== format)
121
+ throw new GitOperationError("capture_failed", formatRefusal(projectRoot, stored, format));
122
+ for (const name of ["pending", "tmp", "roots"])
123
+ mkdirSync(controlDir(store, name), { recursive: true });
124
+ return { store, objectFormat: format };
125
+ }
126
+ export { liveRootRecords, writeRootRecord } from "./object-store-roots.js";
127
+ /** The newest delivery pair kept under `owner` whose post-tree is `postTree` (see retainedPairOf). */
128
+ export function retainedDeliveryPair(projectRoot, owner, postTree) {
129
+ return retainedPairOf(objectStorePath(projectRoot), owner, postTree);
130
+ }
131
+ /** Objects reachable from `roots` minus the boundary commit and its tree, listed in a source. */
132
+ async function closureBeyond(source, roots, boundary) {
133
+ if (roots.length === 0)
134
+ return [];
135
+ // A negative commit stops commit walks; a negative tree excludes its contents
136
+ // even for a bare-tree start (rev-list marks a lone `--not <commit>` tree only
137
+ // through walked commits).
138
+ const args = [
139
+ "rev-list",
140
+ "--objects",
141
+ ...roots,
142
+ ...(boundary ? ["--not", boundary.commit, boundary.tree] : []),
143
+ ];
144
+ const listed = await gitObserved(source.cwd, args, {
145
+ env: source.env,
146
+ label: "rev-list --objects",
147
+ });
148
+ return [
149
+ ...new Set(listed.stdout
150
+ .split("\n")
151
+ .map((line) => line.split(" ")[0])
152
+ .filter(Boolean)),
153
+ ];
154
+ }
155
+ /**
156
+ * Copy what a result needs beyond its boundary into the project store, verify
157
+ * it against the store alone, then record its roots durably under `owner`. A
158
+ * pending record covers the import itself (two-flag protocol with prune).
159
+ */
160
+ export async function retainInObjectStore(input) {
161
+ const { store } = await ensureObjectStore(input.projectRoot, input.objectFormat);
162
+ const pending = await beginPendingRoots(store, input.roots);
163
+ try {
164
+ const needed = await closureBeyond(input.source, input.roots, input.boundary);
165
+ const target = storeEndpoint(store);
166
+ const transfer = await transferObjects(input.source, target, needed, HASH_LENGTH[input.objectFormat]);
167
+ const absent = await missingObjects(target, needed);
168
+ if (absent.length > 0) {
169
+ throw new GitOperationError("capture_object_missing", `${absent.length} object(s) did not reach the project store (first ${absent[0]})`);
170
+ }
171
+ const rootRecord = writeRootRecord(store, input.owner, input.roots, input.pair);
172
+ return { ...transfer, store, objects: needed.length, rootRecord };
173
+ }
174
+ finally {
175
+ endPendingRoots(pending);
176
+ }
177
+ }
178
+ /** Interior objects a traversal from present roots reports missing (`?oid`). */
179
+ async function missingInterior(endpoint, roots) {
180
+ if (roots.length === 0)
181
+ return [];
182
+ const listed = await gitObserved(endpoint.cwd, ["rev-list", "--objects", "--no-walk", "--missing=print", ...roots], { env: endpoint.env, label: "rev-list --missing=print" });
183
+ return listed.stdout
184
+ .split("\n")
185
+ .filter((line) => line.startsWith("?"))
186
+ .map((line) => line.slice(1).trim());
187
+ }
188
+ /** Objects a read-only check cannot reach through `endpoint`: missing roots, else
189
+ * what a traversal from them reports missing (nothing is imported). */
190
+ export async function unreachableObjects(endpoint, roots) {
191
+ const absent = await missingObjects(endpoint, roots);
192
+ return absent.length > 0 ? absent : missingInterior(endpoint, roots);
193
+ }
194
+ /**
195
+ * D(1): before a traversal, the start objects are checked with `cat-file --batch-check`;
196
+ * a missing one is imported from the store (rev-list cannot start from a missing
197
+ * object). The traversal then reports missing interior objects, imported the
198
+ * same way, round by round, until none is left or neither side has them.
199
+ */
200
+ export async function importIntoRepository(input) {
201
+ const user = await repositoryEndpoint(input.repo);
202
+ const format = await repositoryObjectFormat(input.repo);
203
+ const storePath = objectStorePath(input.projectRoot);
204
+ const kept = existsSync(join(storePath, "objects"))
205
+ ? await repositoryObjectFormat(storePath, storeEnv(storePath))
206
+ : null;
207
+ // A store of the other format is never read into this repository.
208
+ const store = kept === format ? storeEndpoint(storePath) : null;
209
+ const total = {
210
+ linkedPacks: 0,
211
+ linkedLoose: 0,
212
+ streamedObjects: 0,
213
+ copiedBytes: 0,
214
+ missing: [],
215
+ ...(kept && kept !== format ? { formatMismatch: { kept, repository: format } } : {}),
216
+ };
217
+ const unavailable = new Set();
218
+ const roots = [...new Set(input.roots)];
219
+ let wanted = await missingObjects(user, roots);
220
+ // Each round imports what the last traversal reported; a missing tree hides
221
+ // its children until it arrives, so depth bounds the rounds.
222
+ for (let round = 0; round < 1024; round += 1) {
223
+ if (wanted.length > 0) {
224
+ const absentInStore = store ? new Set(await missingObjects(store, wanted)) : new Set(wanted);
225
+ const fromStore = wanted.filter((oid) => !absentInStore.has(oid));
226
+ for (const oid of absentInStore)
227
+ unavailable.add(oid);
228
+ if (store && fromStore.length > 0) {
229
+ const moved = await transferObjects(store, user, fromStore, HASH_LENGTH[format]);
230
+ total.linkedPacks += moved.linkedPacks;
231
+ total.linkedLoose += moved.linkedLoose;
232
+ total.streamedObjects += moved.streamedObjects;
233
+ total.copiedBytes += moved.copiedBytes;
234
+ }
235
+ }
236
+ const starts = roots.filter((oid) => !unavailable.has(oid));
237
+ const interior = (await missingInterior(user, starts)).filter((oid) => !unavailable.has(oid));
238
+ if (interior.length === 0)
239
+ break;
240
+ wanted = interior;
241
+ }
242
+ total.missing = [...unavailable].sort();
243
+ return total;
244
+ }
245
+ /** Unreferenced store objects younger than this are never pruned. */
246
+ export const OBJECT_STORE_GRACE_MS = 60 * 60 * 1000;
247
+ /** The walk over loose objects gives the event loop a turn this often. */
248
+ const PRUNE_ENTRIES_PER_TURN = 2_048;
249
+ /** Retention's entry: prune one project runtime directory's store, if it has one.
250
+ * `retiredOwners`: run directories this pass retires (a dry run included). */
251
+ export async function pruneProjectObjectStore(runtimeDir, options) {
252
+ const store = join(runtimeDir, "git-store");
253
+ if (!existsSync(join(store, "objects")))
254
+ return { freedBytes: 0, yielded: false };
255
+ return pruneObjectStore({
256
+ store,
257
+ graceMs: options.graceMs ?? OBJECT_STORE_GRACE_MS,
258
+ dryRun: options.dryRun,
259
+ objectFormat: await repositoryObjectFormat(store, storeEnv(store)),
260
+ ...(options.retiredOwners ? { retiredOwners: options.retiredOwners } : {}),
261
+ });
262
+ }
263
+ /** Plain-file mtime of an object's container (its loose file or its pack). */
264
+ function containerAge(path) {
265
+ try {
266
+ return statSync(path).mtimeMs;
267
+ }
268
+ catch {
269
+ return Date.now();
270
+ }
271
+ }
272
+ /**
273
+ * Prune the store by reachability: keep everything reachable from `roots` plus
274
+ * live pending records, and everything younger than `graceMs`. Packs whose
275
+ * objects are all unreachable and old are removed; mixed old packs are
276
+ * rewritten with their kept objects. Returns the bytes freed. A pass that finds
277
+ * a live import yields without deleting anything.
278
+ */
279
+ export async function pruneObjectStore(input) {
280
+ const { store } = input;
281
+ if (!existsSync(join(store, "objects")))
282
+ return { freedBytes: 0, yielded: false };
283
+ const hold = acquirePruneLock(store);
284
+ if (!hold)
285
+ return { freedBytes: 0, yielded: true };
286
+ try {
287
+ // Any live import may rely on an old object it found present: yield.
288
+ if (livePendingRecords(store, input.graceMs).length > 0)
289
+ return { freedBytes: 0, yielded: true };
290
+ const endpoint = storeEndpoint(store);
291
+ const roots = [
292
+ ...new Set([
293
+ ...(input.roots ?? []),
294
+ ...liveRootRecords(store, input.dryRun, input.retiredOwners),
295
+ ]),
296
+ ];
297
+ const absentRoots = new Set(await missingObjects(endpoint, roots));
298
+ const starts = roots.filter((oid) => !absentRoots.has(oid));
299
+ const live = new Set();
300
+ if (starts.length > 0) {
301
+ const listed = await gitObserved(store, ["rev-list", "--objects", "--no-walk", "--missing=allow-any", ...starts], { env: endpoint.env, label: "rev-list reachable" });
302
+ for (const line of listed.stdout.split("\n"))
303
+ if (line)
304
+ live.add(line.split(" ")[0]);
305
+ }
306
+ const cutoff = Date.now() - input.graceMs;
307
+ let freedBytes = 0;
308
+ const objectsDir = join(store, "objects");
309
+ // A lock lost to a reaper (this process was judged stale) deletes nothing more.
310
+ if (!hold.stillHeld())
311
+ return { freedBytes: 0, yielded: true };
312
+ // Private scratch (staged locks, repacks) an interrupted process left behind.
313
+ if (!input.dryRun)
314
+ for (const name of readdirSync(controlDir(store, "tmp")))
315
+ if (containerAge(join(controlDir(store, "tmp"), name)) < cutoff)
316
+ rmSync(join(controlDir(store, "tmp"), name), { recursive: true, force: true });
317
+ let walked = 0;
318
+ for (const fan of readdirSync(objectsDir)) {
319
+ if (fan.startsWith("tmp_") && containerAge(join(objectsDir, fan)) < cutoff) {
320
+ // Publication staging an interrupted transfer left behind.
321
+ if (!input.dryRun)
322
+ rmSync(join(objectsDir, fan), { recursive: true, force: true });
323
+ continue;
324
+ }
325
+ if (!/^[0-9a-f]{2}$/.test(fan))
326
+ continue;
327
+ for (const rest of readdirSync(join(objectsDir, fan))) {
328
+ walked += 1;
329
+ if (walked % PRUNE_ENTRIES_PER_TURN === 0) {
330
+ await nextTurn();
331
+ if (!hold.stillHeld())
332
+ return { freedBytes, yielded: true };
333
+ }
334
+ const oid = fan + rest;
335
+ const path = join(objectsDir, fan, rest);
336
+ if (live.has(oid) || containerAge(path) >= cutoff)
337
+ continue;
338
+ freedBytes += statSync(path).size;
339
+ if (!input.dryRun)
340
+ unlinkSync(path);
341
+ }
342
+ if (!input.dryRun) {
343
+ try {
344
+ rmdirSync(join(objectsDir, fan));
345
+ }
346
+ catch {
347
+ // Not empty.
348
+ }
349
+ }
350
+ }
351
+ const packDir = join(objectsDir, "pack");
352
+ for (const name of existsSync(packDir) ? readdirSync(packDir) : []) {
353
+ if (!name.endsWith(".idx"))
354
+ continue;
355
+ const idx = join(packDir, name);
356
+ const pack = idx.slice(0, -4) + ".pack";
357
+ if (!existsSync(pack) || containerAge(pack) >= cutoff)
358
+ continue;
359
+ const members = packIndexObjectIds(idx, HASH_LENGTH[input.objectFormat]);
360
+ const kept = members.filter((oid) => live.has(oid));
361
+ if (kept.length === members.length)
362
+ continue;
363
+ const size = statSync(pack).size + statSync(idx).size;
364
+ if (input.dryRun) {
365
+ freedBytes += kept.length === 0 ? size : 0;
366
+ continue;
367
+ }
368
+ // The kept objects stream into a fresh pack before the old one goes.
369
+ if (kept.length > 0)
370
+ await repackKept(store, endpoint, kept, input.objectFormat);
371
+ if (!hold.stillHeld())
372
+ return { freedBytes, yielded: true };
373
+ unlinkSync(idx);
374
+ unlinkSync(pack);
375
+ freedBytes += size;
376
+ }
377
+ return { freedBytes, yielded: false };
378
+ }
379
+ finally {
380
+ hold.release();
381
+ }
382
+ }
383
+ async function repackKept(store, endpoint, kept, objectFormat) {
384
+ // A staging directory that sees no store objects, so every kept object is
385
+ // streamed (bounded memory) into one new pack, renamed into place (.idx last).
386
+ const scratch = join(controlDir(store, "tmp"), `repack-${randomUUID()}`);
387
+ mkdirSync(join(scratch, "objects", "pack"), { recursive: true });
388
+ try {
389
+ const staging = {
390
+ cwd: store,
391
+ env: { ...storeEnv(store), GIT_OBJECT_DIRECTORY: join(scratch, "objects") },
392
+ objectsDir: join(scratch, "objects"),
393
+ };
394
+ await transferObjects(endpoint, staging, kept, HASH_LENGTH[objectFormat]);
395
+ const names = readdirSync(join(scratch, "objects", "pack"));
396
+ for (const suffix of [".pack", ".idx"])
397
+ for (const name of names.filter((entry) => entry.endsWith(suffix)))
398
+ renameSync(join(scratch, "objects", "pack", name), join(endpoint.objectsDir, "pack", name));
399
+ }
400
+ finally {
401
+ rmSync(scratch, { recursive: true, force: true });
402
+ }
403
+ }
404
+ //# sourceMappingURL=object-store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object-store.js","sourceRoot":"","sources":["../src/object-store.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,WAAW,EACX,UAAU,EACV,MAAM,EACN,SAAS,EACT,QAAQ,EACR,UAAU,GACX,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,YAAY,IAAI,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAEhE,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,sBAAsB,EAAE,4BAA4B,EAAE,MAAM,iBAAiB,CAAC;AACvF,OAAO,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC3F,OAAO,EACL,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,eAAe,EACf,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,cAAc,EACd,kBAAkB,EAClB,eAAe,GAGhB,MAAM,sBAAsB,CAAC;AAE9B;;;;;;GAMG;AACH,MAAM,UAAU,eAAe,CAAC,WAAmB;IACjD,OAAO,IAAI,CAAC,iBAAiB,CAAC,WAAW,CAAC,EAAE,WAAW,CAAC,CAAC;AAC3D,CAAC;AAED,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAqB,MAAM,0BAA0B,CAAC;AAEjG,MAAM,WAAW,G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EAAE,GAAG,QAAQ,CAAC,KAAK,CAAC,EAAE,oBAAoB,EAAE,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,EAAE;YAC3E,UAAU,EAAE,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC;SACrC,CAAC;QACF,MAAM,eAAe,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,WAAW,CAAC,YAAY,CAAC,CAAC,CAAC;QAC1E,MAAM,KAAK,GAAG,WAAW,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,CAAC,CAAC,CAAC;QAC5D,KAAK,MAAM,MAAM,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC;YACpC,KAAK,MAAM,IAAI,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;gBAChE,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC,CAAC;IAClG,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IACpD,CAAC;AACH,CAAC"}
@@ -0,0 +1,41 @@
1
+ /** One object database end of a transfer: where its objects live and how Git reads them. */
2
+ export interface ObjectEndpoint {
3
+ /** Directory Git commands run in (a worktree, a bare store or a scratch repo). */
4
+ cwd: string;
5
+ /** Environment that makes Git see exactly this endpoint's objects. */
6
+ env: Record<string, string>;
7
+ /** The object directory files are linked into or read from. */
8
+ objectsDir: string;
9
+ }
10
+ export declare function looseObjectPath(objectsDir: string, oid: string): string;
11
+ /** Object ids of a version-2 pack index, read in bounded chunks (no whole-file read). */
12
+ export declare function packIndexObjectIds(idxPath: string, hashLength: 20 | 32): string[];
13
+ /** Bytes free for an unprivileged writer on the filesystem holding `path`;
14
+ * null when the platform or filesystem cannot report it (free space unknown). */
15
+ export declare function availableBytes(path: string): number | null;
16
+ /** On-disk sizes of the given objects at an endpoint (missing objects count zero). */
17
+ export declare function objectDiskSizes(endpoint: ObjectEndpoint, oids: readonly string[]): Promise<Map<string, number>>;
18
+ /** The subset of `oids` an endpoint lacks (its own objects plus any alternates its env names). */
19
+ export declare function missingObjects(endpoint: ObjectEndpoint, oids: readonly string[]): Promise<string[]>;
20
+ /** Refuse before writing when the destination cannot hold what is about to be
21
+ * copied. Unknown free space refuses nothing: a write that then runs out of
22
+ * space still ends as the same typed refusal (see typedSpaceFailure). */
23
+ export declare function assertSpaceFor(destinationDir: string, requiredBytes: number, label: string): void;
24
+ export interface TransferResult {
25
+ linkedPacks: number;
26
+ linkedLoose: number;
27
+ streamedObjects: number;
28
+ copiedBytes: number;
29
+ }
30
+ /**
31
+ * Make every object of `oids` present in `to`. Whole source packs whose objects
32
+ * are all wanted are adopted by hard link on one filesystem; wanted loose
33
+ * objects are linked; the rest are streamed as one self-contained pack (no
34
+ * deltas, big-blob streaming on both sides), so no child holds a large blob in
35
+ * memory and no JS string ever holds object bytes. A streamed pack is staged
36
+ * inside the destination object directory (`tmp_*`, which Git's own prune
37
+ * reclaims after a crash), so its publication is a same-filesystem rename even
38
+ * when the source lives on another volume.
39
+ */
40
+ export declare function transferObjects(from: ObjectEndpoint, to: ObjectEndpoint, oids: readonly string[], hashLength: 20 | 32): Promise<TransferResult>;
41
+ //# sourceMappingURL=object-transfer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"object-transfer.d.ts","sourceRoot":"","sources":["../src/object-transfer.ts"],"names":[],"mappings":"AAkBA,4FAA4F;AAC5F,MAAM,WAAW,cAAc;IAC7B,kFAAkF;IAClF,GAAG,EAAE,MAAM,CAAC;IACZ,sEAAsE;IACtE,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC5B,+DAA+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