@amalgm/shell 0.1.43 → 0.1.45
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.
- package/PURPOSE.md +20 -16
- package/dist/detection/journal-codec.d.ts +3 -0
- package/dist/detection/journal-codec.js +34 -0
- package/dist/detection/journal-codec.js.map +1 -0
- package/dist/{detection-host.d.ts → detection/portable.d.ts} +19 -1
- package/dist/{detection-host.js → detection/portable.js} +32 -4
- package/dist/detection/portable.js.map +1 -0
- package/dist/detection/runtime.d.ts +58 -0
- package/dist/detection/runtime.js +669 -0
- package/dist/detection/runtime.js.map +1 -0
- package/dist/user-ground-host.d.ts +12 -2
- package/dist/user-ground-host.js +431 -149
- package/dist/user-ground-host.js.map +1 -1
- package/package.json +3 -3
- package/dist/detection-host.js.map +0 -1
package/PURPOSE.md
CHANGED
|
@@ -303,9 +303,11 @@ shell only assembles.
|
|
|
303
303
|
unrelated coverage. The portable registry head remains one atomic graph.
|
|
304
304
|
|
|
305
305
|
35. **Portable path grammar becomes a native path only at the host boundary.**
|
|
306
|
-
Core and Live
|
|
307
|
-
|
|
308
|
-
|
|
306
|
+
Core and Live describe path components with `/`; Shell performs portable
|
|
307
|
+
parent and name operations with that grammar, preserving `\\` as a literal
|
|
308
|
+
character, and only then resolves those components with the host platform's
|
|
309
|
+
path semantics for a filesystem effect. Durable records never rewrite or
|
|
310
|
+
mix separators accidentally.
|
|
309
311
|
|
|
310
312
|
36. **Git materialization reproduces Card bytes independently of machine
|
|
311
313
|
preferences.** A repository created by Add disables receiver-global line
|
|
@@ -340,7 +342,7 @@ shell only assembles.
|
|
|
340
342
|
|
|
341
343
|
42. **Record commits evidence before Watch settles.** The host reconciles a
|
|
342
344
|
Watch generation against one last-verified detection notebook, writes the
|
|
343
|
-
exact portable Detect proposals into the
|
|
345
|
+
exact portable Detect proposals into the one mutation journal, and
|
|
344
346
|
advances that notebook in the same SQLite transaction. The materialized
|
|
345
347
|
`entities` table contains only ground present on this machine; the notebook
|
|
346
348
|
may retain the UUID and last verified evidence for missing ground so an
|
|
@@ -354,18 +356,20 @@ shell only assembles.
|
|
|
354
356
|
43. **One Detect job proves one finite Watch generation.** A scheduled pass or
|
|
355
357
|
explicit flush observes and settles only the generations it froze before
|
|
356
358
|
reading truth. A ring received during that read remains pending and owns a
|
|
357
|
-
later
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
359
|
+
later bounded pass, even when its timer fires while the older generation
|
|
360
|
+
is still observing; no caller waits for the operating system
|
|
361
|
+
to become globally silent. This keeps duplicate or continuous native
|
|
362
|
+
callbacks from making an otherwise complete Record operation unbounded
|
|
363
|
+
without dropping any suspicion.
|
|
364
|
+
|
|
365
|
+
44. **Named Detect is independent of workspace size.** Shell holds one
|
|
366
|
+
prepared SQLite owner for the live Detect runtime. A named path uses one
|
|
367
|
+
indexed row, its parent chain, one stat, changed bytes when required, and
|
|
368
|
+
one transaction. Structural work widens only to the affected subtree;
|
|
369
|
+
repository work widens only to its Card + Checkpoint territory. Nameless,
|
|
370
|
+
invalid, startup, and failed-coverage evidence alone may enter complete
|
|
371
|
+
reconciliation. No named Detect pass serializes a workspace snapshot or
|
|
372
|
+
enters Send; the exact journal row is its terminal output.
|
|
369
373
|
|
|
370
374
|
## Relationship to amalgm-engine
|
|
371
375
|
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** Byte-exact JSON codec for the one durable mutation journal. */
|
|
2
|
+
import { stableJson } from "@amalgm/live";
|
|
3
|
+
const BYTES = "$amalgmBytesBase64";
|
|
4
|
+
const encodeValue = (value) => {
|
|
5
|
+
if (value instanceof Uint8Array) {
|
|
6
|
+
return { [BYTES]: Buffer.from(value).toString("base64") };
|
|
7
|
+
}
|
|
8
|
+
if (Array.isArray(value))
|
|
9
|
+
return value.map(encodeValue);
|
|
10
|
+
if (value && typeof value === "object") {
|
|
11
|
+
return Object.fromEntries(Object.entries(value).map(([key, child]) => [key, encodeValue(child)]));
|
|
12
|
+
}
|
|
13
|
+
return value;
|
|
14
|
+
};
|
|
15
|
+
const decodeValue = (value) => {
|
|
16
|
+
if (Array.isArray(value))
|
|
17
|
+
return value.map(decodeValue);
|
|
18
|
+
if (value && typeof value === "object") {
|
|
19
|
+
const object = value;
|
|
20
|
+
if (Object.keys(object).length === 1 && typeof object[BYTES] === "string") {
|
|
21
|
+
const encoded = object[BYTES];
|
|
22
|
+
const bytes = Buffer.from(encoded, "base64");
|
|
23
|
+
if (bytes.toString("base64") !== encoded) {
|
|
24
|
+
throw new Error("mutation journal contains invalid byte encoding");
|
|
25
|
+
}
|
|
26
|
+
return new Uint8Array(bytes);
|
|
27
|
+
}
|
|
28
|
+
return Object.fromEntries(Object.entries(object).map(([key, child]) => [key, decodeValue(child)]));
|
|
29
|
+
}
|
|
30
|
+
return value;
|
|
31
|
+
};
|
|
32
|
+
export const encodeMutationOperation = (value) => stableJson(encodeValue(value));
|
|
33
|
+
export const decodeMutationOperation = (json) => decodeValue(JSON.parse(json));
|
|
34
|
+
//# sourceMappingURL=journal-codec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"journal-codec.js","sourceRoot":"","sources":["../../src/detection/journal-codec.ts"],"names":[],"mappings":"AAAA,kEAAkE;AAElE,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,KAAK,GAAG,oBAAoB,CAAC;AAEnC,MAAM,WAAW,GAAG,CAAC,KAAc,EAAW,EAAE;IAC9C,IAAI,KAAK,YAAY,UAAU,EAAE,CAAC;QAChC,OAAO,EAAE,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;IAC5D,CAAC;IACD,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QA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CAAC,CAAC,GAAG,EAAE,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IACrG,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,KAAc,EAAU,EAAE,CAAC,UAAU,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,CAAC;AAElG,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,IAAY,EAAW,EAAE,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC"}
|
|
@@ -4,13 +4,31 @@
|
|
|
4
4
|
* It only binds already-observed ground to durable UUIDs and asks Live to
|
|
5
5
|
* plan the exact Watch generation that Record may accept.
|
|
6
6
|
*/
|
|
7
|
-
import { type CloudEntityRecord, type DetectionBatchPlan, type EntityType, type ReplayInstruction, type SuspicionSnapshot } from "@amalgm/live";
|
|
7
|
+
import { type CloudEntityRecord, type DetectionBatchPlan, type EntityType, type ReplayInstruction, type SuspicionSnapshot, type TextReplay } from "@amalgm/live";
|
|
8
|
+
/**
|
|
9
|
+
* Choose an exact text replay from cache evidence. The notebook's base head
|
|
10
|
+
* is logical history; cached base bytes are only an optional delta input.
|
|
11
|
+
* Missing or mismatched base bytes therefore select a verified snapshot
|
|
12
|
+
* without rewriting the known base to null.
|
|
13
|
+
*/
|
|
14
|
+
export declare function exactTextReplay(input: {
|
|
15
|
+
readonly entityId: string;
|
|
16
|
+
readonly basePayloadVersion: string | null;
|
|
17
|
+
readonly baseBytes: Uint8Array | null;
|
|
18
|
+
readonly resultPayloadVersion: string;
|
|
19
|
+
readonly resultBytes: Uint8Array;
|
|
20
|
+
readonly sha256Hex: (bytes: Uint8Array | string) => string;
|
|
21
|
+
}): TextReplay;
|
|
8
22
|
export interface IdentityRow {
|
|
9
23
|
readonly uuid: string;
|
|
10
24
|
readonly type: EntityType;
|
|
11
25
|
readonly relativePath: string;
|
|
12
26
|
readonly deviceNumber: number;
|
|
13
27
|
readonly inode: number;
|
|
28
|
+
/** False when the notebook retained missing evidence from an earlier batch.
|
|
29
|
+
* Such a row may still claim its exact address, but inode reuse cannot prove
|
|
30
|
+
* a new move from ground that was already absent before this observation. */
|
|
31
|
+
readonly physicalContinuity?: boolean;
|
|
14
32
|
}
|
|
15
33
|
export interface IdentityEntry {
|
|
16
34
|
/** Stable only for this observation; never leaves the host. */
|
|
@@ -4,7 +4,35 @@
|
|
|
4
4
|
* It only binds already-observed ground to durable UUIDs and asks Live to
|
|
5
5
|
* plan the exact Watch generation that Record may accept.
|
|
6
6
|
*/
|
|
7
|
-
import { CONTAINERS, detectionBatch, diffDirState, enclosedByRepositoryAncestor, matchByInode, planDetectionBatch, } from "@amalgm/live";
|
|
7
|
+
import { CONTAINERS, captureTextChange, detectionBatch, diffDirState, enclosedByRepositoryAncestor, matchByInode, planDetectionBatch, } from "@amalgm/live";
|
|
8
|
+
/**
|
|
9
|
+
* Choose an exact text replay from cache evidence. The notebook's base head
|
|
10
|
+
* is logical history; cached base bytes are only an optional delta input.
|
|
11
|
+
* Missing or mismatched base bytes therefore select a verified snapshot
|
|
12
|
+
* without rewriting the known base to null.
|
|
13
|
+
*/
|
|
14
|
+
export function exactTextReplay(input) {
|
|
15
|
+
if (input.sha256Hex(input.resultBytes) !== input.resultPayloadVersion) {
|
|
16
|
+
throw new Error("text result cache does not match its declared content head");
|
|
17
|
+
}
|
|
18
|
+
const verifiedBase = input.basePayloadVersion !== null
|
|
19
|
+
&& input.baseBytes !== null
|
|
20
|
+
&& input.sha256Hex(input.baseBytes) === input.basePayloadVersion
|
|
21
|
+
? input.baseBytes
|
|
22
|
+
: null;
|
|
23
|
+
if (input.basePayloadVersion === null || verifiedBase !== null) {
|
|
24
|
+
const captured = captureTextChange(input.entityId, verifiedBase, input.resultBytes, input.sha256Hex);
|
|
25
|
+
if (captured !== null)
|
|
26
|
+
return captured.replay;
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
kind: "file.text",
|
|
30
|
+
mode: "snapshot",
|
|
31
|
+
basePayloadVersion: input.basePayloadVersion,
|
|
32
|
+
resultPayloadVersion: input.resultPayloadVersion,
|
|
33
|
+
delta: null,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
8
36
|
/**
|
|
9
37
|
* Resolve one observation against the last notebook. Directories claim by
|
|
10
38
|
* unique physical continuity first; files and links claim their address
|
|
@@ -28,7 +56,7 @@ export function reconcileGroundUUIDs(rows, entries) {
|
|
|
28
56
|
}
|
|
29
57
|
const availableRows = () => rows.filter((row) => !claimed.has(row.uuid));
|
|
30
58
|
const availableEntries = () => entries.filter((entry) => !resolved.has(entry.key));
|
|
31
|
-
const directoryRows = availableRows().filter((row) => CONTAINERS.has(row.type));
|
|
59
|
+
const directoryRows = availableRows().filter((row) => CONTAINERS.has(row.type) && row.physicalContinuity !== false);
|
|
32
60
|
const directoryEntries = availableEntries().filter((entry) => CONTAINERS.has(entry.type));
|
|
33
61
|
const directoryEntryByPath = new Map(directoryEntries.map((entry) => [entry.relativePath, entry]));
|
|
34
62
|
const directories = diffDirState(directoryRows.map((row) => ({
|
|
@@ -54,7 +82,7 @@ export function reconcileGroundUUIDs(rows, entries) {
|
|
|
54
82
|
if (row)
|
|
55
83
|
claim(entry, row.uuid);
|
|
56
84
|
}
|
|
57
|
-
const physicalRows = availableRows().filter((row) => !CONTAINERS.has(row.type));
|
|
85
|
+
const physicalRows = availableRows().filter((row) => !CONTAINERS.has(row.type) && row.physicalContinuity !== false);
|
|
58
86
|
const physicalEntries = availableEntries().filter((entry) => !CONTAINERS.has(entry.type));
|
|
59
87
|
for (const match of matchByInode(physicalRows.map((row) => ({
|
|
60
88
|
row,
|
|
@@ -121,4 +149,4 @@ export function planGroundDetection(input) {
|
|
|
121
149
|
throw new Error(`Detect plan for ${input.rootId} failed (${candidates}${remainder}): ${message}`);
|
|
122
150
|
}
|
|
123
151
|
}
|
|
124
|
-
//# sourceMappingURL=
|
|
152
|
+
//# source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C,CAAC;IACL,CAAC;IACD,IAAI,CAAC;QACH,OAAO,kBAAkB,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;IAChD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,MAAM,UAAU,GAAG,WAAW,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,KAAK,KAAK,SAAS;YAC3F,CAAC,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC,IAAI,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,IAAI,UAAU,CAAC,MAAM,CAAC,cAAc,IAAI,MAAM,EAAE;YACrG,CAAC,CAAC,GAAG,UAAU,CAAC,IAAI,EAAE,IAAI,IAAI,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC3D,MAAM,SAAS,GAAG,WAAW,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,WAAW,CAAC,MAAM,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;QACnF,MAAM,IAAI,KAAK,CAAC,mBAAmB,KAAK,CAAC,MAAM,YAAY,UAAU,GAAG,SAAS,MAAM,OAAO,EAAE,CAAC,CAAC;IACpG,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The named Detect lane.
|
|
3
|
+
*
|
|
4
|
+
* A watcher path that still names enrolled, non-repository ground does not
|
|
5
|
+
* justify a workspace walk. This runtime holds one SQLite connection,
|
|
6
|
+
* resolves indexed paths, widens only to a named new folder's subtree, and
|
|
7
|
+
* commits exact Live proposals plus local truth in one transaction. Evidence
|
|
8
|
+
* it cannot prove is declined before mutation and goes to reconciliation in
|
|
9
|
+
* the owning host.
|
|
10
|
+
*/
|
|
11
|
+
import { type SuspicionSnapshot } from "@amalgm/live";
|
|
12
|
+
export interface NamedObservation {
|
|
13
|
+
readonly directory: string;
|
|
14
|
+
readonly suspicion: SuspicionSnapshot;
|
|
15
|
+
}
|
|
16
|
+
export interface NamedDetectEvidence {
|
|
17
|
+
readonly directory: string;
|
|
18
|
+
readonly paths: number;
|
|
19
|
+
readonly metadataReads: number;
|
|
20
|
+
readonly contentReads: number;
|
|
21
|
+
readonly plannedRows: number;
|
|
22
|
+
readonly records: number;
|
|
23
|
+
readonly journalBytes: number;
|
|
24
|
+
readonly durationMs: number;
|
|
25
|
+
}
|
|
26
|
+
export interface NamedDetectResult {
|
|
27
|
+
readonly handled: boolean;
|
|
28
|
+
readonly evidence: readonly NamedDetectEvidence[];
|
|
29
|
+
}
|
|
30
|
+
/** One persistent, prepared Detect store. It owns no Watch or Send behavior. */
|
|
31
|
+
export declare class NamedDetectRuntime {
|
|
32
|
+
private readonly database;
|
|
33
|
+
private readonly cacheDir;
|
|
34
|
+
private readonly userRoot;
|
|
35
|
+
private readonly rootAtDirectory;
|
|
36
|
+
private readonly rowAtPath;
|
|
37
|
+
private readonly rowAtUuid;
|
|
38
|
+
private readonly rowsAtPhysicalIdentity;
|
|
39
|
+
private readonly notebookChildren;
|
|
40
|
+
private readonly materializedByUuid;
|
|
41
|
+
private readonly materializedUnderPath;
|
|
42
|
+
private readonly writeEntity;
|
|
43
|
+
private readonly writeNotebook;
|
|
44
|
+
private readonly appendMutation;
|
|
45
|
+
private readonly removeEntity;
|
|
46
|
+
private userPolicy;
|
|
47
|
+
constructor(databaseFile: string, cacheDir: string, userRoot: string);
|
|
48
|
+
close(): void;
|
|
49
|
+
refreshEnrollmentPolicy(): void;
|
|
50
|
+
detect(observations: readonly NamedObservation[]): Promise<NamedDetectResult>;
|
|
51
|
+
private captureFile;
|
|
52
|
+
private captureDirectory;
|
|
53
|
+
private captureLink;
|
|
54
|
+
private enclosedByRepository;
|
|
55
|
+
private readUserPolicy;
|
|
56
|
+
private uniqueMovedBase;
|
|
57
|
+
private replayFor;
|
|
58
|
+
}
|