@maadb/core 0.12.4 → 0.14.0
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/README.md +19 -6
- package/dist/backend/adapter.d.ts +1 -1
- package/dist/backend/adapter.d.ts.map +1 -1
- package/dist/backend/sqlite/index.d.ts +1 -1
- package/dist/backend/sqlite/index.d.ts.map +1 -1
- package/dist/backend/sqlite/index.js +42 -6
- package/dist/backend/sqlite/index.js.map +1 -1
- package/dist/backend/sqlite/schema.d.ts +1 -1
- package/dist/backend/sqlite/schema.d.ts.map +1 -1
- package/dist/backend/sqlite/schema.js +4 -1
- package/dist/backend/sqlite/schema.js.map +1 -1
- package/dist/cli/commands/history-mode.d.ts +3 -0
- package/dist/cli/commands/history-mode.d.ts.map +1 -0
- package/dist/cli/commands/history-mode.js +18 -0
- package/dist/cli/commands/history-mode.js.map +1 -0
- package/dist/cli/index.js +6 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/engine/audit.d.ts.map +1 -1
- package/dist/engine/audit.js +11 -4
- package/dist/engine/audit.js.map +1 -1
- package/dist/engine/context.d.ts +6 -3
- package/dist/engine/context.d.ts.map +1 -1
- package/dist/engine/context.js +10 -5
- package/dist/engine/context.js.map +1 -1
- package/dist/engine/index.d.ts +35 -14
- package/dist/engine/index.d.ts.map +1 -1
- package/dist/engine/index.js +55 -13
- package/dist/engine/index.js.map +1 -1
- package/dist/engine/journal.d.ts +14 -1
- package/dist/engine/journal.d.ts.map +1 -1
- package/dist/engine/journal.js +63 -4
- package/dist/engine/journal.js.map +1 -1
- package/dist/engine/reads.d.ts +2 -1
- package/dist/engine/reads.d.ts.map +1 -1
- package/dist/engine/reads.js +207 -0
- package/dist/engine/reads.js.map +1 -1
- package/dist/engine/repairs.js +4 -0
- package/dist/engine/repairs.js.map +1 -1
- package/dist/engine/types.d.ts +102 -1
- package/dist/engine/types.d.ts.map +1 -1
- package/dist/engine/types.js +6 -1
- package/dist/engine/types.js.map +1 -1
- package/dist/engine/writes.d.ts.map +1 -1
- package/dist/engine/writes.js +16 -6
- package/dist/engine/writes.js.map +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/extractor/objects.d.ts +2 -1
- package/dist/extractor/objects.d.ts.map +1 -1
- package/dist/extractor/objects.js +1 -1
- package/dist/extractor/objects.js.map +1 -1
- package/dist/extractor/relationships.d.ts.map +1 -1
- package/dist/extractor/relationships.js +16 -0
- package/dist/extractor/relationships.js.map +1 -1
- package/dist/git/index.d.ts +1 -1
- package/dist/git/index.d.ts.map +1 -1
- package/dist/git/index.js +8 -4
- package/dist/git/index.js.map +1 -1
- package/dist/history/config.d.ts +18 -0
- package/dist/history/config.d.ts.map +1 -0
- package/dist/history/config.js +109 -0
- package/dist/history/config.js.map +1 -0
- package/dist/history/controller.d.ts +31 -0
- package/dist/history/controller.d.ts.map +1 -0
- package/dist/history/controller.js +316 -0
- package/dist/history/controller.js.map +1 -0
- package/dist/history/types.d.ts +58 -0
- package/dist/history/types.d.ts.map +1 -0
- package/dist/history/types.js +5 -0
- package/dist/history/types.js.map +1 -0
- package/dist/instance/config.d.ts +12 -2
- package/dist/instance/config.d.ts.map +1 -1
- package/dist/instance/config.js +49 -4
- package/dist/instance/config.js.map +1 -1
- package/dist/instance/pool.d.ts +3 -3
- package/dist/instance/pool.d.ts.map +1 -1
- package/dist/instance/pool.js +29 -11
- package/dist/instance/pool.js.map +1 -1
- package/dist/mcp/kinds.d.ts.map +1 -1
- package/dist/mcp/kinds.js +2 -0
- package/dist/mcp/kinds.js.map +1 -1
- package/dist/mcp/roles.d.ts.map +1 -1
- package/dist/mcp/roles.js +2 -1
- package/dist/mcp/roles.js.map +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +2 -0
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/tools/backup.d.ts.map +1 -1
- package/dist/mcp/tools/backup.js +7 -1
- package/dist/mcp/tools/backup.js.map +1 -1
- package/dist/mcp/tools/history-mode.d.ts +27 -0
- package/dist/mcp/tools/history-mode.d.ts.map +1 -0
- package/dist/mcp/tools/history-mode.js +71 -0
- package/dist/mcp/tools/history-mode.js.map +1 -0
- package/dist/mcp/tools/maintain.d.ts.map +1 -1
- package/dist/mcp/tools/maintain.js +5 -2
- package/dist/mcp/tools/maintain.js.map +1 -1
- package/dist/mcp/tools/read.d.ts.map +1 -1
- package/dist/mcp/tools/read.js +48 -1
- package/dist/mcp/tools/read.js.map +1 -1
- package/dist/types.d.ts +15 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/engine/audit.js
CHANGED
|
@@ -2,9 +2,16 @@
|
|
|
2
2
|
// Audit — history, diff, snapshot, audit (git-backed)
|
|
3
3
|
// ============================================================================
|
|
4
4
|
import { ok, singleErr } from '../errors.js';
|
|
5
|
+
function unavailable(ctx) {
|
|
6
|
+
const mode = ctx.history?.config.effectiveMode;
|
|
7
|
+
if (mode === 'feed' || mode === 'read') {
|
|
8
|
+
return singleErr('HISTORY_DISABLED', `Git history is unavailable in history_mode ${mode}`, undefined, { historyMode: mode });
|
|
9
|
+
}
|
|
10
|
+
return singleErr('GIT_NOT_INITIALIZED', 'Git is not available in this project');
|
|
11
|
+
}
|
|
5
12
|
export async function history(ctx, id, opts) {
|
|
6
13
|
if (!ctx.gitLayer)
|
|
7
|
-
return
|
|
14
|
+
return unavailable(ctx);
|
|
8
15
|
const doc = ctx.backend.getDocument(id);
|
|
9
16
|
if (!doc)
|
|
10
17
|
return singleErr('FILE_NOT_FOUND', `Document "${id}" not found`);
|
|
@@ -13,7 +20,7 @@ export async function history(ctx, id, opts) {
|
|
|
13
20
|
}
|
|
14
21
|
export async function diff(ctx, id, from, to) {
|
|
15
22
|
if (!ctx.gitLayer)
|
|
16
|
-
return
|
|
23
|
+
return unavailable(ctx);
|
|
17
24
|
const doc = ctx.backend.getDocument(id);
|
|
18
25
|
if (!doc)
|
|
19
26
|
return singleErr('FILE_NOT_FOUND', `Document "${id}" not found`);
|
|
@@ -24,7 +31,7 @@ export async function diff(ctx, id, from, to) {
|
|
|
24
31
|
}
|
|
25
32
|
export async function snapshot(ctx, id, at) {
|
|
26
33
|
if (!ctx.gitLayer)
|
|
27
|
-
return
|
|
34
|
+
return unavailable(ctx);
|
|
28
35
|
const doc = ctx.backend.getDocument(id);
|
|
29
36
|
if (!doc)
|
|
30
37
|
return singleErr('FILE_NOT_FOUND', `Document "${id}" not found`);
|
|
@@ -35,7 +42,7 @@ export async function snapshot(ctx, id, at) {
|
|
|
35
42
|
}
|
|
36
43
|
export async function audit(ctx, opts) {
|
|
37
44
|
if (!ctx.gitLayer)
|
|
38
|
-
return
|
|
45
|
+
return unavailable(ctx);
|
|
39
46
|
const entries = await ctx.gitLayer.audit(opts);
|
|
40
47
|
return ok(entries);
|
|
41
48
|
}
|
package/dist/engine/audit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../../src/engine/audit.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,sDAAsD;AACtD,+EAA+E;AAI/E,OAAO,EAAE,EAAE,EAAE,SAAS,EAAe,MAAM,cAAc,CAAC;AAY1D,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,GAAkB,EAClB,EAAS,EACT,IAAyC;IAEzC,IAAI,CAAC,GAAG,CAAC,QAAQ;QAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"audit.js","sourceRoot":"","sources":["../../src/engine/audit.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,sDAAsD;AACtD,+EAA+E;AAI/E,OAAO,EAAE,EAAE,EAAE,SAAS,EAAe,MAAM,cAAc,CAAC;AAY1D,SAAS,WAAW,CAAI,GAAkB;IACxC,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,aAAa,CAAC;IAC/C,IAAI,IAAI,KAAK,MAAM,IAAI,I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AAC,WAAW,EAAE,wBAAwB,CAAC,CAAC;IACrE,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC;AACpB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,GAAkB,EAClB,EAAS,EACT,EAAU;IAEV,IAAI,CAAC,GAAG,CAAC,QAAQ;QAAE,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC;IAE3C,MAAM,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;IACxC,IAAI,CAAC,GAAG;QAAE,OAAO,SAAS,CAAC,gBAAgB,EAAE,aAAa,EAAY,aAAa,CAAC,CAAC;IAErF,MAAM,MAAM,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAkB,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;IAC3E,IAAI,CAAC,MAAM;QAAE,OAAO,SAAS,CAAC,WAAW,EAAE,6BAA6B,CAAC,CAAC;IAC1E,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC;AACpB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,KAAK,CACzB,GAAkB,EAClB,IAA4D;IAE5D,IAAI,CAAC,GAAG,CAAC,QAAQ;QAAE,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC;IAE3C,MAAM,OAAO,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC/C,OAAO,EAAE,CAAC,OAAO,CAAC,CAAC;AACrB,CAAC"}
|
package/dist/engine/context.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ import type { GitLayer, CommitOptions, CommitOutcome } from '../git/index.js';
|
|
|
4
4
|
import type { CommitIdentity } from '../git/commit.js';
|
|
5
5
|
import type { OperationJournal } from './journal.js';
|
|
6
6
|
import type { EmbeddingProvider } from './semantic/types.js';
|
|
7
|
+
import type { HistoryRuntime } from '../history/types.js';
|
|
7
8
|
/**
|
|
8
9
|
* 0.6.10 — Mutable counters on the context so a write-path failure in
|
|
9
10
|
* `gitCommit` can be surfaced through `maad_health` without plumbing state
|
|
@@ -28,6 +29,8 @@ export interface EngineContext {
|
|
|
28
29
|
journal: OperationJournal;
|
|
29
30
|
readOnly: boolean;
|
|
30
31
|
commitFailures: CommitFailureTracker;
|
|
32
|
+
/** Present once the history runtime has been installed for this engine. */
|
|
33
|
+
history?: HistoryRuntime;
|
|
31
34
|
/**
|
|
32
35
|
* 0.7.0 — Identity snapshot set per-operation by the MCP layer inside the
|
|
33
36
|
* write mutex. When populated AND MAAD_COMMIT_IDENTITY is not "false",
|
|
@@ -48,9 +51,9 @@ export interface EngineContext {
|
|
|
48
51
|
embeddingProvider?: EmbeddingProvider;
|
|
49
52
|
}
|
|
50
53
|
/**
|
|
51
|
-
* Run a
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
+
* Run a history-policy commit and return the outcome. Before a history runtime
|
|
55
|
+
* is installed, this falls back to the legacy direct Git behavior. If both the
|
|
56
|
+
* runtime and gitLayer are absent, returns `noop`. When the commit fails,
|
|
54
57
|
* the failure is logged on the ops channel AND tallied on
|
|
55
58
|
* `ctx.commitFailures` so `maad_health` can surface it; the caller gets the
|
|
56
59
|
* outcome back and can stamp `write_durable: false` on the MCP response.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/engine/context.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,QAAQ,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC9E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACrD,OAAO,KA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E,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC;;;;OAIG;IACH,eAAe,EAAE,OAAO,CAAC;IACzB;;;OAGG;IACH,iBAAiB,CAAC,EAAE,iBAAiB,CAAC;CACvC;AAED;;;;;;;GAOG;AACH,wBAAsB,SAAS,CAAC,GAAG,EAAE,aAAa,EAAE,IAAI,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC,CAkC/F"}
|
package/dist/engine/context.js
CHANGED
|
@@ -14,15 +14,15 @@ export function newCommitFailureTracker() {
|
|
|
14
14
|
};
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
-
* Run a
|
|
18
|
-
*
|
|
19
|
-
*
|
|
17
|
+
* Run a history-policy commit and return the outcome. Before a history runtime
|
|
18
|
+
* is installed, this falls back to the legacy direct Git behavior. If both the
|
|
19
|
+
* runtime and gitLayer are absent, returns `noop`. When the commit fails,
|
|
20
20
|
* the failure is logged on the ops channel AND tallied on
|
|
21
21
|
* `ctx.commitFailures` so `maad_health` can surface it; the caller gets the
|
|
22
22
|
* outcome back and can stamp `write_durable: false` on the MCP response.
|
|
23
23
|
*/
|
|
24
24
|
export async function gitCommit(ctx, opts) {
|
|
25
|
-
if (!ctx.gitLayer)
|
|
25
|
+
if (!ctx.history && !ctx.gitLayer)
|
|
26
26
|
return { status: 'noop' };
|
|
27
27
|
// 0.7.0 — Thread commit identity through when set by the MCP layer.
|
|
28
28
|
// Engine-level direct callers (CLI imports, tests) leave ctx.commitIdentity
|
|
@@ -30,7 +30,12 @@ export async function gitCommit(ctx, opts) {
|
|
|
30
30
|
const enriched = ctx.commitIdentity !== undefined
|
|
31
31
|
? { ...opts, identity: ctx.commitIdentity }
|
|
32
32
|
: opts;
|
|
33
|
-
const outcome =
|
|
33
|
+
const outcome = ctx.history
|
|
34
|
+
? await ctx.history.commit(enriched)
|
|
35
|
+
: await ctx.gitLayer.commit(enriched);
|
|
36
|
+
if (!ctx.history && outcome.status !== 'failed') {
|
|
37
|
+
ctx.journal.completeMany(ctx.journal.findIndexedByFiles(opts.files).map(entry => entry.id));
|
|
38
|
+
}
|
|
34
39
|
if (outcome.status === 'failed') {
|
|
35
40
|
ctx.commitFailures.count++;
|
|
36
41
|
ctx.commitFailures.lastAt = new Date().toISOString();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/engine/context.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,6DAA6D;AAC7D,+EAA+E;
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/engine/context.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,6DAA6D;AAC7D,+EAA+E;AAS/E,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAiBjD,MAAM,UAAU,uBAAuB;IACrC,OAAO;QACL,KAAK,EAAE,CAAC;QACR,MAAM,EAAE,IAAI;QACZ,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,IAAI;QACjB,UAAU,EAAE,IAAI;QAChB,SAAS,EAAE,IAAI;KAChB,CAAC;AACJ,CAAC;AAiCD;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,GAAkB,EAAE,IAAmB;IACrE,IAAI,CAAC,GAAG,CAAC,OAAO,IAAI,CAAC,GAAG,CAAC,QAAQ;QAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAC7D,oEAAoE;IACpE,4EAA4E;IAC5E,4DAA4D;IAC5D,MAAM,QAAQ,GAAkB,GAAG,CAAC,cAAc,KAAK,SAAS;QAC9D,CAAC,CAAC,EAAE,GAAG,IAAI,EAAE,QAAQ,EAAE,GAAG,CAAC,cAAc,EAAE;QAC3C,CAAC,CAAC,IAAI,CAAC;IACT,MAAM,OAAO,GAAG,GAAG,CAAC,O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AE,QAAQ,EAAE,yBAAyB,IAAI,CAAC,KAAe,KAAK,OAAO,CAAC,IAAI,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC;IAC5H,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/engine/index.d.ts
CHANGED
|
@@ -2,9 +2,10 @@ import { type Result } from '../errors.js';
|
|
|
2
2
|
import type { DocId, DocType, FilePath, Registry, SchemaDefinition, ExtractionResult } from '../types.js';
|
|
3
3
|
import type { MaadBackend } from '../backend/index.js';
|
|
4
4
|
import { GitLayer } from '../git/index.js';
|
|
5
|
+
import type { HistoryHealthState } from '../history/types.js';
|
|
5
6
|
import type { EmbeddingProvider } from './semantic/types.js';
|
|
6
7
|
import * as maintenance from './maintenance.js';
|
|
7
|
-
export type { IndexResult, CreateResult, GetResult, UpdateResult, DeleteResult, FindResult, SearchResult, RelatedResult, DescribeResult, SummaryResult, GetFullResult, SchemaInfoResult, ValidationReport, VerifyResult, } from './types.js';
|
|
8
|
+
export type { IndexResult, CreateResult, GetResult, UpdateResult, DeleteResult, FindResult, SearchResult, RelatedResult, RelationshipPathsResult, RelationshipPathQuery, DescribeResult, SummaryResult, GetFullResult, SchemaInfoResult, ValidationReport, VerifyResult, } from './types.js';
|
|
8
9
|
export type { SemanticSearchQuery, SemanticSearchResult, SemanticHit, SearchMode, } from './semantic/types.js';
|
|
9
10
|
export interface HealthReport {
|
|
10
11
|
projectRoot: string;
|
|
@@ -40,6 +41,7 @@ export interface HealthReport {
|
|
|
40
41
|
sha: string;
|
|
41
42
|
createdAt: string;
|
|
42
43
|
} | null;
|
|
44
|
+
history: HistoryHealthState;
|
|
43
45
|
}
|
|
44
46
|
export declare class MaadEngine {
|
|
45
47
|
private projectRoot;
|
|
@@ -48,6 +50,7 @@ export declare class MaadEngine {
|
|
|
48
50
|
private backend;
|
|
49
51
|
private gitLayer;
|
|
50
52
|
private journal;
|
|
53
|
+
private historyRuntime;
|
|
51
54
|
private commitFailures;
|
|
52
55
|
private pendingCommitIdentity;
|
|
53
56
|
private initialized;
|
|
@@ -85,11 +88,13 @@ export declare class MaadEngine {
|
|
|
85
88
|
runExclusive<T>(op: string, fn: () => Promise<T>): Promise<T>;
|
|
86
89
|
init(projectRoot: string, opts?: {
|
|
87
90
|
readOnly?: boolean;
|
|
91
|
+
history?: import('../history/types.js').ResolvedHistoryConfig;
|
|
88
92
|
semantic?: boolean;
|
|
89
93
|
embeddingProvider?: EmbeddingProvider;
|
|
90
94
|
guardEmptyIndex?: boolean;
|
|
91
95
|
}): Promise<Result<void>>;
|
|
92
96
|
isReadOnly(): boolean;
|
|
97
|
+
private readOnlyMutationError;
|
|
93
98
|
reload(): Promise<Result<void>>;
|
|
94
99
|
/**
|
|
95
100
|
* 0.7.7 — Lightweight in-place reload of registry + schemas.
|
|
@@ -167,13 +172,25 @@ export declare class MaadEngine {
|
|
|
167
172
|
private assertInit;
|
|
168
173
|
indexAll(opts?: {
|
|
169
174
|
force?: boolean;
|
|
170
|
-
}): Promise<import("./types.js").IndexResult | Result<
|
|
171
|
-
indexFile(absolutePath: FilePath): Promise<
|
|
175
|
+
}): Promise<import("./types.js").IndexResult | Result<never>>;
|
|
176
|
+
indexFile(absolutePath: FilePath): Promise<{
|
|
177
|
+
ok: false;
|
|
178
|
+
errors: import("../errors.js").MaadError[];
|
|
179
|
+
} | {
|
|
180
|
+
ok: true;
|
|
181
|
+
value: ExtractionResult;
|
|
182
|
+
}>;
|
|
172
183
|
reindex(opts?: {
|
|
173
184
|
docId?: DocId;
|
|
174
185
|
force?: boolean;
|
|
175
186
|
embeddings?: boolean;
|
|
176
|
-
}): Promise<
|
|
187
|
+
}): Promise<{
|
|
188
|
+
ok: false;
|
|
189
|
+
errors: import("../errors.js").MaadError[];
|
|
190
|
+
} | {
|
|
191
|
+
ok: true;
|
|
192
|
+
value: import("./types.js").IndexResult;
|
|
193
|
+
}>;
|
|
177
194
|
/**
|
|
178
195
|
* 0.8.0 — await the async embed worker draining the queue to completion, so
|
|
179
196
|
* the vector index is caught up with what's been written. No-op when semantic
|
|
@@ -181,6 +198,7 @@ export declare class MaadEngine {
|
|
|
181
198
|
* hosts needing a consistent vector index, and by tests.
|
|
182
199
|
*/
|
|
183
200
|
flushSemanticIndex(): Promise<void>;
|
|
201
|
+
flushHistory(trigger?: import('../history/types.js').HistoryFlushTrigger): Promise<import("../history/types.js").HistoryFlushResult>;
|
|
184
202
|
/**
|
|
185
203
|
* 0.8.0 — semantic subsystem health for maad_health.embeddings. Always returns
|
|
186
204
|
* a stable shape; `enabled:false` when semantic is off or the index never
|
|
@@ -201,6 +219,7 @@ export declare class MaadEngine {
|
|
|
201
219
|
findDocuments(query: import('../types.js').DocumentQuery): Result<import("./types.js").FindResult>;
|
|
202
220
|
searchObjects(query: import('../types.js').ObjectQuery): Result<import("./types.js").SearchResult>;
|
|
203
221
|
listRelated(id: DocId, direction: 'outgoing' | 'incoming' | 'both', types?: DocType[]): Result<import("./types.js").RelatedResult>;
|
|
222
|
+
relationshipPaths(query: import('./types.js').RelationshipPathQuery): Result<import("./types.js").RelationshipPathsResult>;
|
|
204
223
|
describe(): import("./types.js").DescribeResult;
|
|
205
224
|
summary(): import("./types.js").SummaryResult;
|
|
206
225
|
getSchema(dt: DocType): SchemaDefinition | undefined;
|
|
@@ -215,7 +234,7 @@ export declare class MaadEngine {
|
|
|
215
234
|
errors: import("../errors.js").MaadError[];
|
|
216
235
|
} | {
|
|
217
236
|
ok: true;
|
|
218
|
-
value:
|
|
237
|
+
value: import("./types.js").BackupTag;
|
|
219
238
|
}>;
|
|
220
239
|
backupList(opts?: import('./types.js').ListBackupsOptions): Promise<Result<import("./types.js").BackupTag[]>>;
|
|
221
240
|
backupDelete(tag: string): Promise<{
|
|
@@ -223,7 +242,9 @@ export declare class MaadEngine {
|
|
|
223
242
|
errors: import("../errors.js").MaadError[];
|
|
224
243
|
} | {
|
|
225
244
|
ok: true;
|
|
226
|
-
value:
|
|
245
|
+
value: {
|
|
246
|
+
removed: string;
|
|
247
|
+
};
|
|
227
248
|
}>;
|
|
228
249
|
changesSince(query: import('./types.js').ChangesSinceQuery): Result<import("./types.js").ChangesPage>;
|
|
229
250
|
semanticSearch(query: import('./semantic/types.js').SemanticSearchQuery): Promise<Result<import("./semantic/types.js").SemanticSearchResult>>;
|
|
@@ -233,56 +254,56 @@ export declare class MaadEngine {
|
|
|
233
254
|
errors: import("../errors.js").MaadError[];
|
|
234
255
|
} | {
|
|
235
256
|
ok: true;
|
|
236
|
-
value:
|
|
257
|
+
value: import("./types.js").CreateResult;
|
|
237
258
|
}>;
|
|
238
259
|
updateDocument(id: DocId, fields?: Record<string, unknown>, body?: string, appendBody?: string, expectedVersion?: number): Promise<{
|
|
239
260
|
ok: false;
|
|
240
261
|
errors: import("../errors.js").MaadError[];
|
|
241
262
|
} | {
|
|
242
263
|
ok: true;
|
|
243
|
-
value:
|
|
264
|
+
value: import("./types.js").UpdateResult;
|
|
244
265
|
}>;
|
|
245
266
|
deleteDocument(id: DocId, mode: 'soft' | 'hard'): Promise<{
|
|
246
267
|
ok: false;
|
|
247
268
|
errors: import("../errors.js").MaadError[];
|
|
248
269
|
} | {
|
|
249
270
|
ok: true;
|
|
250
|
-
value:
|
|
271
|
+
value: import("./types.js").DeleteResult;
|
|
251
272
|
}>;
|
|
252
273
|
bulkCreate(records: import('./types.js').BulkCreateInput[]): Promise<{
|
|
253
274
|
ok: false;
|
|
254
275
|
errors: import("../errors.js").MaadError[];
|
|
255
276
|
} | {
|
|
256
277
|
ok: true;
|
|
257
|
-
value:
|
|
278
|
+
value: import("./types.js").BulkResult;
|
|
258
279
|
}>;
|
|
259
280
|
bulkUpdate(updates: import('./types.js').BulkUpdateInput[]): Promise<{
|
|
260
281
|
ok: false;
|
|
261
282
|
errors: import("../errors.js").MaadError[];
|
|
262
283
|
} | {
|
|
263
284
|
ok: true;
|
|
264
|
-
value:
|
|
285
|
+
value: import("./types.js").BulkResult;
|
|
265
286
|
}>;
|
|
266
287
|
bulkDelete(docIds: string[], mode: 'soft' | 'hard'): Promise<{
|
|
267
288
|
ok: false;
|
|
268
289
|
errors: import("../errors.js").MaadError[];
|
|
269
290
|
} | {
|
|
270
291
|
ok: true;
|
|
271
|
-
value:
|
|
292
|
+
value: import("./types.js").BulkDeleteResult;
|
|
272
293
|
}>;
|
|
273
294
|
purgeSoftDeleted(olderThanIso: string, maxRecords: number): Promise<{
|
|
274
295
|
ok: false;
|
|
275
296
|
errors: import("../errors.js").MaadError[];
|
|
276
297
|
} | {
|
|
277
298
|
ok: true;
|
|
278
|
-
value:
|
|
299
|
+
value: import("./types.js").PurgeSoftDeletedResult;
|
|
279
300
|
}>;
|
|
280
301
|
repairWhere(filter: Record<string, import('../types.js').FilterCondition> | undefined, docType: DocType | undefined, repairTypes: import('./types.js').RepairStrategyName[], maxRecords: number): Promise<{
|
|
281
302
|
ok: false;
|
|
282
303
|
errors: import("../errors.js").MaadError[];
|
|
283
304
|
} | {
|
|
284
305
|
ok: true;
|
|
285
|
-
value:
|
|
306
|
+
value: import("./types.js").RepairWhereResult;
|
|
286
307
|
}>;
|
|
287
308
|
validate(docId?: DocId, options?: maintenance.ValidateOptions): Promise<Result<import("./types.js").ValidationReport>>;
|
|
288
309
|
history(id: DocId, opts?: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/engine/index.ts"],"names":[],"mappings":"AASA,OAAO,EAAiB,KAAK,MAAM,EAAE,MAAM,cAAc,CAAC;AAW1D,OAAO,KAAK,EACV,KAAK,EACL,OAAO,EACP,QAAQ,EACR,QAAQ,EAER,gBAAgB,EAChB,gBAAgB,EACjB,MAAM,aAAa,CAAC;AAMrB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/engine/index.ts"],"names":[],"mapp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EAAE,EAAE,EAAE,MAAM;IAC9B,KAAK,CAAC,IAAI,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE;IAGxE,UAAU,IAAI,WAAW;IACzB,WAAW,IAAI,QAAQ;IACvB,WAAW,IAAI,QAAQ,GAAG,IAAI;IAC9B,cAAc,IAAI,MAAM;CACzB"}
|
package/dist/engine/index.js
CHANGED
|
@@ -23,6 +23,8 @@ import { SqliteBackend } from '../backend/index.js';
|
|
|
23
23
|
import { GitLayer } from '../git/index.js';
|
|
24
24
|
import { newCommitFailureTracker } from './context.js';
|
|
25
25
|
import { OperationJournal } from './journal.js';
|
|
26
|
+
import { HistoryController } from '../history/controller.js';
|
|
27
|
+
import { resolveHistoryConfig } from '../history/config.js';
|
|
26
28
|
import { isSemanticEnabled, readSemanticEnv } from './semantic/config.js';
|
|
27
29
|
import { resolveEmbeddingProvider } from './semantic/provider.js';
|
|
28
30
|
import { SemanticIndexer } from './semantic/indexer.js';
|
|
@@ -98,6 +100,7 @@ export class MaadEngine {
|
|
|
98
100
|
backend;
|
|
99
101
|
gitLayer = null;
|
|
100
102
|
journal;
|
|
103
|
+
historyRuntime = null;
|
|
101
104
|
commitFailures = newCommitFailureTracker();
|
|
102
105
|
// 0.7.0 — pending commit identity set per-operation by the MCP `withEngine`
|
|
103
106
|
// wrapper inside the write mutex (safe because write mutex serializes all
|
|
@@ -186,7 +189,13 @@ export class MaadEngine {
|
|
|
186
189
|
}
|
|
187
190
|
async init(projectRoot, opts) {
|
|
188
191
|
this.projectRoot = path.resolve(projectRoot);
|
|
189
|
-
|
|
192
|
+
const historyResult = opts?.history !== undefined
|
|
193
|
+
? ok(opts.history)
|
|
194
|
+
: resolveHistoryConfig({}, this.projectRoot);
|
|
195
|
+
if (!historyResult.ok)
|
|
196
|
+
return historyResult;
|
|
197
|
+
const historyConfig = historyResult.value;
|
|
198
|
+
this._readOnly = (opts?.readOnly ?? false) || historyConfig.effectiveMode === 'read';
|
|
190
199
|
this.bootOpts = opts;
|
|
191
200
|
// Self-heal engine-owned state on empty projects. In read-only mode we
|
|
192
201
|
// refuse to write anything: a missing registry/schema/backend is a hard
|
|
@@ -260,7 +269,7 @@ export class MaadEngine {
|
|
|
260
269
|
}
|
|
261
270
|
// Operation journal — tracks pending writes for crash recovery
|
|
262
271
|
this.journal = new OperationJournal(backendDir);
|
|
263
|
-
this.startupRecovery = this._readOnly ? [] : this.journal.reconcile();
|
|
272
|
+
this.startupRecovery = this._readOnly ? [] : this.journal.reconcile({ retainIndexed: true });
|
|
264
273
|
this.gitLayer = new GitLayer(this.projectRoot);
|
|
265
274
|
if (await this.gitLayer.isRepo()) {
|
|
266
275
|
// Git is available — check for stale index.lock from a crashed prior process.
|
|
@@ -276,6 +285,13 @@ export class MaadEngine {
|
|
|
276
285
|
else {
|
|
277
286
|
this.gitLayer = null;
|
|
278
287
|
}
|
|
288
|
+
this.historyRuntime = new HistoryController(historyConfig, this.gitLayer, this.journal, (op, fn) => this.runExclusive(op, fn));
|
|
289
|
+
const recovered = await this.historyRuntime.recover();
|
|
290
|
+
if (recovered) {
|
|
291
|
+
this.startupRecovery.push(recovered.outcome.status === 'failed'
|
|
292
|
+
? `history_recovery_failed:${recovered.outcome.code}`
|
|
293
|
+
: `history_recovery_completed:${historyConfig.effectiveMode}`);
|
|
294
|
+
}
|
|
279
295
|
this.initialized = true;
|
|
280
296
|
// Warm the git-clean cache so the first health() call returns real data
|
|
281
297
|
// instead of null. Best-effort — a failure here falls through to null
|
|
@@ -320,6 +336,11 @@ export class MaadEngine {
|
|
|
320
336
|
isReadOnly() {
|
|
321
337
|
return this._readOnly;
|
|
322
338
|
}
|
|
339
|
+
readOnlyMutationError() {
|
|
340
|
+
return this.historyRuntime?.config.effectiveMode === 'read'
|
|
341
|
+
? singleErr('PROJECT_READ_ONLY', 'Project history_mode is read')
|
|
342
|
+
: singleErr('READ_ONLY', 'Engine is in read-only mode');
|
|
343
|
+
}
|
|
323
344
|
async reload() {
|
|
324
345
|
return this.runExclusive('reload', async () => {
|
|
325
346
|
const replacement = new MaadEngine();
|
|
@@ -334,6 +355,8 @@ export class MaadEngine {
|
|
|
334
355
|
this.backend = replacement.backend;
|
|
335
356
|
this.gitLayer = replacement.gitLayer;
|
|
336
357
|
this.journal = replacement.journal;
|
|
358
|
+
this.historyRuntime = replacement.historyRuntime;
|
|
359
|
+
this.historyRuntime?.bindSerializer((op, fn) => this.runExclusive(op, fn));
|
|
337
360
|
this.startupRecovery = replacement.startupRecovery;
|
|
338
361
|
this.semanticEnabled = replacement.semanticEnabled;
|
|
339
362
|
this.embeddingProvider = replacement.embeddingProvider;
|
|
@@ -342,6 +365,7 @@ export class MaadEngine {
|
|
|
342
365
|
// Ownership moved to this instance; prevent replacement.close() from
|
|
343
366
|
// touching the adopted backend or worker.
|
|
344
367
|
replacement.semanticIndexer = null;
|
|
368
|
+
replacement.historyRuntime = null;
|
|
345
369
|
replacement.initialized = false;
|
|
346
370
|
return ok(undefined);
|
|
347
371
|
});
|
|
@@ -429,6 +453,7 @@ export class MaadEngine {
|
|
|
429
453
|
lastIntegritySweepAt: this.backend.getMeta('last_integrity_sweep_at'),
|
|
430
454
|
lastIntegrityFindings: parseStoredJson(this.backend.getMeta('last_integrity_findings')),
|
|
431
455
|
lastBackupTag: parseStoredJson(this.backend.getMeta('last_backup_tag')),
|
|
456
|
+
history: this.historyRuntime.health(),
|
|
432
457
|
};
|
|
433
458
|
}
|
|
434
459
|
// ---- H8 probes ------------------------------------------------------------
|
|
@@ -543,6 +568,8 @@ export class MaadEngine {
|
|
|
543
568
|
}
|
|
544
569
|
async disposeResources() {
|
|
545
570
|
this.initialized = false;
|
|
571
|
+
const history = this.historyRuntime;
|
|
572
|
+
this.historyRuntime = null;
|
|
546
573
|
const indexer = this.semanticIndexer;
|
|
547
574
|
this.semanticIndexer = null;
|
|
548
575
|
if (indexer)
|
|
@@ -553,6 +580,11 @@ export class MaadEngine {
|
|
|
553
580
|
}
|
|
554
581
|
catch { /* idempotent/best-effort teardown */ }
|
|
555
582
|
}
|
|
583
|
+
// History flushes use the journal and Git only. Close SQLite first so
|
|
584
|
+
// legacy callers that do not await close() still release the Windows file
|
|
585
|
+
// handle synchronously, then finish the bounded Git boundary.
|
|
586
|
+
if (history)
|
|
587
|
+
await history.close();
|
|
556
588
|
}
|
|
557
589
|
ctx() {
|
|
558
590
|
this.assertInit();
|
|
@@ -565,6 +597,7 @@ export class MaadEngine {
|
|
|
565
597
|
journal: this.journal,
|
|
566
598
|
readOnly: this._readOnly,
|
|
567
599
|
commitFailures: this.commitFailures,
|
|
600
|
+
...(this.historyRuntime !== null ? { history: this.historyRuntime } : {}),
|
|
568
601
|
semanticEnabled: this.semanticEnabled,
|
|
569
602
|
...(this.embeddingProvider !== null ? { embeddingProvider: this.embeddingProvider } : {}),
|
|
570
603
|
...(this.pendingCommitIdentity !== undefined ? { commitIdentity: this.pendingCommitIdentity } : {}),
|
|
@@ -600,13 +633,17 @@ export class MaadEngine {
|
|
|
600
633
|
// tests) get serialized via the first (outer) acquire.
|
|
601
634
|
async indexAll(opts) {
|
|
602
635
|
if (this._readOnly)
|
|
603
|
-
return
|
|
636
|
+
return this.readOnlyMutationError();
|
|
604
637
|
return this.kickIndexer(await this.runExclusive('indexAll', () => indexing.indexAll(this.ctx(), opts)));
|
|
605
638
|
}
|
|
606
639
|
async indexFile(absolutePath) {
|
|
640
|
+
if (this._readOnly)
|
|
641
|
+
return this.readOnlyMutationError();
|
|
607
642
|
return this.kickIndexer(await this.runExclusive('indexFile', () => indexing.indexFile(this.ctx(), absolutePath)));
|
|
608
643
|
}
|
|
609
644
|
async reindex(opts) {
|
|
645
|
+
if (this._readOnly)
|
|
646
|
+
return this.readOnlyMutationError();
|
|
610
647
|
// `embeddings` forces a full reindex (so block_text/FTS are (re)populated for
|
|
611
648
|
// every doc — needed when enabling semantic on an existing project), then
|
|
612
649
|
// re-enqueues all blocks and drains the worker so the rebuild is synchronous.
|
|
@@ -638,6 +675,10 @@ export class MaadEngine {
|
|
|
638
675
|
async flushSemanticIndex() {
|
|
639
676
|
await this.semanticIndexer?.flush();
|
|
640
677
|
}
|
|
678
|
+
async flushHistory(trigger = 'explicit') {
|
|
679
|
+
this.assertInit();
|
|
680
|
+
return this.runExclusive(`history:${trigger}`, () => this.historyRuntime.flush(trigger));
|
|
681
|
+
}
|
|
641
682
|
/**
|
|
642
683
|
* 0.8.0 — semantic subsystem health for maad_health.embeddings. Always returns
|
|
643
684
|
* a stable shape; `enabled:false` when semantic is off or the index never
|
|
@@ -663,6 +704,7 @@ export class MaadEngine {
|
|
|
663
704
|
findDocuments(query) { return reads.findDocuments(this.ctx(), query); }
|
|
664
705
|
searchObjects(query) { return reads.searchObjects(this.ctx(), query); }
|
|
665
706
|
listRelated(id, direction, types) { return reads.listRelated(this.ctx(), id, direction, types); }
|
|
707
|
+
relationshipPaths(query) { return reads.relationshipPaths(this.ctx(), query); }
|
|
666
708
|
describe() { return reads.describe(this.ctx()); }
|
|
667
709
|
summary() { return reads.summary(this.ctx()); }
|
|
668
710
|
getSchema(dt) { return reads.getSchema(this.ctx(), dt); }
|
|
@@ -674,13 +716,13 @@ export class MaadEngine {
|
|
|
674
716
|
async verifyIntegrity(query) { return reads.verifyIntegrity(this.ctx(), query); }
|
|
675
717
|
async backupCreate(opts) {
|
|
676
718
|
if (this._readOnly)
|
|
677
|
-
return
|
|
719
|
+
return this.readOnlyMutationError();
|
|
678
720
|
return backup.createBackup(this.ctx(), opts);
|
|
679
721
|
}
|
|
680
722
|
async backupList(opts) { return backup.listBackups(this.ctx(), opts); }
|
|
681
723
|
async backupDelete(tag) {
|
|
682
724
|
if (this._readOnly)
|
|
683
|
-
return
|
|
725
|
+
return this.readOnlyMutationError();
|
|
684
726
|
return backup.deleteBackup(this.ctx(), tag);
|
|
685
727
|
}
|
|
686
728
|
changesSince(query) { return reads.changesSince(this.ctx(), query); }
|
|
@@ -692,42 +734,42 @@ export class MaadEngine {
|
|
|
692
734
|
// Self-wrapping. Reentrant under an outer runExclusive scope.
|
|
693
735
|
async createDocument(dt, fields, body, customDocId) {
|
|
694
736
|
if (this._readOnly)
|
|
695
|
-
return
|
|
737
|
+
return this.readOnlyMutationError();
|
|
696
738
|
return this.kickIndexer(await this.runExclusive('createDocument', () => writes.createDocument(this.ctx(), dt, fields, body, customDocId)));
|
|
697
739
|
}
|
|
698
740
|
async updateDocument(id, fields, body, appendBody, expectedVersion) {
|
|
699
741
|
if (this._readOnly)
|
|
700
|
-
return
|
|
742
|
+
return this.readOnlyMutationError();
|
|
701
743
|
return this.kickIndexer(await this.runExclusive('updateDocument', () => writes.updateDocument(this.ctx(), id, fields, body, appendBody, expectedVersion)));
|
|
702
744
|
}
|
|
703
745
|
async deleteDocument(id, mode) {
|
|
704
746
|
if (this._readOnly)
|
|
705
|
-
return
|
|
747
|
+
return this.readOnlyMutationError();
|
|
706
748
|
return this.runExclusive('deleteDocument', () => writes.deleteDocument(this.ctx(), id, mode));
|
|
707
749
|
}
|
|
708
750
|
async bulkCreate(records) {
|
|
709
751
|
if (this._readOnly)
|
|
710
|
-
return
|
|
752
|
+
return this.readOnlyMutationError();
|
|
711
753
|
return this.kickIndexer(await this.runExclusive('bulkCreate', () => writes.bulkCreate(this.ctx(), records)));
|
|
712
754
|
}
|
|
713
755
|
async bulkUpdate(updates) {
|
|
714
756
|
if (this._readOnly)
|
|
715
|
-
return
|
|
757
|
+
return this.readOnlyMutationError();
|
|
716
758
|
return this.kickIndexer(await this.runExclusive('bulkUpdate', () => writes.bulkUpdate(this.ctx(), updates)));
|
|
717
759
|
}
|
|
718
760
|
async bulkDelete(docIds, mode) {
|
|
719
761
|
if (this._readOnly)
|
|
720
|
-
return
|
|
762
|
+
return this.readOnlyMutationError();
|
|
721
763
|
return this.runExclusive('bulkDelete', () => writes.bulkDelete(this.ctx(), docIds, mode));
|
|
722
764
|
}
|
|
723
765
|
async purgeSoftDeleted(olderThanIso, maxRecords) {
|
|
724
766
|
if (this._readOnly)
|
|
725
|
-
return
|
|
767
|
+
return this.readOnlyMutationError();
|
|
726
768
|
return this.runExclusive('purgeSoftDeleted', () => writes.purgeSoftDeleted(this.ctx(), olderThanIso, maxRecords));
|
|
727
769
|
}
|
|
728
770
|
async repairWhere(filter, docType, repairTypes, maxRecords) {
|
|
729
771
|
if (this._readOnly)
|
|
730
|
-
return
|
|
772
|
+
return this.readOnlyMutationError();
|
|
731
773
|
return this.kickIndexer(await this.runExclusive('repairWhere', () => repairs.repairWhere(this.ctx(), filter, docType, repairTypes, maxRecords)));
|
|
732
774
|
}
|
|
733
775
|
// --- Maintenance ---
|