@kontourai/lookout 0.3.0 → 0.3.2
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 +189 -32
- package/dist/src/check-result.d.ts +2 -2
- package/dist/src/check-runner.d.ts +1 -1
- package/dist/src/check-runner.js +39 -26
- package/dist/src/drift-emission.js +2 -0
- package/dist/src/index.d.ts +8 -2
- package/dist/src/index.js +3 -1
- package/dist/src/observe-extract-diff.d.ts +90 -0
- package/dist/src/observe-extract-diff.js +154 -0
- package/dist/src/proposal-diff.d.ts +4 -0
- package/dist/src/proposal-diff.js +49 -4
- package/dist/src/registry.d.ts +16 -4
- package/dist/src/registry.js +107 -41
- package/dist/src/semantic-review-projection.d.ts +13 -0
- package/dist/src/semantic-review-projection.js +68 -0
- package/dist/src/semantic-review-types.d.ts +95 -0
- package/dist/src/semantic-review-types.js +1 -0
- package/dist/src/semantic-review-work.d.ts +5 -0
- package/dist/src/semantic-review-work.js +36 -0
- package/dist/src/snapshot-store.d.ts +11 -1
- package/dist/src/snapshot-store.js +18 -1
- package/package.json +5 -4
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { diffProposalSets } from "./proposal-diff.js";
|
|
2
|
+
import { collectSemanticChanges, projectReviewItem, reviewKey, sanitizeError, validateObservationIdentity } from "./semantic-review-projection.js";
|
|
3
|
+
export { semanticReviewApiVersion } from "./semantic-review-types.js";
|
|
4
|
+
/** Project one genuine proposal-observation transition into deterministic review work. */
|
|
5
|
+
export function buildSemanticReviewWork(input) {
|
|
6
|
+
const identities = validateObservationIdentity(input.observationIdentity);
|
|
7
|
+
if (!identities.ok)
|
|
8
|
+
return identities;
|
|
9
|
+
const diff = diffProposalSets(input);
|
|
10
|
+
if (!diff.ok)
|
|
11
|
+
return sanitizeError(diff);
|
|
12
|
+
const transition = reviewKey({ sourceId: input.current.sourceId, priorObservationId: identities.value.prior, currentObservationId: identities.value.current });
|
|
13
|
+
if (!transition.ok)
|
|
14
|
+
return transition;
|
|
15
|
+
const items = [];
|
|
16
|
+
const occurrences = new Map();
|
|
17
|
+
for (const change of collectSemanticChanges(input, diff.value)) {
|
|
18
|
+
let target;
|
|
19
|
+
try {
|
|
20
|
+
target = input.claimTarget(change);
|
|
21
|
+
}
|
|
22
|
+
catch {
|
|
23
|
+
return { ok: false, error: { kind: "callback-threw", message: "claimTarget callback threw", path: "$.claimTarget" } };
|
|
24
|
+
}
|
|
25
|
+
const base = reviewKey(change);
|
|
26
|
+
if (!base.ok)
|
|
27
|
+
return base;
|
|
28
|
+
const occurrence = occurrences.get(base.value) ?? 0;
|
|
29
|
+
occurrences.set(base.value, occurrence + 1);
|
|
30
|
+
const item = projectReviewItem(change, occurrence, transition.value, identities.value, input.prior, input.current, target);
|
|
31
|
+
if (!item.ok)
|
|
32
|
+
return item;
|
|
33
|
+
items.push(item.value);
|
|
34
|
+
}
|
|
35
|
+
return { ok: true, value: { transitionId: transition.value, priorObservationId: identities.value.prior, currentObservationId: identities.value.current, items } };
|
|
36
|
+
}
|
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
import type { SnapshotStore } from "@kontourai/
|
|
1
|
+
import type { SnapshotStore } from "@kontourai/forage";
|
|
2
|
+
import { type SnapshotSourceRefResolution } from "@kontourai/forage/fetch";
|
|
2
3
|
export declare function createLookoutSnapshotStore(root?: string): SnapshotStore;
|
|
4
|
+
export type ResolveLookoutSnapshotOptions = {
|
|
5
|
+
store: SnapshotStore;
|
|
6
|
+
root?: never;
|
|
7
|
+
} | {
|
|
8
|
+
store?: never;
|
|
9
|
+
root?: string;
|
|
10
|
+
};
|
|
11
|
+
/** Replay one Lookout-emitted durable reference without any network access. */
|
|
12
|
+
export declare function resolveLookoutSnapshot(reference: string, options?: ResolveLookoutSnapshotOptions): Promise<SnapshotSourceRefResolution>;
|
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
-
import { createFilesystemSnapshotStore } from "@kontourai/
|
|
2
|
+
import { createFilesystemSnapshotStore } from "@kontourai/forage";
|
|
3
|
+
import { resolveSnapshotSourceRef, } from "@kontourai/forage/fetch";
|
|
3
4
|
export function createLookoutSnapshotStore(root = path.join(process.cwd(), ".kontourai", "lookout", "snapshots")) {
|
|
4
5
|
return createFilesystemSnapshotStore({ root });
|
|
5
6
|
}
|
|
7
|
+
/** Replay one Lookout-emitted durable reference without any network access. */
|
|
8
|
+
export async function resolveLookoutSnapshot(reference, options = {}) {
|
|
9
|
+
try {
|
|
10
|
+
const store = options.store ?? createLookoutSnapshotStore(options.root);
|
|
11
|
+
return await resolveSnapshotSourceRef(store, reference);
|
|
12
|
+
}
|
|
13
|
+
catch {
|
|
14
|
+
return {
|
|
15
|
+
ok: false,
|
|
16
|
+
error: {
|
|
17
|
+
kind: "snapshot-store-error",
|
|
18
|
+
message: "the supplied snapshot store could not resolve the reference",
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kontourai/lookout",
|
|
3
|
-
"version": "0.3.
|
|
4
|
-
"description": "A small source registry and drift-check runner built on
|
|
3
|
+
"version": "0.3.2",
|
|
4
|
+
"description": "A small source registry and drift-check runner built on Forage snapshots.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"private": false,
|
|
@@ -44,10 +44,11 @@
|
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@kontourai/datum": "0.3.0",
|
|
47
|
-
"@kontourai/forage": "0.
|
|
48
|
-
"@kontourai/traverse": "0.
|
|
47
|
+
"@kontourai/forage": "0.4.1",
|
|
48
|
+
"@kontourai/traverse": "0.18.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
|
+
"@kontourai/survey": "1.17.0",
|
|
51
52
|
"@types/node": "^25.6.0",
|
|
52
53
|
"typescript": "^5.8.0"
|
|
53
54
|
},
|