@amalgm/shell 0.1.164-main.41917702222 → 0.1.164-main.41930044808

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.
@@ -0,0 +1,33 @@
1
+ /** A walk's captured rows and how one root's rows are saved: each observed
2
+ * and shared row replaces what its inventory held (`install.rows`). */
3
+ import type { CloudEntityRecord, UserGroundIdentity } from "@amalgm/live";
4
+ import type { GroundOwner, InstalledRows } from "./ground-install-saves.js";
5
+ import type { GroundRow } from "./ground-row.js";
6
+ import { type Saved } from "./ground-saver.js";
7
+ import type { SourceProof } from "./source-proof.js";
8
+ export interface CapturedRow {
9
+ readonly record: CloudEntityRecord;
10
+ readonly relativePath: string;
11
+ readonly absolutePath: string;
12
+ readonly physicalKey: string;
13
+ readonly sourceSignature: string | null;
14
+ readonly filesystemMode: number;
15
+ readonly sighting: string | null;
16
+ }
17
+ /** Retained sharing metadata is not a new physical capture. */
18
+ export type PublicationRow = Omit<CapturedRow, "filesystemMode"> & Pick<GroundRow, "filesystemMode">;
19
+ export declare function capturedGroundRow(resourceId: string, rootUUID: string, row: PublicationRow): GroundRow;
20
+ /** One root's observed and shared rows, each replacing what its inventory
21
+ * held before; sharing stands as it was when nothing was selected. A source
22
+ * proof's semantic phase has already answered; its physical phase closes as
23
+ * the save posts. Rows built ahead of a fact they rely on commit only once
24
+ * `after` holds (ground-saver.ts). */
25
+ export declare function persistRows(file: string, identity: UserGroundIdentity, resourceId: string, rootUUID: string, rows: {
26
+ readonly observed: readonly CapturedRow[];
27
+ readonly shared: readonly PublicationRow[] | null;
28
+ }, previousRows?: readonly Pick<GroundRow, "uuid" | "rootUUID" | "resourceId">[], options?: {
29
+ readonly source?: SourceProof;
30
+ readonly verified?: InstalledRows["verified"];
31
+ readonly after?: Promise<unknown>;
32
+ }): Promise<Saved<void>>;
33
+ export declare const groundOwner: ({ userId, userEmail, deviceId }: UserGroundIdentity) => GroundOwner;
@@ -0,0 +1,43 @@
1
+ import { closePhysicallyOffThread } from "./content-capture-pool.js";
2
+ import { save } from "./ground-saver.js";
3
+ export function capturedGroundRow(resourceId, rootUUID, row) {
4
+ return {
5
+ resourceId,
6
+ rootUUID,
7
+ uuid: row.record.uuid,
8
+ type: row.record.type,
9
+ parentUUID: row.record.parentUUID,
10
+ name: row.record.name,
11
+ status: "active",
12
+ version: row.record.version,
13
+ payloadVersion: row.record.payloadVersion,
14
+ transportVersion: row.record.transportVersion,
15
+ relativePath: row.relativePath,
16
+ absolutePath: row.absolutePath,
17
+ physicalKey: row.physicalKey,
18
+ sourceSignature: row.sourceSignature,
19
+ filesystemMode: row.filesystemMode,
20
+ sighting: row.sighting,
21
+ };
22
+ }
23
+ /** One root's observed and shared rows, each replacing what its inventory
24
+ * held before; sharing stands as it was when nothing was selected. A source
25
+ * proof's semantic phase has already answered; its physical phase closes as
26
+ * the save posts. Rows built ahead of a fact they rely on commit only once
27
+ * `after` holds (ground-saver.ts). */
28
+ export async function persistRows(file, identity, resourceId, rootUUID, rows, previousRows = [], options = {}) {
29
+ if (options.source)
30
+ await closePhysicallyOffThread(options.source, "complete");
31
+ return save(file, "install.rows", {
32
+ owner: groundOwner(identity),
33
+ resourceId,
34
+ rows: {
35
+ observed: rows.observed.map(row => capturedGroundRow(resourceId, rootUUID, row)),
36
+ shared: rows.shared && rows.shared.map(row => capturedGroundRow(resourceId, rootUUID, row)),
37
+ },
38
+ previous: previousRows.map(({ uuid, rootUUID: root, resourceId: held }) => ({ uuid, rootUUID: root, resourceId: held })),
39
+ ...(options.verified ? { verified: options.verified } : {}),
40
+ }, options.after ? { after: options.after } : {});
41
+ }
42
+ export const groundOwner = ({ userId, userEmail, deviceId }) => ({ userId, userEmail, deviceId });
43
+ //# sourceMappingURL=captured-rows.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"captured-rows.js","sourceRoot":"","sources":["../src/captured-rows.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAA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,iBAAiB,CAAC,UAAU,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC;YAChF,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC,iBAAiB,CAAC,UAAU,EAAE,QAAQ,EAAE,GAAG,CAAC,CAAC;SAC5F;QACD,QAAQ,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,CAAC,CAAC;QACxH,GAAG,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC5D,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AACpD,CAAC;AAED,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAsB,EAAe,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,CAAC,CAAC"}
@@ -0,0 +1,186 @@
1
+ import { Refusal, type DetectionBatchPlan, type SuspicionSnapshot, type UserGroundIdentity } from "@amalgm/live";
2
+ import { type CapturedRow, type PublicationRow } from "../captured-rows.js";
3
+ import { type ContentStamp } from "../content-clock.js";
4
+ import { type GitMarker } from "../git/marker.js";
5
+ import { type GroundRow } from "../ground-row.js";
6
+ import { RegisterUploadFusion } from "../register-upload-fusion.js";
7
+ import { type SourceProof } from "../source-proof.js";
8
+ import { type ApplyOwnershipBlocker } from "./apply-ownership.js";
9
+ import { GroundSourceProof, type GroundObservationProof } from "./ground-proof.js";
10
+ import { readSharingPolicy } from "./sharing-policy.js";
11
+ import { type UnavailableRoot } from "./unreadable.js";
12
+ import { type Withheld } from "./withheld.js";
13
+ export interface MutableScanEvidence {
14
+ entries: number;
15
+ metadataReused: number;
16
+ contentReads: number;
17
+ gitInspections: number;
18
+ repositoryCaptures: number;
19
+ walkMs: number;
20
+ captureMs: number;
21
+ captureBusyMs: number;
22
+ captureBytes: number;
23
+ gitMs: number;
24
+ reconcileMs: number;
25
+ persistMs: number;
26
+ selection?: string;
27
+ }
28
+ /** A bound root standing on another device than the one it was bound on:
29
+ * its drive is unplugged, renumbered, or another is mounted there. As with an
30
+ * absent root, nothing of it is read or published. No timer retries it;
31
+ * later suspicion, or Register adopting the directory, asks again, and the
32
+ * original returning is caught up whole. */
33
+ export declare class RootOffDevice extends Refusal {
34
+ constructor(rootPath: string);
35
+ }
36
+ /** A root this process may not even look at, because a directory above it
37
+ * hides its entries. Like a binding the pass could not follow, it is unread
38
+ * ground, never absent: nothing of it is read or published, the domain's
39
+ * absence decisions wait for it, and access returning is heard. */
40
+ export declare class RootUnreachable extends Error {
41
+ readonly root: UnavailableRoot;
42
+ constructor(root: UnavailableRoot);
43
+ }
44
+ /** A bound root re-created on its device is the same workspace, compared
45
+ * whole: a walk that read less than a complete examination located owes
46
+ * its complete examination. */
47
+ export declare class RootRecreated extends Error {
48
+ constructor(rootPath: string);
49
+ }
50
+ /** What one examined root hands unit admission. */
51
+ export interface RootUnitEvidence {
52
+ /** The walk's retained sources, closed once outside SQLite. */
53
+ readonly walk: GroundSourceProof;
54
+ /** Identities whose collection did not complete, with why. */
55
+ readonly failed: ReadonlyMap<string, Withheld>;
56
+ /** Selection withheld a result for a cross-entity reason. */
57
+ readonly whole: boolean;
58
+ /** Proofs every unit of this root depends on: sharing policy and ownership. */
59
+ readonly rootProofs: readonly SourceProof[];
60
+ /** The sharing policy text this walk selected under; admission closes on it. */
61
+ readonly policy: string;
62
+ /** Regular files the walk read, by physical key. */
63
+ readonly physicalReads: ReadonlySet<string>;
64
+ /** Ground this walk could not read, by absolute address: a directory hides
65
+ * every entry beneath it, a leaf only its own bytes. */
66
+ readonly unread: ReadonlyMap<string, {
67
+ readonly reason: string;
68
+ readonly directory: boolean;
69
+ }>;
70
+ /** Unfinished Apply operations whose cones this walk left unread. */
71
+ readonly owners: readonly ApplyOwnershipBlocker[];
72
+ /** Why this walk's namespace cannot close, when it cannot: a directory it
73
+ * could not list, or listings no stamp can qualify. */
74
+ readonly namespace: string | null;
75
+ }
76
+ export interface RootObservationInput {
77
+ identity: UserGroundIdentity;
78
+ resourceId: string;
79
+ rootUUID: string;
80
+ rootName: string;
81
+ rootPath: string;
82
+ rootType: "workspace" | "folder" | "repo.git";
83
+ /** The `.git` observation that classified this root, when one did. */
84
+ rootMarker?: GitMarker | null;
85
+ rootParentUUID?: string | null;
86
+ database: string;
87
+ cacheDir: string;
88
+ bindingDir: string;
89
+ /** The content clock of the walk's root, stamped before the caller read
90
+ * the rows it hands in. */
91
+ stamp: ContentStamp;
92
+ suspects?: readonly string[] | null;
93
+ /** Drain and abandon collection if its scheduler requests foreground service. */
94
+ checkpoint?: () => void;
95
+ suspicion?: SuspicionSnapshot;
96
+ existingRows?: readonly GroundRow[];
97
+ /** Complete admitted predecessor, never a source of physical identity. */
98
+ sharingRows?: readonly GroundRow[];
99
+ /** Every deliberate binding remains a selectable UUID boundary, while only
100
+ * the outermost binding owns a physical scan. */
101
+ registeredBoundaries?: ReadonlyMap<string, string>;
102
+ evidence?: MutableScanEvidence;
103
+ /** Timing every syscall is itself work. Count cheap facts always, but take
104
+ * per-leg clocks only while a caller is actively reading trace evidence. */
105
+ measureEvidence?: boolean;
106
+ /** Whether this scan's consumer mints per-entity Send records. Only then
107
+ * does the walk select against sharing's admitted predecessor, stage cache
108
+ * bytes and build detection replays. Otherwise it is a declaration, a first
109
+ * login's or Register's: it selects from nothing, and its one complete
110
+ * snapshot reads ground at upload. */
111
+ plansSendRecords: boolean;
112
+ /** Register's walk of one declaration root, with nothing persisted here.
113
+ * The declaration commit admits both inventories beside its journal row. */
114
+ declaring?: boolean;
115
+ /** Workspaces declared but not yet published by Register. A reference to
116
+ * one is part of that declaration, so this scan never selects it. */
117
+ heldDeclarations?: ReadonlySet<string>;
118
+ /** Fused upload rail for a declaring walk: selected non-repository
119
+ * captures ship their bytes from the walk's own read. */
120
+ fusion?: RegisterUploadFusion;
121
+ /** The caller admits in independent units: evidence that moves while one
122
+ * identity is read fails that identity, never the root. Its lanes are rung,
123
+ * so a repository whose Git writer is still at work waits for the ring its
124
+ * lock's release makes, or for Git's longest lock wait to end
125
+ * (repository-state.ts); a cold journey reads through, as Git's own readers
126
+ * do, and its witnesses judge the moment. */
127
+ units?: boolean;
128
+ /** The root's sharing policy, when the caller already read it. */
129
+ policy?: ReturnType<typeof readSharingPolicy>;
130
+ /** Whether a complete examination of the root's present object located
131
+ * this scope (a pooled one), rather than Watch's names. */
132
+ pooled?: boolean;
133
+ /** A root examined only along Watch's names: the walk follows them, and every other row it holds is context, carried as
134
+ * last known and selected exactly as B holds it. */
135
+ folders?: boolean;
136
+ /** A folder scope's tops a pooled examination found vacant, relative to
137
+ * the root, each framed by its own rows alone: one that holds an object
138
+ * again is ground its frame cannot answer. */
139
+ vacant?: readonly string[];
140
+ /** A folder scope's proved returns, relative to the root, each a container
141
+ * on the way (scope-frame.ts answered): its own row observed, its members
142
+ * carried but where a name reaches. */
143
+ answered?: readonly string[];
144
+ /** Asked of each resolved identity the scope does not hold, context apart,
145
+ * before anything is built: both addresses of one that crossed the
146
+ * scope's edge. Any crossing ends the scan unbuilt, since its result could
147
+ * not be admitted. */
148
+ crossing?: (found: Pick<GroundRow, "uuid" | "physicalKey" | "absolutePath">, holds: (uuid: string) => boolean) => readonly string[];
149
+ }
150
+ type RootObservation = {
151
+ readonly kind: "unexamined";
152
+ } | {
153
+ readonly kind: "crossed";
154
+ readonly addresses: readonly string[];
155
+ } | {
156
+ readonly kind: "observed";
157
+ readonly rows: readonly PublicationRow[];
158
+ readonly observedRows: readonly CapturedRow[];
159
+ readonly sourceProof: GroundObservationProof;
160
+ readonly transferable: boolean;
161
+ /** Why this root's result cannot travel yet. A refusal is Git's own stable
162
+ * answer about the ground; anything else is a fault owed a retry. */
163
+ readonly transferFailure: {
164
+ readonly reason: string;
165
+ readonly refused: boolean;
166
+ } | null;
167
+ readonly detection: DetectionBatchPlan | null;
168
+ readonly trashedRows: readonly GroundRow[];
169
+ readonly units: RootUnitEvidence;
170
+ /** A folder scope's context: facts for its results, never results. */
171
+ readonly context: ReadonlySet<string>;
172
+ /** The O rows this observation re-decided, and the active ones among them
173
+ * no observed entry claimed. */
174
+ readonly examined: readonly Pick<GroundRow, "uuid">[];
175
+ readonly absent: readonly string[];
176
+ /** The retained identities observed entries proved returned, as stored;
177
+ * the ones back where they stood, which a reveal shows; and each revealed
178
+ * top with the rows beneath it still absent (ground-store.ts reveal). */
179
+ readonly returned: ReadonlyMap<string, GroundRow>;
180
+ readonly revealed: ReadonlyMap<string, GroundRow>;
181
+ readonly reveals: ReadonlyMap<string, readonly string[]>;
182
+ };
183
+ /** One walk of a root. What its reads staged is named together once the walk
184
+ * needs the names, or removed when the walk ends first (cargo-group.ts). */
185
+ export declare function observeRoot(input: RootObservationInput): Promise<RootObservation>;
186
+ export {};