@quantiya/codevibe-core 2.0.83 → 2.0.85

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.
@@ -9,6 +9,14 @@ export interface WorkspaceMaterializerSession {
9
9
  copyFile(source: string, destination: string, maxLogicalBytes?: number): Promise<MaterializedFileMetadata>;
10
10
  hashDestinationFile(destination: string, maxBytes: number): Promise<MaterializedFileMetadata>;
11
11
  relocateDestinationRoot(authority: WorkspaceRootAuthority): Promise<void>;
12
+ /**
13
+ * §5.3 (macOS): clone every listed regular file of one directory with a single `cp -c`, so each later
14
+ * `copyFile` for those names publishes and verifies a prepared clone instead of spawning `cp` itself. Returns how
15
+ * many were prepared; 0 (not darwin, forced physical, or the volume refused) leaves the per-file path unchanged.
16
+ */
17
+ prepareDarwinClones(relativeDir: string, names: readonly string[]): Promise<number>;
18
+ /** Remove any staging this directory still holds. MUST run after the directory's files, success or failure. */
19
+ finishDarwinClones(relativeDir: string): Promise<void>;
12
20
  close(): Promise<void>;
13
21
  }
14
22
  export interface WorkspaceFileHashSession {
@@ -26,6 +34,12 @@ export interface WorkspaceMaterializerOptions {
26
34
  priorPhysicalCopyBytes?: number;
27
35
  maxFileBytes: number;
28
36
  maxTotalBytes: number;
37
+ /**
38
+ * Upper bound on a `hashDestinationFile` read. Separate from `maxTotalBytes`, which bounds PHYSICAL copy bytes:
39
+ * they shared one value, so §5.6's free-space budget — which can be smaller than a tracked file's hashing limit
40
+ * on a nearly full disk — rejected every hash request. Omitted, the shipped coupling is kept.
41
+ */
42
+ maxHashBytes?: number;
29
43
  helperTimeoutMs?: number;
30
44
  forcePhysicalCopy?: boolean;
31
45
  testHangStage?: (source: string) => MaterializationHangStage | undefined;
@@ -33,6 +47,22 @@ export interface WorkspaceMaterializerOptions {
33
47
  releasePhysicalBytes?: (bytes: number) => Promise<void> | void;
34
48
  beforePhysicalCopy?: (source: string) => Promise<void>;
35
49
  onPhysicalCopyBytes?: (totalBytes: number) => Promise<void>;
50
+ /**
51
+ * P63 SB-45: the physical-copy ledger shared by every lane of a {@link createWorkspaceMaterializerPool}. Absent, the
52
+ * session keeps its own, exactly as before.
53
+ */
54
+ sharedPhysicalAccounting?: SharedPhysicalAccounting;
55
+ }
56
+ /**
57
+ * The physical bytes every lane of one snapshot has committed, plus those reserved by copies still in flight. One
58
+ * object per snapshot; JavaScript runs each reservation's check-and-add without yielding, so concurrent lanes can
59
+ * never jointly exceed `maxTotalBytes` — each helper only sees the total as of its own request.
60
+ */
61
+ export interface SharedPhysicalAccounting {
62
+ committed: number;
63
+ inflight: number;
64
+ /** Serializes `onPhysicalCopyBytes` (the durable owner anchor): each write records the CURRENT total. */
65
+ report: Promise<void>;
36
66
  }
37
67
  /**
38
68
  * One bounded helper owns all live-workspace clone/read waits for a snapshot.
@@ -40,6 +70,28 @@ export interface WorkspaceMaterializerOptions {
40
70
  * physical fallback only after the helper reports the exact stable file size.
41
71
  */
42
72
  export declare function createWorkspaceMaterializerSession(opts: WorkspaceMaterializerOptions): WorkspaceMaterializerSession;
73
+ /**
74
+ * P63 SB-45: several identity-bound helpers for ONE snapshot, so per-file work runs in parallel. Each lane is an
75
+ * ordinary {@link WorkspaceMaterializerSession} — the same helper, the same per-file checks, one request at a time —
76
+ * and the lanes share one physical-copy ledger ({@link SharedPhysicalAccounting}). A caller binds work that
77
+ * shares helper state to one lane: a directory's batch clones are prepared, adopted and finished by the same lane.
78
+ * Lanes start lazily, so a small folder starts only the lanes it uses.
79
+ */
80
+ export interface WorkspaceMaterializerPool {
81
+ readonly lanes: readonly WorkspaceMaterializerSession[];
82
+ /** Relocate every lane (after atomic exposure renames the destination root). */
83
+ relocateDestinationRoot(authority: WorkspaceRootAuthority): Promise<void>;
84
+ /**
85
+ * Run `work` for each item on the lanes, at most one request per lane at a time; at most `lanesFor(items)` lanes
86
+ * are used. Rejects with the first failure only after every started item has settled, so no helper request is
87
+ * still running when the caller closes the pool.
88
+ */
89
+ forEach<T>(items: readonly T[], work: (lane: WorkspaceMaterializerSession, item: T) => Promise<void>): Promise<void>;
90
+ close(): Promise<void>;
91
+ }
92
+ /** Items per lane before another lane is worth its helper start (~50 ms each). */
93
+ export declare const MATERIALIZER_ITEMS_PER_LANE = 256;
94
+ export declare function createWorkspaceMaterializerPool(opts: WorkspaceMaterializerOptions, laneCount: number): WorkspaceMaterializerPool;
43
95
  /**
44
96
  * Reuse one identity-bound helper for a full snapshot scan. This retains the
45
97
  * same per-file path/inode/hash checks as `anchoredHashFileWithinRoot` without
@@ -3,7 +3,7 @@ import { type ProcessCleanupOwner } from './process-tree';
3
3
  import { type WorkspaceRootAuthority } from './workspace-authority';
4
4
  import { ReviewedShadowDiffFile, ShadowDiffFile, ShadowEnv, ShadowPromoteState, TrackBranchSpec, UnresolvedBundlePublicationRetention } from './shadow-protocol';
5
5
  import { RecoveredShadow } from './shadow-recovery';
6
- export { MAX_TRACKED_FILE_LOGICAL_BYTES, MAX_TRACKED_WORKSPACE_LOGICAL_BYTES, MAX_TRACKED_FILE_COUNT, MAX_TRACKED_PATH_BYTES, MAX_REVIEW_FILE_BYTES, MAX_PROMOTION_PREIMAGE_AGGREGATE_BYTES, MAX_STATE_MARKER_BYTES, DEFAULT_SHADOW_TTL_MS, } from './shadow-protocol';
6
+ export { MAX_CHANGE_SET_FILE_COUNT, MAX_CHANGE_SET_PATH_BYTES, MAX_TRACKED_FILE_LOGICAL_BYTES, MAX_TRACKED_WORKSPACE_LOGICAL_BYTES, MAX_TRACKED_FILE_COUNT, MAX_TRACKED_PATH_BYTES, MAX_REVIEW_FILE_BYTES, MAX_PROMOTION_PREIMAGE_AGGREGATE_BYTES, MAX_STATE_MARKER_BYTES, DEFAULT_SHADOW_TTL_MS, } from './shadow-protocol';
7
7
  export type { ShadowChangeKind, ShadowDiffFile, ReviewedShadowDiffFile, CasHelperCrashStage, UnresolvedBundlePublicationRetention, ShadowEnv, TrackBranchSpec, } from './shadow-protocol';
8
8
  export { listRecoverableShadows, reconcileShadowPublicationAuthority, listShadowCleanupResidue, assertPathCollectionBounds, } from './shadow-recovery';
9
9
  export type { RecoveredShadow, ShadowCleanupResidue } from './shadow-recovery';
@@ -56,6 +56,22 @@ export declare class WorkspaceShadow {
56
56
  private readonly stateFileWriteAdmissions;
57
57
  private exposureFileAuthority?;
58
58
  private stateResourcesRetiredInProcess;
59
+ /** §5.2/§5.6: where this instance's immutable baseline lives when it is too large to inline. */
60
+ private baselineRecord?;
61
+ /** Stage 2 R1-F1: baseline paths set since the shards were written — persisted as `baselineDelta`. */
62
+ private readonly baselineSetAfterRecord;
63
+ /**
64
+ * §7.1: each copy file's stat tuple, recorded at create before the agent ran. Absent for a reopened or
65
+ * recovered instance — capture then hashes every file, exactly as before.
66
+ */
67
+ private copyStatTable?;
68
+ /** §7.4: the user's own changes to their folder since the start record, from the last capture. */
69
+ userFolderChanges?: import('./shadow-start-record').FolderChangesSinceStart;
70
+ /**
71
+ * §7.4: count the user's own edits to their folder since the task started. Reviewers see this in Slice 2's review
72
+ * INDEX; Slice 1 records it and writes it to the task log. Never fails a capture: the count is information.
73
+ */
74
+ private recordUserFolderChanges;
59
75
  private readonly env;
60
76
  private readonly maxStateMarkerBytes;
61
77
  private promotedInProcess;
@@ -271,6 +287,12 @@ export declare class WorkspaceShadow {
271
287
  * retries may consume it, but no marker writer may replace it.
272
288
  */
273
289
  private beginDisposal;
290
+ /**
291
+ * Stage 2 R1-F1: the baseline entries the immutable shards do not hold — paths set after they were written, by this
292
+ * instance or (after a reopen) by an earlier one, as the existing marker's delta records. Every marker writer
293
+ * persists it; `undefined` when there are no shards or nothing was added.
294
+ */
295
+ private baselineDeltaFor;
274
296
  private writeStateMarker;
275
297
  private readStateMarker;
276
298
  private readStateMarkerSnapshot;