@graview/tools 0.1.48 → 0.1.49
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 +31 -0
- package/dist/agent/tools.d.ts +2 -1
- package/dist/agent/tools.d.ts.map +1 -1
- package/dist/agent/tools.js +40 -9
- package/dist/agent/tools.js.map +1 -1
- package/dist/ai.d.ts +1 -1
- package/dist/ai.d.ts.map +1 -1
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +87 -1
- package/dist/cli.js.map +1 -1
- package/dist/decide.d.ts +1 -1
- package/dist/decide.d.ts.map +1 -1
- package/dist/decide.js +2 -2
- package/dist/decide.js.map +1 -1
- package/dist/derive.d.ts.map +1 -1
- package/dist/derive.js +8 -1
- package/dist/derive.js.map +1 -1
- package/dist/dev-ai.d.ts +2 -1
- package/dist/dev-ai.d.ts.map +1 -1
- package/dist/dev-ai.js +8 -6
- package/dist/dev-ai.js.map +1 -1
- package/dist/draft.js +1 -1
- package/dist/draft.js.map +1 -1
- package/dist/fast.d.ts +44 -0
- package/dist/fast.d.ts.map +1 -0
- package/dist/fast.js +2 -0
- package/dist/fast.js.map +1 -0
- package/dist/figure.js +1 -1
- package/dist/figure.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/inline-ai.d.ts.map +1 -1
- package/dist/inline-ai.js +1 -1
- package/dist/inline-ai.js.map +1 -1
- package/dist/intelligence.d.ts +32 -2
- package/dist/intelligence.d.ts.map +1 -1
- package/dist/intelligence.js +1 -1
- package/dist/intelligence.js.map +1 -1
- package/dist/local.d.ts +1 -1
- package/dist/local.d.ts.map +1 -1
- package/dist/local.js +23 -18
- package/dist/local.js.map +1 -1
- package/dist/loop.d.ts +1 -1
- package/dist/loop.d.ts.map +1 -1
- package/dist/loop.js.map +1 -1
- package/dist/providers/jev.d.ts +1 -36
- package/dist/providers/jev.d.ts.map +1 -1
- package/dist/providers/jev.js.map +1 -1
- package/dist/questions.js +2 -2
- package/dist/questions.js.map +1 -1
- package/dist/run.d.ts +1 -1
- package/dist/run.d.ts.map +1 -1
- package/dist/seat-model.js +3 -3
- package/dist/seat-model.js.map +1 -1
- package/dist/suggest.d.ts +8 -8
- package/dist/suggest.d.ts.map +1 -1
- package/dist/suggest.js +2 -2
- package/dist/suggest.js.map +1 -1
- package/dist/tidy/asking.d.ts +51 -0
- package/dist/tidy/asking.d.ts.map +1 -0
- package/dist/tidy/asking.js +86 -0
- package/dist/tidy/asking.js.map +1 -0
- package/dist/tidy/away.d.ts +24 -0
- package/dist/tidy/away.d.ts.map +1 -0
- package/dist/tidy/away.js +24 -0
- package/dist/tidy/away.js.map +1 -0
- package/dist/tidy/blocking.d.ts +82 -0
- package/dist/tidy/blocking.d.ts.map +1 -0
- package/dist/tidy/blocking.js +260 -0
- package/dist/tidy/blocking.js.map +1 -0
- package/dist/tidy/dream.d.ts +117 -0
- package/dist/tidy/dream.d.ts.map +1 -0
- package/dist/tidy/dream.js +178 -0
- package/dist/tidy/dream.js.map +1 -0
- package/dist/tidy/judges.d.ts +109 -0
- package/dist/tidy/judges.d.ts.map +1 -0
- package/dist/tidy/judges.js +282 -0
- package/dist/tidy/judges.js.map +1 -0
- package/dist/tidy/judging.d.ts +51 -0
- package/dist/tidy/judging.d.ts.map +1 -0
- package/dist/tidy/judging.js +243 -0
- package/dist/tidy/judging.js.map +1 -0
- package/dist/tidy/policy.d.ts +18 -0
- package/dist/tidy/policy.d.ts.map +1 -0
- package/dist/tidy/policy.js +29 -0
- package/dist/tidy/policy.js.map +1 -0
- package/dist/tidy/system-one.d.ts +40 -0
- package/dist/tidy/system-one.d.ts.map +1 -0
- package/dist/tidy/system-one.js +49 -0
- package/dist/tidy/system-one.js.map +1 -0
- package/dist/tidy.d.ts +8 -0
- package/dist/tidy.d.ts.map +1 -0
- package/dist/tidy.js +23 -0
- package/dist/tidy.js.map +1 -0
- package/package.json +7 -3
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { isAutomated } from "@graview/core";
|
|
2
|
+
import { declined, suggest, suggestionKey, suggestions } from "@graview/core/tidying";
|
|
3
|
+
import { askAll } from "./asking.js";
|
|
4
|
+
import { blocksOf } from "./blocking.js";
|
|
5
|
+
import { asksOf, coverOf } from "./judging.js";
|
|
6
|
+
import { JUDGES } from "./judges.js";
|
|
7
|
+
import { routeOf } from "./policy.js";
|
|
8
|
+
import { nearOf, systemOneOf } from "./system-one.js";
|
|
9
|
+
/*
|
|
10
|
+
* DREAMING: the app's own actor, run while nobody is looking — a host's
|
|
11
|
+
* nightly schedule, an alarm, `graview dream`. Code finds what is worth
|
|
12
|
+
* asking about, far more widely than an exact match (`./blocking.ts`); a
|
|
13
|
+
* System One model, when the host lends one, JUDGES each — the same thing
|
|
14
|
+
* twice? which of these does it mean? finished? which option fits? — in one
|
|
15
|
+
* request per candidate (`./judging.ts`); and code says what each answer
|
|
16
|
+
* is enough for, by how much the change would undo (`./policy.ts`): made,
|
|
17
|
+
* where the host let the actor apply that sure a change; suggested, to
|
|
18
|
+
* wait in the Suggested tray for a person; or let go. Without a model, or
|
|
19
|
+
* when it fails or the run's budget runs out, the judges' own rules are
|
|
20
|
+
* the floor. The declaration says where the actor may never act
|
|
21
|
+
* (`tidying`), never where it may act unasked, so applying is the host's
|
|
22
|
+
* word, not the app's, and off unless said.
|
|
23
|
+
*/
|
|
24
|
+
/** "Graview, tidying": the app's own actor, as a run is made by unless a host names its own. */
|
|
25
|
+
export const TIDYING_ACTOR = { kind: "system", id: "tidying", name: "Graview, tidying", automated: true };
|
|
26
|
+
/** When each record was last changed, from the log. */
|
|
27
|
+
export function touchedIn(store) {
|
|
28
|
+
const touched = new Map();
|
|
29
|
+
for (const op of store.log.all()) {
|
|
30
|
+
const at = Date.parse(op.at);
|
|
31
|
+
if (Number.isNaN(at))
|
|
32
|
+
continue;
|
|
33
|
+
for (const id of op.writes)
|
|
34
|
+
touched.set(id, Math.max(at, touched.get(id) ?? 0));
|
|
35
|
+
}
|
|
36
|
+
return touched;
|
|
37
|
+
}
|
|
38
|
+
const plural = (count, one) => `${count === 1 ? "one" : count} ${one}${count === 1 ? "" : "s"}`;
|
|
39
|
+
/**
|
|
40
|
+
* RUN THE APP'S OWN ACTOR ONCE. Blocking and a model, when lent, judge
|
|
41
|
+
* the store as the actor sees it; the judges' rules judge what the model
|
|
42
|
+
* did not; each judgment is routed by its confidence and severity, surest
|
|
43
|
+
* first up to `limit`. A change a person declined is never asked again;
|
|
44
|
+
* one already waiting is not asked twice; whatever the store refuses is
|
|
45
|
+
* reported, not thrown. Call it on the store that keeps the log — a
|
|
46
|
+
* server's, for a hosted app.
|
|
47
|
+
*/
|
|
48
|
+
export async function dream(store, options = {}) {
|
|
49
|
+
const whole = store;
|
|
50
|
+
const principal = options.principal ?? TIDYING_ACTOR;
|
|
51
|
+
if (!isAutomated(principal))
|
|
52
|
+
throw new Error("Only the app's own actor dreams: an author that says automated: true (a system or agent seat, never a person).");
|
|
53
|
+
const now = options.now === undefined ? Date.now() : new Date(options.now).getTime();
|
|
54
|
+
const context = {
|
|
55
|
+
store: whole.seenBy(principal),
|
|
56
|
+
now,
|
|
57
|
+
touched: touchedIn(whole),
|
|
58
|
+
quietFor: (options.quietHours ?? 24) * 60 * 60 * 1000,
|
|
59
|
+
olderThanDays: options.olderThanDays ?? 30,
|
|
60
|
+
};
|
|
61
|
+
const judges = options.judges ?? JUDGES;
|
|
62
|
+
// The model judges what blocking puts forward; what it answered is covered.
|
|
63
|
+
const judged = [];
|
|
64
|
+
const covered = new Set();
|
|
65
|
+
const model = systemOneOf(options.model, options.ai);
|
|
66
|
+
let modelSaid;
|
|
67
|
+
let usage;
|
|
68
|
+
let budget;
|
|
69
|
+
if (model) {
|
|
70
|
+
const blocks = await blocksOf(context, { families: new Set(judges.map((judge) => judge.name)), ...(nearOf(options.ai) ? { near: nearOf(options.ai) } : {}), ...(options.blocking ?? {}) });
|
|
71
|
+
const asks = asksOf(context.store, blocks);
|
|
72
|
+
const asked = await askAll(model, asks, {
|
|
73
|
+
...(options.concurrency !== undefined ? { concurrency: options.concurrency } : {}),
|
|
74
|
+
...(options.budget ? { budget: options.budget } : {}),
|
|
75
|
+
...(options.cache !== undefined ? { cache: options.cache } : {}),
|
|
76
|
+
});
|
|
77
|
+
let answered = 0;
|
|
78
|
+
asks.forEach((ask, at) => {
|
|
79
|
+
const answers = asked.answers[at];
|
|
80
|
+
if (!answers)
|
|
81
|
+
return;
|
|
82
|
+
answered++;
|
|
83
|
+
for (const cover of ask.covers)
|
|
84
|
+
covered.add(cover);
|
|
85
|
+
judged.push(...ask.read(answers, model.model));
|
|
86
|
+
});
|
|
87
|
+
modelSaid = { name: model.model, answered: answered > 0, asks: asks.length, judged: answered, ...(asked.error !== undefined ? { error: asked.error } : {}) };
|
|
88
|
+
usage = asked.usage;
|
|
89
|
+
if (asked.stopped) {
|
|
90
|
+
const left = asks.length - answered;
|
|
91
|
+
budget = `Stopped at the run's ${asked.stopped === "requests" ? "request" : "token"} budget after ${plural(asked.usage.requests, "request")}; ${plural(left, "candidate")} ${left === 1 ? "was" : "were"} left to the judges' own rules.`;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// The judges' own rules, for whatever the model did not judge: the floor.
|
|
95
|
+
const floor = judges.flatMap((judge) => judge.judge(context).map((candidate) => ({ ...candidate, severity: judge.severity ?? "archive" }))).filter((candidate) => !covered.has(coverOf(candidate)));
|
|
96
|
+
const waiting = new Set(suggestions(whole).map((one) => suggestionKey(one.calls)));
|
|
97
|
+
const outcomes = [];
|
|
98
|
+
const said = (candidate, outcome, more = {}) => outcomes.push({ judge: candidate.judge, outcome, calls: candidate.calls, basis: candidate.basis, confidence: candidate.confidence, about: candidate.about, ...(candidate.model ? { model: candidate.model } : {}), ...more });
|
|
99
|
+
const fresh = [];
|
|
100
|
+
const seen = new Set();
|
|
101
|
+
for (const candidate of [...judged, ...floor]) {
|
|
102
|
+
if (candidate.none || candidate.calls.length === 0) {
|
|
103
|
+
said(candidate, "dropped");
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
const key = suggestionKey(candidate.calls);
|
|
107
|
+
if (seen.has(key))
|
|
108
|
+
continue;
|
|
109
|
+
seen.add(key);
|
|
110
|
+
if (declined(whole, candidate.calls))
|
|
111
|
+
said(candidate, "declined");
|
|
112
|
+
else if (waiting.has(key))
|
|
113
|
+
said(candidate, "waiting");
|
|
114
|
+
else {
|
|
115
|
+
const route = routeOf(candidate.confidence, candidate.severity, options.bands, candidate.split === true);
|
|
116
|
+
if (route === "drop")
|
|
117
|
+
said(candidate, "dropped");
|
|
118
|
+
else
|
|
119
|
+
fresh.push({ candidate, route, at: fresh.length });
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
const limit = options.limit ?? 20;
|
|
123
|
+
const ranked = [...fresh].sort((a, b) => b.candidate.confidence - a.candidate.confidence || a.at - b.at).slice(0, limit);
|
|
124
|
+
// A record merged away in this run is not merged, or merged into, again.
|
|
125
|
+
const mergedAway = new Set();
|
|
126
|
+
const run = new Date(now).toISOString();
|
|
127
|
+
for (const { candidate, route } of ranked) {
|
|
128
|
+
const merge = candidate.judge === "duplicates" ? candidate.calls[0]?.args : undefined;
|
|
129
|
+
if (merge && (mergedAway.has(String(merge.id)) || mergedAway.has(String(merge.into)))) {
|
|
130
|
+
said(candidate, "dropped", { error: "One of the two was already proposed to merge into another in this run." });
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
const lineage = { basis: candidate.basis, confidence: candidate.confidence, run, actor: candidate.judge, ...(candidate.model ? { model: candidate.model } : {}) };
|
|
134
|
+
try {
|
|
135
|
+
if (route === "act" && options.applyAtLeast !== undefined && candidate.confidence >= options.applyAtLeast) {
|
|
136
|
+
const result = whole.applyAll(candidate.calls, { author: principal, lineage, ...(options.via ? { via: options.via } : {}) });
|
|
137
|
+
said(candidate, "applied", { id: result.batch });
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
const op = suggest(whole, candidate.calls, { author: principal, lineage, ...(options.via ? { via: options.via } : {}) });
|
|
141
|
+
if (op)
|
|
142
|
+
said(candidate, "suggested", { id: op.id });
|
|
143
|
+
}
|
|
144
|
+
if (merge)
|
|
145
|
+
mergedAway.add(String(merge.id));
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
said(candidate, "refused", { error: error instanceof Error ? error.message : String(error) });
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
const byJudge = {};
|
|
152
|
+
for (const judge of judges)
|
|
153
|
+
byJudge[judge.name] = { suggested: 0, applied: 0, skipped: 0 };
|
|
154
|
+
for (const one of outcomes) {
|
|
155
|
+
const tally = (byJudge[one.judge] ??= { suggested: 0, applied: 0, skipped: 0 });
|
|
156
|
+
if (one.outcome === "suggested")
|
|
157
|
+
tally.suggested++;
|
|
158
|
+
else if (one.outcome === "applied")
|
|
159
|
+
tally.applied++;
|
|
160
|
+
else
|
|
161
|
+
tally.skipped++;
|
|
162
|
+
}
|
|
163
|
+
const suggested = outcomes.filter((one) => one.outcome === "suggested").length;
|
|
164
|
+
const applied = outcomes.filter((one) => one.outcome === "applied").length;
|
|
165
|
+
return {
|
|
166
|
+
run,
|
|
167
|
+
outcomes,
|
|
168
|
+
byJudge,
|
|
169
|
+
...(modelSaid ? { model: modelSaid } : {}),
|
|
170
|
+
...(usage ? { usage } : {}),
|
|
171
|
+
...(budget ? { budget } : {}),
|
|
172
|
+
applying: options.applyAtLeast === undefined
|
|
173
|
+
? "Nothing was applied: the host did not let the actor apply on its own (applyAtLeast), so every change sure enough to ask about was suggested."
|
|
174
|
+
: `Changes at least ${options.applyAtLeast} sure, and sure enough for how much they would undo, were applied where the app and its people allow it.`,
|
|
175
|
+
said: suggested + applied === 0 ? "Nothing to tidy." : [suggested > 0 ? `Suggested ${plural(suggested, "change")}` : "", applied > 0 ? `applied ${plural(applied, "change")}` : ""].filter(Boolean).join(" and ").replace(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AC,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,CAAC,CAAC,aAAa,MAAM,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,OAAO,GAAG,CAAC,CAAC,CAAC,CAAC,WAAW,MAAM,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,GAAG,GAAG;KAC3O,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { type AnySchema, type MutationCall, type Store } from "@graview/core";
|
|
2
|
+
import type { Severity } from "./policy.js";
|
|
3
|
+
type Node = {
|
|
4
|
+
readonly id: string;
|
|
5
|
+
readonly kind: string;
|
|
6
|
+
} & Record<string, unknown>;
|
|
7
|
+
/** One change a judge would make: the calls, what it is based on, and how sure (0 to 1). */
|
|
8
|
+
export interface Candidate {
|
|
9
|
+
/** The judge that found it: "duplicates", "links", "archive". */
|
|
10
|
+
readonly judge: string;
|
|
11
|
+
readonly calls: readonly MutationCall[];
|
|
12
|
+
/** Words a person reads: "Same name as “Acme” (another vendor)". */
|
|
13
|
+
readonly basis: string;
|
|
14
|
+
readonly confidence: number;
|
|
15
|
+
/** The records it is about, so a model and a report can name them. */
|
|
16
|
+
readonly about: readonly string[];
|
|
17
|
+
}
|
|
18
|
+
/** What a judge is handed: the store as the actor sees it, and the run's clock and limits. */
|
|
19
|
+
export interface JudgeContext {
|
|
20
|
+
readonly store: Store<AnySchema>;
|
|
21
|
+
/** The run's moment, in milliseconds. */
|
|
22
|
+
readonly now: number;
|
|
23
|
+
/** When each record was last changed, from the log; a record the log never touched is absent. */
|
|
24
|
+
readonly touched: ReadonlyMap<string, number>;
|
|
25
|
+
/** Records changed more recently than this many milliseconds are left for now. */
|
|
26
|
+
readonly quietFor: number;
|
|
27
|
+
/** How old, in days, a finished record is before it is a candidate to set aside. */
|
|
28
|
+
readonly olderThanDays: number;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* A judge: a name, how much what it proposes would undo, and what it finds
|
|
32
|
+
* from the graph alone — the floor a dream stands on when no model answers.
|
|
33
|
+
* A model, when lent, judges the same things more broadly (`./judging.ts`).
|
|
34
|
+
*/
|
|
35
|
+
export interface Judge {
|
|
36
|
+
readonly name: string;
|
|
37
|
+
/** How much its changes would undo, which sets how sure it must be (`BANDS`). "archive" when unsaid. */
|
|
38
|
+
readonly severity?: Severity;
|
|
39
|
+
judge(context: JudgeContext): readonly Candidate[];
|
|
40
|
+
}
|
|
41
|
+
/** Whether the actor may propose anything about this record: not left alone, not changed lately, its kind tidied. */
|
|
42
|
+
export declare function mayTouch(context: JudgeContext, node: Node): boolean;
|
|
43
|
+
/** A kind's acts as the store holds them, by name. */
|
|
44
|
+
export declare const actNamed: (store: Store<AnySchema>, name: string) => import("@graview/core").AnyMutationDefinition<AnySchema> | undefined;
|
|
45
|
+
export declare const named: (schema: AnySchema, node: Node) => string;
|
|
46
|
+
export declare const noun: (schema: AnySchema, kind: string) => string;
|
|
47
|
+
export declare const fieldsOf: (schema: AnySchema, kind: string) => string[];
|
|
48
|
+
/** Fields whose value names one thing and only that thing: two records that share one are the same. */
|
|
49
|
+
export declare const KEY_FIELD: RegExp;
|
|
50
|
+
/** The one of several that stays: the one with the most links and history, else the first made. */
|
|
51
|
+
export declare function keeperOf(store: Store<AnySchema>, nodes: readonly Node[], touched: ReadonlyMap<string, number>): Node;
|
|
52
|
+
/**
|
|
53
|
+
* DUPLICATES → MERGE. Records of one kind that share a name — case,
|
|
54
|
+
* accents and spacing aside, as an import matches a row to its record
|
|
55
|
+
* (`nameKey`) — or a key a record has only one of (an email, a code). The
|
|
56
|
+
* one with the most links stays; each other is merged into it
|
|
57
|
+
* (`merge-<kind>`). An exact name is surer than one that matches only with
|
|
58
|
+
* its punctuation aside; a shared key is surest.
|
|
59
|
+
*/
|
|
60
|
+
export declare const duplicates: Judge;
|
|
61
|
+
/** The act that links a kind's records along a relation, and the argument the far record goes in: the derived connect, else a declared act that `connects` it. */
|
|
62
|
+
export declare function connectOf(store: Store<AnySchema>, kind: string, relation: string, targets: readonly string[]): {
|
|
63
|
+
readonly name: string;
|
|
64
|
+
readonly to: string;
|
|
65
|
+
} | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* LINKS FROM SHARED VALUES. A record whose text names another record —
|
|
68
|
+
* a field that says exactly what the other is called, or names it among
|
|
69
|
+
* other words — is linked to it through a relation the declaration already
|
|
70
|
+
* has whose far end is that record's kind; a relation is never invented.
|
|
71
|
+
* A cardinality-one relation that already holds a link is left as it is;
|
|
72
|
+
* a name two records of the far kind share says nothing. An exact name is
|
|
73
|
+
* surer than one named in passing.
|
|
74
|
+
*/
|
|
75
|
+
export declare const links: Judge;
|
|
76
|
+
/**
|
|
77
|
+
* HOW THE APP SAYS A RECORD IS FINISHED, from its declaration: its
|
|
78
|
+
* lifecycle (a value that retires it, or a date it expires after), else
|
|
79
|
+
* its main choice field read as the map reads it (`districtState`: a
|
|
80
|
+
* value like done, shipped, closed), else a yes/no field called done,
|
|
81
|
+
* completed or closed. Undefined when the kind says no such thing.
|
|
82
|
+
*/
|
|
83
|
+
export declare function finishedOf(schema: AnySchema, kind: string, today: string): ((node: Node) => string | undefined) | undefined;
|
|
84
|
+
/** When a record last moved: the log's last change to it, else the date its declaration reads it by (a lifecycle date, an end or due role). */
|
|
85
|
+
export declare function lastMoved(schema: AnySchema, node: Node, touched: ReadonlyMap<string, number>): number | undefined;
|
|
86
|
+
/**
|
|
87
|
+
* DONE AND OLD → SET ASIDE. A record its kind says is finished, unchanged
|
|
88
|
+
* for longer than the run's `olderThanDays`, is a candidate to archive
|
|
89
|
+
* (`archive-<kind>`): out of lists and counts, its links and history kept,
|
|
90
|
+
* "Bring it back" one act away. Only kinds that archive; a record whose age
|
|
91
|
+
* nothing says is left.
|
|
92
|
+
*/
|
|
93
|
+
export declare const archive: Judge;
|
|
94
|
+
/**
|
|
95
|
+
* AN EMPTY CHOICE, FILLED IN (`edit-<kind>`). Which of a field's options a
|
|
96
|
+
* record is takes reading it, so the graph alone proposes nothing: only a
|
|
97
|
+
* model, when lent, judges it (`./judging.ts`).
|
|
98
|
+
*/
|
|
99
|
+
export declare const categorize: Judge;
|
|
100
|
+
/**
|
|
101
|
+
* AN EMPTY ONE-LINK RELATION, FILLED IN. Without a model the floor is the
|
|
102
|
+
* `links` judge's — a far record the record's own text names; a model, when
|
|
103
|
+
* lent, chooses among the likeliest records of the far kind, or none.
|
|
104
|
+
*/
|
|
105
|
+
export declare const missingLinks: Judge;
|
|
106
|
+
/** The judges a run uses unless told otherwise. */
|
|
107
|
+
export declare const JUDGES: readonly Judge[];
|
|
108
|
+
export {};
|
|
109
|
+
//# sourceMappingURL=judges.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"judges.d.ts","sourceRoot":"","sources":["../../src/tidy/judges.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6E,KAAK,SAAS,EAAE,KAAK,YAAY,EAAE,KAAK,KAAK,EAAE,MAAM,eAAe,CAAC;AAIzJ,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAa5C,KAAK,IAAI,GAAG;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAErF,4FAA4F;AAC5F,MAAM,WAAW,SAAS;IACxB,iEAAiE;IACjE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,SAAS,YAAY,EAAE,CAAC;IACxC,oEAAoE;IACpE,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,UAAU,EAAE,MA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labelOf, nameKey, nodeRefArgs, nounOf } from "@graview/core";
|
|
2
|
+
import { districtState } from "@graview/core/city";
|
|
3
|
+
import { fold } from "@graview/core/search";
|
|
4
|
+
import { tidyingOf } from "@graview/core/tidying";
|
|
5
|
+
const DAY = 24 * 60 * 60 * 1000;
|
|
6
|
+
/** Whether the actor may propose anything about this record: not left alone, not changed lately, its kind tidied. */
|
|
7
|
+
export function mayTouch(context, node) {
|
|
8
|
+
if (isLeftAlone(context.store, node.id) || isArchived(node))
|
|
9
|
+
return false;
|
|
10
|
+
if (tidyingOf(context.store.schema, node.kind) === "never")
|
|
11
|
+
return false;
|
|
12
|
+
const last = context.touched.get(node.id);
|
|
13
|
+
return last === undefined || context.now - last >= context.quietFor;
|
|
14
|
+
}
|
|
15
|
+
/** A kind's acts as the store holds them, by name. */
|
|
16
|
+
export const actNamed = (store, name) => store.allMutations().find((act) => act.name === name);
|
|
17
|
+
export const named = (schema, node) => labelOf(schema.tryDefinition(node.kind), node);
|
|
18
|
+
export const noun = (schema, kind) => nounOf(schema.tryDefinition(kind), kind);
|
|
19
|
+
export const fieldsOf = (schema, kind) => Object.keys((schema.tryDefinition(kind)?.fields.shape ?? {}));
|
|
20
|
+
/** Fields whose value names one thing and only that thing: two records that share one are the same. */
|
|
21
|
+
export const KEY_FIELD = /^(e-?mail|email-?address|code|sku|reference|ref|external-?id|key)$/i;
|
|
22
|
+
/** The one of several that stays: the one with the most links and history, else the first made. */
|
|
23
|
+
export function keeperOf(store, nodes, touched) {
|
|
24
|
+
const weight = (node) => store.graph.out(node.id).length + store.graph.in(node.id).length;
|
|
25
|
+
return [...nodes].sort((a, b) => weight(b) - weight(a) || (touched.get(a.id) ?? 0) - (touched.get(b.id) ?? 0))[0];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* DUPLICATES → MERGE. Records of one kind that share a name — case,
|
|
29
|
+
* accents and spacing aside, as an import matches a row to its record
|
|
30
|
+
* (`nameKey`) — or a key a record has only one of (an email, a code). The
|
|
31
|
+
* one with the most links stays; each other is merged into it
|
|
32
|
+
* (`merge-<kind>`). An exact name is surer than one that matches only with
|
|
33
|
+
* its punctuation aside; a shared key is surest.
|
|
34
|
+
*/
|
|
35
|
+
export const duplicates = {
|
|
36
|
+
name: "duplicates",
|
|
37
|
+
severity: "merge",
|
|
38
|
+
judge(context) {
|
|
39
|
+
const { store } = context;
|
|
40
|
+
const schema = store.schema;
|
|
41
|
+
const out = [];
|
|
42
|
+
for (const definition of schema.definitions) {
|
|
43
|
+
const kind = definition.kind;
|
|
44
|
+
if (definition.archives === false || !actNamed(store, `merge-${kind}`))
|
|
45
|
+
continue;
|
|
46
|
+
const records = store.graph.nodesOfKind(kind);
|
|
47
|
+
const keys = fieldsOf(schema, kind).filter((field) => KEY_FIELD.test(field));
|
|
48
|
+
const merged = new Set();
|
|
49
|
+
const groups = [];
|
|
50
|
+
const group = (key, basis, confidence) => {
|
|
51
|
+
const by = new Map();
|
|
52
|
+
for (const node of records) {
|
|
53
|
+
if (merged.has(node.id))
|
|
54
|
+
continue;
|
|
55
|
+
const value = key(node);
|
|
56
|
+
if (value)
|
|
57
|
+
by.set(value, [...(by.get(value) ?? []), node]);
|
|
58
|
+
}
|
|
59
|
+
for (const [value, nodes] of by)
|
|
60
|
+
if (nodes.length > 1) {
|
|
61
|
+
groups.push({ nodes, basis: (keeper) => basis(keeper, value), confidence });
|
|
62
|
+
for (const node of nodes)
|
|
63
|
+
merged.add(node.id);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
for (const field of keys) {
|
|
67
|
+
group((node) => (typeof node[field] === "string" && node[field].trim() ? nameKey(node[field]) : undefined), (_keeper, value) => `Both have the ${field} ${value}`, 0.95);
|
|
68
|
+
}
|
|
69
|
+
group((node) => nameKey(named(schema, node)) || undefined, (keeper) => `Same name as “${named(schema, keeper)}” (another ${noun(schema, kind)})`, 0.9);
|
|
70
|
+
group((node) => fold(named(schema, node)).replace(/ /g, "") || undefined, (keeper) => `Nearly the same name as “${named(schema, keeper)}”, punctuation and spacing aside`, 0.75);
|
|
71
|
+
for (const { nodes, basis, confidence } of groups) {
|
|
72
|
+
const keeper = keeperOf(store, nodes, context.touched);
|
|
73
|
+
if (!mayTouch(context, keeper))
|
|
74
|
+
continue;
|
|
75
|
+
for (const node of nodes) {
|
|
76
|
+
if (node.id === keeper.id || !mayTouch(context, node))
|
|
77
|
+
continue;
|
|
78
|
+
out.push({ judge: "duplicates", calls: [{ name: `merge-${kind}`, args: { id: node.id, into: keeper.id } }], basis: basis(keeper), confidence, about: [node.id, keeper.id] });
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return out;
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
/** The act that links a kind's records along a relation, and the argument the far record goes in: the derived connect, else a declared act that `connects` it. */
|
|
86
|
+
export function connectOf(store, kind, relation, targets) {
|
|
87
|
+
for (const act of store.allMutations()) {
|
|
88
|
+
if (!(act.connects ?? []).includes(relation) || act.subject?.arg === undefined || !act.subject.kinds?.includes(kind))
|
|
89
|
+
continue;
|
|
90
|
+
const refs = nodeRefArgs(act.input).filter((ref) => ref.name !== act.subject.arg);
|
|
91
|
+
// One other record it takes, of the kinds the relation reaches: anything more is the act's own business.
|
|
92
|
+
const far = refs.filter((ref) => ref.kinds.includes("*") || targets.some((target) => ref.kinds.includes(target)));
|
|
93
|
+
if (act.subject.arg === "id" && far.length === 1 && refs.length === 1)
|
|
94
|
+
return { name: act.name, to: far[0].name };
|
|
95
|
+
}
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
/** Whether `inside` holds `words` as whole words, folded. */
|
|
99
|
+
const holdsWords = (inside, words) => ` ${inside} `.includes(` ${words} `);
|
|
100
|
+
/**
|
|
101
|
+
* LINKS FROM SHARED VALUES. A record whose text names another record —
|
|
102
|
+
* a field that says exactly what the other is called, or names it among
|
|
103
|
+
* other words — is linked to it through a relation the declaration already
|
|
104
|
+
* has whose far end is that record's kind; a relation is never invented.
|
|
105
|
+
* A cardinality-one relation that already holds a link is left as it is;
|
|
106
|
+
* a name two records of the far kind share says nothing. An exact name is
|
|
107
|
+
* surer than one named in passing.
|
|
108
|
+
*/
|
|
109
|
+
export const links = {
|
|
110
|
+
name: "links",
|
|
111
|
+
severity: "link",
|
|
112
|
+
judge(context) {
|
|
113
|
+
const { store } = context;
|
|
114
|
+
const schema = store.schema;
|
|
115
|
+
const out = [];
|
|
116
|
+
for (const definition of schema.definitions) {
|
|
117
|
+
const kind = definition.kind;
|
|
118
|
+
if (tidyingOf(schema, kind) === "no-links")
|
|
119
|
+
continue;
|
|
120
|
+
const hidden = new Set(definition.display?.hide ?? []);
|
|
121
|
+
for (const [relation, edge] of Object.entries(definition.edges ?? {})) {
|
|
122
|
+
if (edge.acts === "none" || tidyingOf(schema, kind, relation) === "never")
|
|
123
|
+
continue;
|
|
124
|
+
const targets = edge.to === "*" ? schema.definitions.map((one) => one.kind) : edge.to;
|
|
125
|
+
const act = connectOf(store, kind, relation, targets);
|
|
126
|
+
if (!act)
|
|
127
|
+
continue;
|
|
128
|
+
// The far records by their folded name; a name two of them share names neither.
|
|
129
|
+
const byName = new Map();
|
|
130
|
+
for (const target of targets) {
|
|
131
|
+
if (tidyingOf(schema, target) === "never" || tidyingOf(schema, target) === "no-links")
|
|
132
|
+
continue;
|
|
133
|
+
for (const node of store.graph.nodesOfKind(target)) {
|
|
134
|
+
const name = fold(named(schema, node));
|
|
135
|
+
if (name.replace(/ /g, "").length < 3)
|
|
136
|
+
continue;
|
|
137
|
+
byName.set(name, byName.has(name) ? null : node);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
for (const node of store.graph.nodesOfKind(kind)) {
|
|
141
|
+
if (!mayTouch(context, node))
|
|
142
|
+
continue;
|
|
143
|
+
const linked = new Set(store.graph.out(node.id, relation).map((one) => one.id));
|
|
144
|
+
if (edge.cardinality === "one" && linked.size > 0)
|
|
145
|
+
continue;
|
|
146
|
+
const own = fold(named(schema, node));
|
|
147
|
+
const found = new Map();
|
|
148
|
+
for (const field of fieldsOf(schema, kind)) {
|
|
149
|
+
const value = node[field];
|
|
150
|
+
if (hidden.has(field) || typeof value !== "string" || !value.trim())
|
|
151
|
+
continue;
|
|
152
|
+
const said = fold(value);
|
|
153
|
+
for (const [name, far] of byName) {
|
|
154
|
+
if (!far || far.id === node.id || linked.has(far.id) || name === own)
|
|
155
|
+
continue;
|
|
156
|
+
const exact = said === name;
|
|
157
|
+
if (!exact && !holdsWords(said, name))
|
|
158
|
+
continue;
|
|
159
|
+
const was = found.get(far.id);
|
|
160
|
+
if (!was || (exact && !was.exact))
|
|
161
|
+
found.set(far.id, { far, field, exact });
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
const ranked = [...found.values()].sort((a, b) => Number(b.exact) - Number(a.exact));
|
|
165
|
+
// One link to hold, and two equally named: nothing to say.
|
|
166
|
+
const picked = edge.cardinality === "one" ? (ranked.length === 1 || (ranked[0]?.exact && !ranked[1]?.exact) ? ranked.slice(0, 1) : []) : ranked;
|
|
167
|
+
for (const { far, field, exact } of picked) {
|
|
168
|
+
if (!mayTouch(context, far))
|
|
169
|
+
continue;
|
|
170
|
+
const farNoun = noun(schema, far.kind);
|
|
171
|
+
out.push({
|
|
172
|
+
judge: "links",
|
|
173
|
+
calls: [{ name: act.name, args: { id: node.id, [act.to]: far.id } }],
|
|
174
|
+
basis: exact ? `Its ${field} is “${named(schema, far)}”, the name of ${/^[aeiou]/i.test(farNoun) ? "an" : "a"} ${farNoun}` : `Its ${field} names “${named(schema, far)}”`,
|
|
175
|
+
confidence: exact ? 0.85 : 0.5,
|
|
176
|
+
about: [node.id, far.id],
|
|
177
|
+
});
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
return out;
|
|
183
|
+
},
|
|
184
|
+
};
|
|
185
|
+
/**
|
|
186
|
+
* HOW THE APP SAYS A RECORD IS FINISHED, from its declaration: its
|
|
187
|
+
* lifecycle (a value that retires it, or a date it expires after), else
|
|
188
|
+
* its main choice field read as the map reads it (`districtState`: a
|
|
189
|
+
* value like done, shipped, closed), else a yes/no field called done,
|
|
190
|
+
* completed or closed. Undefined when the kind says no such thing.
|
|
191
|
+
*/
|
|
192
|
+
export function finishedOf(schema, kind, today) {
|
|
193
|
+
const definition = schema.tryDefinition(kind);
|
|
194
|
+
if (!definition)
|
|
195
|
+
return undefined;
|
|
196
|
+
const lifecycle = definition.lifecycle;
|
|
197
|
+
if (lifecycle) {
|
|
198
|
+
return (node) => (isCurrent(definition, node, today) ? undefined : lifecycle.retired === "date" ? `its ${lifecycle.field} has passed` : `its ${lifecycle.field} is “${String(node[lifecycle.field])}”`);
|
|
199
|
+
}
|
|
200
|
+
const state = districtState(schema, kind);
|
|
201
|
+
if (state && state.tiers.includes("done")) {
|
|
202
|
+
const done = new Set(state.values.filter((_, at) => state.tiers[at] === "done"));
|
|
203
|
+
return (node) => (done.has(node[state.field]) ? `its ${state.field} is “${String(node[state.field])}”` : undefined);
|
|
204
|
+
}
|
|
205
|
+
const flag = fieldsOf(schema, kind).find((field) => /^(done|completed|closed|finished)$/i.test(field));
|
|
206
|
+
return flag ? (node) => (node[flag] === true ? `it is marked ${flag}` : undefined) : undefined;
|
|
207
|
+
}
|
|
208
|
+
/** When a record last moved: the log's last change to it, else the date its declaration reads it by (a lifecycle date, an end or due role). */
|
|
209
|
+
export function lastMoved(schema, node, touched) {
|
|
210
|
+
const logged = touched.get(node.id);
|
|
211
|
+
if (logged !== undefined)
|
|
212
|
+
return logged;
|
|
213
|
+
const definition = schema.tryDefinition(node.kind);
|
|
214
|
+
const roles = definition?.fieldRoles ?? {};
|
|
215
|
+
for (const field of [definition?.lifecycle?.retired === "date" ? definition.lifecycle.field : undefined, roles["end"], roles["due"], roles["at"], roles["start"]]) {
|
|
216
|
+
const value = field ? node[field] : undefined;
|
|
217
|
+
const at = typeof value === "string" ? Date.parse(value) : Number.NaN;
|
|
218
|
+
if (!Number.isNaN(at))
|
|
219
|
+
return at;
|
|
220
|
+
}
|
|
221
|
+
return undefined;
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* DONE AND OLD → SET ASIDE. A record its kind says is finished, unchanged
|
|
225
|
+
* for longer than the run's `olderThanDays`, is a candidate to archive
|
|
226
|
+
* (`archive-<kind>`): out of lists and counts, its links and history kept,
|
|
227
|
+
* "Bring it back" one act away. Only kinds that archive; a record whose age
|
|
228
|
+
* nothing says is left.
|
|
229
|
+
*/
|
|
230
|
+
export const archive = {
|
|
231
|
+
name: "archive",
|
|
232
|
+
severity: "archive",
|
|
233
|
+
judge(context) {
|
|
234
|
+
const { store } = context;
|
|
235
|
+
const schema = store.schema;
|
|
236
|
+
const today = new Date(context.now).toISOString().slice(0, 10);
|
|
237
|
+
const out = [];
|
|
238
|
+
for (const definition of schema.definitions) {
|
|
239
|
+
const kind = definition.kind;
|
|
240
|
+
if (definition.archives === false || !actNamed(store, `archive-${kind}`))
|
|
241
|
+
continue;
|
|
242
|
+
const finished = finishedOf(schema, kind, today);
|
|
243
|
+
if (!finished)
|
|
244
|
+
continue;
|
|
245
|
+
for (const node of store.graph.nodesOfKind(kind)) {
|
|
246
|
+
if (!mayTouch(context, node))
|
|
247
|
+
continue;
|
|
248
|
+
const why = finished(node);
|
|
249
|
+
const moved = why ? lastMoved(schema, node, context.touched) : undefined;
|
|
250
|
+
if (!why || moved === undefined)
|
|
251
|
+
continue;
|
|
252
|
+
const days = Math.floor((context.now - moved) / DAY);
|
|
253
|
+
if (days < context.olderThanDays)
|
|
254
|
+
continue;
|
|
255
|
+
out.push({
|
|
256
|
+
judge: "archive",
|
|
257
|
+
calls: [{ name: `archive-${kind}`, args: { id: node.id } }],
|
|
258
|
+
basis: `Finished — ${why} — and unchanged for ${days} days`,
|
|
259
|
+
// Older is surer, never certain: a person may still be reading it.
|
|
260
|
+
confidence: Math.min(0.8, 0.6 + days / 365),
|
|
261
|
+
about: [node.id],
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
return out;
|
|
266
|
+
},
|
|
267
|
+
};
|
|
268
|
+
/**
|
|
269
|
+
* AN EMPTY CHOICE, FILLED IN (`edit-<kind>`). Which of a field's options a
|
|
270
|
+
* record is takes reading it, so the graph alone proposes nothing: only a
|
|
271
|
+
* model, when lent, judges it (`./judging.ts`).
|
|
272
|
+
*/
|
|
273
|
+
export const categorize = { name: "categorize", severity: "categorize", judge: () => [] };
|
|
274
|
+
/**
|
|
275
|
+
* AN EMPTY ONE-LINK RELATION, FILLED IN. Without a model the floor is the
|
|
276
|
+
* `links` judge's — a far record the record's own text names; a model, when
|
|
277
|
+
* lent, chooses among the likeliest records of the far kind, or none.
|
|
278
|
+
*/
|
|
279
|
+
export const missingLinks = { name: "missing-links", severity: "link", judge: () => [] };
|
|
280
|
+
/** The judges a run uses unless told otherwise. */
|
|
281
|
+
export const JUDGES = [duplicates, links, archive, categorize, missingLinks];
|
|
282
|
+
//# sourceMappingURL=judges.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"judges.js","sourceRoot":"","sources":["../../src/tidy/judges.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAiD,MAAM,eAAe,CAAC;AACzJ,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAqDlD,MAAM,GAAG,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAEhC,qHAAqH;AACrH,MAAM,UAAU,QAAQ,CAAC,OAAqB,EAAE,IAAU;IACxD,IAAI,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,EAAE,CAAC,IAAI,UA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