@startsimpli/integrations 0.2.214 → 0.2.216
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/package.json +5 -5
- package/src/__tests__/briefing-record-library.test.ts +47 -0
- package/src/__tests__/connect-claude.test.tsx +2 -0
- package/src/__tests__/corpus-tracker.test.tsx +13 -2
- package/src/__tests__/engine-decide.test.ts +160 -0
- package/src/__tests__/engine-extract-policy.test.ts +145 -0
- package/src/__tests__/engine-replay.test.ts +126 -0
- package/src/__tests__/engine-scheduled-run.test.ts +82 -0
- package/src/__tests__/extract-skips-tandem-authored.test.ts +34 -0
- package/src/__tests__/load-error.test.tsx +3 -1
- package/src/__tests__/suggested-items-hidden.test.ts +74 -0
- package/src/__tests__/suggestion-ui.test.tsx +97 -0
- package/src/__tests__/todo-table.test.tsx +2 -1
- package/src/components/pages/ConnectClaudePage.tsx +2 -1
- package/src/components/pages/TaskDetailPage.tsx +10 -0
- package/src/components/pages/TrackerPage.tsx +32 -10
- package/src/components/pages/tracker/Suggestion.tsx +66 -0
- package/src/components/table/todo-model.ts +1 -0
- package/src/corpus/activity.ts +2 -3
- package/src/corpus/ask-items.ts +2 -2
- package/src/corpus/briefing/compose.ts +2 -2
- package/src/corpus/briefing/weekly.ts +2 -2
- package/src/corpus/briefing-text.ts +11 -0
- package/src/corpus/client.ts +2 -0
- package/src/corpus/commitments.ts +20 -3
- package/src/corpus/converse/briefing-queue.ts +2 -1
- package/src/corpus/converse/item-answers.ts +2 -2
- package/src/corpus/due-groups.ts +2 -2
- package/src/corpus/engine/apply.ts +111 -0
- package/src/corpus/engine/decide.ts +106 -0
- package/src/corpus/engine/dry-extract.ts +98 -0
- package/src/corpus/engine/graduation.ts +49 -0
- package/src/corpus/engine/index.ts +14 -0
- package/src/corpus/engine/replay.ts +222 -0
- package/src/corpus/engine/rules.ts +58 -0
- package/src/corpus/engine/sources.ts +16 -0
- package/src/corpus/engine/suggestion.ts +72 -0
- package/src/corpus/engine/types.ts +147 -0
- package/src/corpus/entities.ts +9 -2
- package/src/corpus/extract-prompts.ts +139 -0
- package/src/corpus/extract.ts +46 -139
- package/src/corpus/focus-overview.ts +2 -2
- package/src/corpus/index.ts +9 -0
- package/src/corpus/item-status.ts +17 -0
- package/src/corpus/note-actions.ts +3 -3
- package/src/corpus/questions/derive.ts +2 -1
- package/src/corpus/questions/sync.ts +2 -1
- package/src/corpus/retrieval.ts +3 -0
- package/src/corpus/runs.ts +31 -2
- package/src/corpus/today.ts +2 -2
- package/src/corpus/tracker-groups.ts +3 -0
- package/src/corpus/tracker-timeline-client.ts +1 -1
- package/src/corpus/types.ts +13 -3
- package/src/native/screens/connect-claude/ConnectClaudeScreen.tsx +1 -1
- package/src/native/screens/connect-claude/fake.ts +1 -1
- package/src/native/tracker/format.ts +1 -1
|
@@ -17,6 +17,7 @@ import { normalizeSpeech, spokenWhen, splitWhen } from '../briefing/intent/dates
|
|
|
17
17
|
import type { VoiceAction } from '../briefing/intent/types';
|
|
18
18
|
import { contentWords } from '../briefing/intent/match';
|
|
19
19
|
import { dueDay, localDate } from '../today';
|
|
20
|
+
import { isLiveStatus } from '../item-status';
|
|
20
21
|
|
|
21
22
|
export interface QueueItem {
|
|
22
23
|
id: string;
|
|
@@ -129,7 +130,7 @@ function rank(a: { i: BriefingItem; day: string }, b: { i: BriefingItem; day: st
|
|
|
129
130
|
export function rankQueue(input: QueueInput): { queue: QueueItem[]; older: number } {
|
|
130
131
|
const today = localDate(input.now, input.timeZone);
|
|
131
132
|
const skipped = new Set(input.skipped ?? []);
|
|
132
|
-
const open = (i: BriefingItem) =>
|
|
133
|
+
const open = (i: BriefingItem) => isLiveStatus(i.status) && !['completed', 'canceled'].includes(i.linearState ?? '');
|
|
133
134
|
const ranked = input.items
|
|
134
135
|
.filter(open)
|
|
135
136
|
.filter((i) => !skipped.has(i.id))
|
|
@@ -8,6 +8,7 @@ import { speakable } from '../briefing/speak';
|
|
|
8
8
|
import type { BriefingItem } from '../briefing/types';
|
|
9
9
|
import { dueDay } from '../today';
|
|
10
10
|
import type { ConverseSource } from './types';
|
|
11
|
+
import { isLiveStatus } from '../item-status';
|
|
11
12
|
|
|
12
13
|
/** Words that may appear in a due-date question without making it about something else. */
|
|
13
14
|
const PLAIN = new Set(('what whats what\'s which is are do does did have has had i my me mine the this next last that and a an all any anything ' +
|
|
@@ -15,7 +16,6 @@ const PLAIN = new Set(('what whats what\'s which is are do does did have has had
|
|
|
15
16
|
'due overdue late behind slipping slipped missed today tomorrow yesterday week month weekend ' +
|
|
16
17
|
'monday tuesday wednesday thursday friday saturday sunday').split(/\s+/));
|
|
17
18
|
|
|
18
|
-
const FINISHED = new Set(['done', 'dropped']);
|
|
19
19
|
const LINEAR_FINISHED = new Set(['completed', 'canceled', 'cancelled']);
|
|
20
20
|
|
|
21
21
|
function listOf(titles: string[], total: number): string {
|
|
@@ -46,7 +46,7 @@ export function itemAnswer(input: { question: string; items: BriefingItem[]; now
|
|
|
46
46
|
if (extra.some((w) => !covered.has(w) && !['for', 'in', 'on'].includes(w))) return null;
|
|
47
47
|
|
|
48
48
|
const today = intent.today;
|
|
49
|
-
const open = items.filter((i) =>
|
|
49
|
+
const open = items.filter((i) => isLiveStatus(i.status) && !LINEAR_FINISHED.has(i.linearState ?? '')
|
|
50
50
|
&& (!ownerSub || !i.ownerSub || i.ownerSub === ownerSub)
|
|
51
51
|
&& (!asked.size || (i.focusName && asked.has(i.focusName.trim()))));
|
|
52
52
|
const dated = open.map((i) => ({ i, day: dueDay(i.dueAt, timeZone) }));
|
package/src/corpus/due-groups.ts
CHANGED
|
@@ -11,6 +11,7 @@
|
|
|
11
11
|
*/
|
|
12
12
|
import { dueDay, localDate } from './today';
|
|
13
13
|
import type { Commitment } from './types';
|
|
14
|
+
import { isLiveStatus } from './item-status';
|
|
14
15
|
|
|
15
16
|
export type DueBucket = 'overdue' | 'today' | 'week' | 'later';
|
|
16
17
|
|
|
@@ -41,7 +42,6 @@ export interface DueGroups<T = Commitment> {
|
|
|
41
42
|
|
|
42
43
|
type Dueable = Pick<Commitment, 'status' | 'dueAt'> & { priority?: number };
|
|
43
44
|
|
|
44
|
-
const FINISHED = new Set(['done', 'dropped']);
|
|
45
45
|
|
|
46
46
|
/** Whole calendar days from `from` to `to` (both `YYYY-MM-DD`). */
|
|
47
47
|
export function daysBetween(from: string, to: string): number {
|
|
@@ -65,7 +65,7 @@ export function groupDue<T extends Dueable>(
|
|
|
65
65
|
let undated = 0;
|
|
66
66
|
let total = 0;
|
|
67
67
|
for (const item of items) {
|
|
68
|
-
if (
|
|
68
|
+
if (!isLiveStatus(item.status)) continue;
|
|
69
69
|
const due = dueDay(item.dueAt, timeZone);
|
|
70
70
|
if (!due) { undated += 1; continue; }
|
|
71
71
|
const days = daysBetween(today, due);
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE POLICY IN THE WRITE PATH (bd startsim-vrmx5 slice 2).
|
|
3
|
+
*
|
|
4
|
+
* Extraction hands over the items a run would CREATE; each one is judged by
|
|
5
|
+
* `decide` and comes back either as it was (act), as a suggestion (propose:
|
|
6
|
+
* status `suggested`, kept off every list and out of the tracker until the owner
|
|
7
|
+
* accepts it), or not at all (skip). Every kept item carries its decision in
|
|
8
|
+
* `suggestion`, so the "why" line and the review buttons have what they need.
|
|
9
|
+
*
|
|
10
|
+
* Items are only ever the pass owner's: a source owned by someone else is
|
|
11
|
+
* skipped (X-OWNER), and an item about the owner is stamped with the owner's id
|
|
12
|
+
* so the row belongs to the person whose source it came from.
|
|
13
|
+
*/
|
|
14
|
+
import { decide } from './decide';
|
|
15
|
+
import { suggestionOf } from './suggestion';
|
|
16
|
+
import { SUGGESTED_STATUS } from '../item-status';
|
|
17
|
+
import type { Commitment, SourceDocument } from '../types';
|
|
18
|
+
import type { DecisionLabel, OwnerRelation, RuleId } from './types';
|
|
19
|
+
|
|
20
|
+
export interface EngineScope {
|
|
21
|
+
/** The person the pass runs for; every source must be theirs. */
|
|
22
|
+
ownerSub: string;
|
|
23
|
+
/** Names the owner goes by in notes ("Quinn"). */
|
|
24
|
+
ownerNames: string[];
|
|
25
|
+
/** The owner's past reviews, so a graduated rule acts. */
|
|
26
|
+
labels?: readonly DecisionLabel[];
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface PolicyOutcome {
|
|
30
|
+
/** Items to write: acted on as they were, or turned into suggestions. */
|
|
31
|
+
kept: Commitment[];
|
|
32
|
+
acted: number;
|
|
33
|
+
proposed: number;
|
|
34
|
+
skipped: Partial<Record<RuleId, number>>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const norm = (value: string | undefined) => String(value ?? '').trim().toLowerCase();
|
|
38
|
+
|
|
39
|
+
export function ownerRelationOf(item: Pick<Commitment, 'ownerName' | 'ownerSub' | 'ownerSubs'>, scope: EngineScope): OwnerRelation {
|
|
40
|
+
const subs = [...(item.ownerSubs ?? []), item.ownerSub ?? ''].filter(Boolean);
|
|
41
|
+
if (subs.includes(scope.ownerSub)) return 'self';
|
|
42
|
+
if (subs.length) return 'other';
|
|
43
|
+
const name = norm(item.ownerName);
|
|
44
|
+
if (!name) return 'none';
|
|
45
|
+
const parts = name.split(/[\s,]+/);
|
|
46
|
+
return scope.ownerNames.map(norm).filter(Boolean).some((alias) => name === alias || parts.includes(alias)) ? 'self' : 'other';
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* The names a person goes by, learned from their own items: an item linked to
|
|
51
|
+
* them (owner_sub) that also carries an owner name says "this name is them".
|
|
52
|
+
* Most used first; a name needs two linked items.
|
|
53
|
+
*/
|
|
54
|
+
export function ownerNamesFrom(items: Array<Pick<Commitment, 'ownerName' | 'ownerSub' | 'ownerSubs'>>, ownerSub: string): string[] {
|
|
55
|
+
const counts = new Map<string, number>();
|
|
56
|
+
for (const item of items) {
|
|
57
|
+
const subs = [...(item.ownerSubs ?? []), item.ownerSub ?? ''];
|
|
58
|
+
const name = String(item.ownerName ?? '').trim();
|
|
59
|
+
if (!name || name.includes(',') || !subs.includes(ownerSub)) continue;
|
|
60
|
+
counts.set(name, (counts.get(name) ?? 0) + 1);
|
|
61
|
+
}
|
|
62
|
+
// Two linked items at least: one mislinked item must not make someone else's to-dos act as the owner's.
|
|
63
|
+
return [...counts].filter(([, n]) => n >= 2).sort((a, b) => b[1] - a[1]).map(([name]) => name);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function applyPolicy(fresh: Commitment[], context: { scope: EngineScope; documents: SourceDocument[] }): PolicyOutcome {
|
|
67
|
+
const { scope } = context;
|
|
68
|
+
const byId = new Map(context.documents.map((doc) => [doc.id, doc]));
|
|
69
|
+
const out: PolicyOutcome = { kept: [], acted: 0, proposed: 0, skipped: {} };
|
|
70
|
+
|
|
71
|
+
for (const item of fresh) {
|
|
72
|
+
const mention = item.mentions[0];
|
|
73
|
+
const doc = mention ? byId.get(mention.documentId) : undefined;
|
|
74
|
+
const owner = ownerRelationOf(item, scope);
|
|
75
|
+
const decision = decide({
|
|
76
|
+
kind: 'item',
|
|
77
|
+
documentId: mention?.documentId ?? '',
|
|
78
|
+
documentOwnerSub: doc?.scope?.ownerSub ?? null,
|
|
79
|
+
documentSource: String(doc?.source ?? item.source ?? ''),
|
|
80
|
+
quote: mention?.quote ?? '',
|
|
81
|
+
// Extraction's own gates already ran: grounding in code, the verifier on model items.
|
|
82
|
+
extractor: mention?.extractor ?? 'model',
|
|
83
|
+
grounded: true,
|
|
84
|
+
verified: true,
|
|
85
|
+
owner,
|
|
86
|
+
subtype: item.subtype,
|
|
87
|
+
status: item.status,
|
|
88
|
+
// People besides the owner; an unknown count is a group, never a one-to-one.
|
|
89
|
+
participantCount: (() => {
|
|
90
|
+
const people = doc ? (doc.participants.length || doc.participantCount || 0) : 0;
|
|
91
|
+
return people > 0 ? people - 1 : 2;
|
|
92
|
+
})(),
|
|
93
|
+
match: null,
|
|
94
|
+
}, { ownerSub: scope.ownerSub }, scope.labels ?? []);
|
|
95
|
+
|
|
96
|
+
if (decision.mode === 'skip') {
|
|
97
|
+
out.skipped[decision.rule] = (out.skipped[decision.rule] ?? 0) + 1;
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
const kept: Commitment = { ...item, suggestion: suggestionOf(decision) };
|
|
101
|
+
if (owner === 'self' && !kept.ownerSub) kept.ownerSub = scope.ownerSub;
|
|
102
|
+
if (decision.mode === 'propose') {
|
|
103
|
+
kept.status = SUGGESTED_STATUS as Commitment['status'];
|
|
104
|
+
out.proposed += 1;
|
|
105
|
+
} else {
|
|
106
|
+
out.acted += 1;
|
|
107
|
+
}
|
|
108
|
+
out.kept.push(kept);
|
|
109
|
+
}
|
|
110
|
+
return out;
|
|
111
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE DECISION POLICY (bd startsim-vrmx5, Todo: ENG-151): evidence in, one
|
|
3
|
+
* decision out. Pure: no storage, no clock, no model. The same candidate and the
|
|
4
|
+
* same standings always give the same answer, so a dry run, a test and the
|
|
5
|
+
* scheduled pass cannot disagree.
|
|
6
|
+
*
|
|
7
|
+
* Order matters and is the policy itself: the hard refusals (another owner's
|
|
8
|
+
* source, Tandem's own output, an ungrounded or unverified statement) are checked
|
|
9
|
+
* before anything is matched, so no later rule can talk its way past them.
|
|
10
|
+
*/
|
|
11
|
+
import { standingOf } from './graduation';
|
|
12
|
+
import { RULES } from './rules';
|
|
13
|
+
import { isTandemAuthored } from './sources';
|
|
14
|
+
import type {
|
|
15
|
+
Candidate, DateCandidate, Decision, DecisionContext, DecisionLabel, ItemCandidate, ItemMatch,
|
|
16
|
+
RemoteCandidate, ResolutionCandidate, RuleId,
|
|
17
|
+
} from './types';
|
|
18
|
+
|
|
19
|
+
/** Subtypes that are, by definition, owed to the owner by somebody else. */
|
|
20
|
+
const WAITING_SUBTYPES = new Set(['need']);
|
|
21
|
+
|
|
22
|
+
export function decide(
|
|
23
|
+
candidate: Candidate,
|
|
24
|
+
context: DecisionContext,
|
|
25
|
+
labels: readonly DecisionLabel[] = [],
|
|
26
|
+
): Decision {
|
|
27
|
+
const fire = (rule: RuleId, targetId?: string, reason?: string): Decision => {
|
|
28
|
+
const spec = RULES[rule];
|
|
29
|
+
const standing = standingOf(rule, labels);
|
|
30
|
+
return {
|
|
31
|
+
verb: spec.verb,
|
|
32
|
+
mode: standing.mode,
|
|
33
|
+
rule,
|
|
34
|
+
confidence: standing.confidence,
|
|
35
|
+
reason: reason ?? spec.reason,
|
|
36
|
+
evidence: { documentId: candidate.documentId, quote: candidate.quote },
|
|
37
|
+
...(targetId ? { targetId } : {}),
|
|
38
|
+
reversible: spec.verb !== 'ignore',
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// 1. Never across owners. A source with no owner is not the pass owner's either.
|
|
43
|
+
if (!context.ownerSub || candidate.documentOwnerSub !== context.ownerSub) return fire('X-OWNER');
|
|
44
|
+
// 2. Never Tandem's own output.
|
|
45
|
+
if (isTandemAuthored(candidate.documentSource)) return fire('X-SELF');
|
|
46
|
+
|
|
47
|
+
switch (candidate.kind) {
|
|
48
|
+
case 'item': return decideItem(candidate, context, fire);
|
|
49
|
+
case 'resolution': return decideResolution(candidate, context, fire);
|
|
50
|
+
case 'date': return decideDate(candidate, fire);
|
|
51
|
+
case 'remote': return decideRemote(candidate, fire);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
type Fire = (rule: RuleId, targetId?: string, reason?: string) => Decision;
|
|
56
|
+
|
|
57
|
+
const sameOwner = (match: ItemMatch | null | undefined, context: DecisionContext) =>
|
|
58
|
+
Boolean(match && match.itemOwnerSub === context.ownerSub);
|
|
59
|
+
|
|
60
|
+
function decideItem(candidate: ItemCandidate, context: DecisionContext, fire: Fire): Decision {
|
|
61
|
+
if (!candidate.grounded) return fire('X-UNGROUNDED');
|
|
62
|
+
if (candidate.extractor === 'model' && !candidate.verified) return fire('X-UNVERIFIED');
|
|
63
|
+
|
|
64
|
+
// Someone else's commitment is the owner's business only when it is owed to
|
|
65
|
+
// them: a stated need, or a one-to-one where the other person is promising
|
|
66
|
+
// the owner. In a group meeting it is that person's to-do, not the owner's.
|
|
67
|
+
if (candidate.owner === 'other') {
|
|
68
|
+
const owedToOwner = WAITING_SUBTYPES.has(candidate.subtype) || candidate.status === 'blocked'
|
|
69
|
+
|| candidate.participantCount <= 1;
|
|
70
|
+
if (!owedToOwner) return fire('X-OTHERS');
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// A match onto someone else's item is not a match: it is a new item of the
|
|
74
|
+
// owner's own, or nothing (bd startsim-vrmx5; isolation audit, 2026-11-24).
|
|
75
|
+
const match = sameOwner(candidate.match, context) ? candidate.match! : null;
|
|
76
|
+
if (match?.strength === 'exact') return fire('L-EXACT', match.itemId);
|
|
77
|
+
if (match?.strength === 'anchored') return fire('L-NEAR', match.itemId);
|
|
78
|
+
if (match?.strength === 'unanchored') return fire('L-RELATED', match.itemId);
|
|
79
|
+
|
|
80
|
+
if (candidate.owner === 'other') return fire('C-WAITING');
|
|
81
|
+
if (candidate.owner === 'none') return fire('C-UNOWNED');
|
|
82
|
+
return fire(candidate.extractor === 'rules' ? 'C-VENDOR' : 'C-MODEL');
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function decideResolution(candidate: ResolutionCandidate, context: DecisionContext, fire: Fire): Decision {
|
|
86
|
+
const best = candidate.matches.find((match) => sameOwner(match, context));
|
|
87
|
+
if (!best) return fire('X-NO-MATCH');
|
|
88
|
+
if (candidate.humanEdited?.includes('status')) return fire('X-HUMAN', best.itemId);
|
|
89
|
+
const verb = candidate.outcome === 'dropped' ? 'dropped' : 'finished';
|
|
90
|
+
// More than one open item fits: still a suggestion, and it says so.
|
|
91
|
+
const ambiguous = candidate.matches.filter((match) => sameOwner(match, context)).length > 1;
|
|
92
|
+
return fire('U-RESOLVED', best.itemId,
|
|
93
|
+
`A later source says this is ${verb}${ambiguous ? '; more than one item could fit' : ''}.`);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function decideDate(candidate: DateCandidate, fire: Fire): Decision {
|
|
97
|
+
if (!candidate.itemId) return fire('X-NO-MATCH');
|
|
98
|
+
if (candidate.humanEdited?.includes('due_at') || candidate.humanEdited?.includes('dueAt')) {
|
|
99
|
+
return fire('X-HUMAN', candidate.itemId);
|
|
100
|
+
}
|
|
101
|
+
return fire('U-DATE', candidate.itemId);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function decideRemote(candidate: RemoteCandidate, fire: Fire): Decision {
|
|
105
|
+
return fire('U-REMOTE', candidate.itemId);
|
|
106
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EXTRACTION WITHOUT WRITING, for the engine's dry run (bd startsim-vrmx5).
|
|
3
|
+
*
|
|
4
|
+
* Runs the real extraction pipeline (rules pass, model, verifier, dedupe) over
|
|
5
|
+
* one owner's documents in a window, slice by slice, against an in-memory corpus
|
|
6
|
+
* whose save only records what WOULD have been written. Nothing reaches the
|
|
7
|
+
* tenant. The captured rows then go through the same `replayWindow` as stored
|
|
8
|
+
* items, so a fresh pass and a replay are judged by one policy.
|
|
9
|
+
*/
|
|
10
|
+
import { extractCommitments } from '../extract';
|
|
11
|
+
import { isTandemAuthored } from './sources';
|
|
12
|
+
import type { ExtractDeps } from '../extract';
|
|
13
|
+
import type { EngineScope } from './apply';
|
|
14
|
+
import type { Commitment, CorpusExtractorLlm, SourceDocument } from '../types';
|
|
15
|
+
|
|
16
|
+
export interface DryExtractInput {
|
|
17
|
+
ownerSub: string;
|
|
18
|
+
orgId: string;
|
|
19
|
+
/** Already narrowed to the window by the caller. */
|
|
20
|
+
documents: SourceDocument[];
|
|
21
|
+
/** The owner's current items, so dedupe sees what is already tracked. */
|
|
22
|
+
existing: Commitment[];
|
|
23
|
+
extractor: CorpusExtractorLlm;
|
|
24
|
+
documentsPerSlice?: number;
|
|
25
|
+
maxCharsPerRun?: number;
|
|
26
|
+
onSlice?: (done: number, total: number) => void;
|
|
27
|
+
/** Run the live decision policy too, exactly as the scheduled pass will. */
|
|
28
|
+
engine?: EngineScope;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface DryExtractResult {
|
|
32
|
+
/** Every row extraction would have written, latest version of each. */
|
|
33
|
+
rows: Commitment[];
|
|
34
|
+
documentsProcessed: number;
|
|
35
|
+
ungrounded: number;
|
|
36
|
+
unconfirmed: number;
|
|
37
|
+
modelFailures: number;
|
|
38
|
+
provider: string;
|
|
39
|
+
/** What the live policy did, summed over slices, when `engine` was given. */
|
|
40
|
+
policy?: { acted: number; proposed: number; skipped: Record<string, number> };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export async function dryExtract(input: DryExtractInput): Promise<DryExtractResult> {
|
|
44
|
+
const documents = input.documents.filter(
|
|
45
|
+
(doc) => doc.scope?.ownerSub === input.ownerSub && !isTandemAuthored(doc.source),
|
|
46
|
+
);
|
|
47
|
+
const store = new Map<string, Commitment>(input.existing.map((item) => [item.externalId, item]));
|
|
48
|
+
const written = new Map<string, Commitment>();
|
|
49
|
+
|
|
50
|
+
const corpus = {
|
|
51
|
+
async listDocuments(query: { page?: number; pageSize?: number } = {}) {
|
|
52
|
+
const size = query.pageSize ?? 200;
|
|
53
|
+
const start = ((query.page ?? 1) - 1) * size;
|
|
54
|
+
const results = documents.slice(start, start + size);
|
|
55
|
+
return { count: documents.length, next: start + size < documents.length ? 'more' : null, previous: null, results };
|
|
56
|
+
},
|
|
57
|
+
async listCommitments() {
|
|
58
|
+
const results = [...store.values()];
|
|
59
|
+
return { count: results.length, next: null, previous: null, results };
|
|
60
|
+
},
|
|
61
|
+
async saveCommitments(rows: Commitment[]) {
|
|
62
|
+
for (const row of rows) {
|
|
63
|
+
// Extracted rows belong to the owner whose source they came from.
|
|
64
|
+
const owned = { ...row, scope: { ...row.scope, orgId: input.orgId, ownerSub: input.ownerSub } };
|
|
65
|
+
store.set(row.externalId, owned);
|
|
66
|
+
written.set(row.externalId, owned);
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
} as unknown as ExtractDeps['corpus'];
|
|
70
|
+
|
|
71
|
+
const out: DryExtractResult = {
|
|
72
|
+
rows: [], documentsProcessed: 0, ungrounded: 0, unconfirmed: 0, modelFailures: 0, provider: '',
|
|
73
|
+
};
|
|
74
|
+
let offset: number | null = 0;
|
|
75
|
+
while (offset !== null) {
|
|
76
|
+
const result = await extractCommitments(
|
|
77
|
+
{ scope: { orgId: input.orgId }, offset, limit: input.documentsPerSlice ?? 2, ...(input.engine ? { engine: input.engine } : {}) },
|
|
78
|
+
{ corpus, extractor: input.extractor },
|
|
79
|
+
{ maxCharsPerRun: input.maxCharsPerRun ?? 6_000 },
|
|
80
|
+
);
|
|
81
|
+
out.documentsProcessed += result.documentsProcessed;
|
|
82
|
+
out.ungrounded += Number(result.ungrounded ?? 0);
|
|
83
|
+
out.unconfirmed += Number(result.unconfirmed ?? 0);
|
|
84
|
+
if (result.modelFailure) out.modelFailures += 1;
|
|
85
|
+
if (result.engine) {
|
|
86
|
+
const policy = out.policy ?? (out.policy = { acted: 0, proposed: 0, skipped: {} });
|
|
87
|
+
policy.acted += result.engine.acted;
|
|
88
|
+
policy.proposed += result.engine.proposed;
|
|
89
|
+
for (const [rule, n] of Object.entries(result.engine.skipped)) policy.skipped[rule] = (policy.skipped[rule] ?? 0) + Number(n ?? 0);
|
|
90
|
+
}
|
|
91
|
+
out.provider = `${result.provider?.provider ?? ''}/${result.provider?.model ?? ''}`;
|
|
92
|
+
input.onSlice?.(out.documentsProcessed, documents.length);
|
|
93
|
+
if (result.documentsProcessed === 0) break;
|
|
94
|
+
offset = result.nextOffset;
|
|
95
|
+
}
|
|
96
|
+
out.rows = [...written.values()];
|
|
97
|
+
return out;
|
|
98
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WHEN A RULE MAY ACT ON ITS OWN (bd startsim-vrmx5).
|
|
3
|
+
*
|
|
4
|
+
* A rule that starts as a suggestion graduates to acting once the owner's own
|
|
5
|
+
* reviews show it right at least GRADUATION_PRECISION of the time over at least
|
|
6
|
+
* GRADUATION_MIN_LABELS reviews. "Right" is accepted as offered; an edit or a
|
|
7
|
+
* reject counts against it. Labels written by automation never count: a sync
|
|
8
|
+
* job closing an item is not the owner agreeing with the engine.
|
|
9
|
+
*
|
|
10
|
+
* A graduated rule that later drops below the bar goes back to proposing. The
|
|
11
|
+
* bar is checked every pass, so the mode follows the evidence both ways.
|
|
12
|
+
*/
|
|
13
|
+
import { RULES, SAFE_RULES } from './rules';
|
|
14
|
+
import type { DecisionLabel, EngineMode, RuleId } from './types';
|
|
15
|
+
|
|
16
|
+
export const GRADUATION_PRECISION = 0.9;
|
|
17
|
+
export const GRADUATION_MIN_LABELS = 30;
|
|
18
|
+
|
|
19
|
+
export interface RuleStanding {
|
|
20
|
+
rule: RuleId;
|
|
21
|
+
reviewed: number;
|
|
22
|
+
accepted: number;
|
|
23
|
+
/** accepted / reviewed, or null before any human review. */
|
|
24
|
+
precision: number | null;
|
|
25
|
+
mode: EngineMode;
|
|
26
|
+
/** The confidence decisions under this rule carry: measured once enough labels exist, else the prior. */
|
|
27
|
+
confidence: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function standingOf(rule: RuleId, labels: readonly DecisionLabel[]): RuleStanding {
|
|
31
|
+
const mine = labels.filter((label) => label.rule === rule && label.actor === 'human');
|
|
32
|
+
const accepted = mine.filter((label) => label.outcome === 'accepted').length;
|
|
33
|
+
const precision = mine.length ? accepted / mine.length : null;
|
|
34
|
+
const spec = RULES[rule];
|
|
35
|
+
const enough = mine.length >= GRADUATION_MIN_LABELS;
|
|
36
|
+
let mode: EngineMode = spec.auto;
|
|
37
|
+
if (spec.auto !== 'skip' && !SAFE_RULES.has(rule)) {
|
|
38
|
+
mode = enough && precision !== null && precision >= GRADUATION_PRECISION ? 'act' : 'propose';
|
|
39
|
+
}
|
|
40
|
+
return {
|
|
41
|
+
rule, reviewed: mine.length, accepted, precision, mode,
|
|
42
|
+
confidence: enough && precision !== null ? precision : spec.prior,
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Standings for every rule, computed once per pass. */
|
|
47
|
+
export function standings(labels: readonly DecisionLabel[]): Map<RuleId, RuleStanding> {
|
|
48
|
+
return new Map((Object.keys(RULES) as RuleId[]).map((rule) => [rule, standingOf(rule, labels)]));
|
|
49
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { decide } from './decide';
|
|
2
|
+
export { dryExtract } from './dry-extract';
|
|
3
|
+
export type { DryExtractInput, DryExtractResult } from './dry-extract';
|
|
4
|
+
export { GRADUATION_MIN_LABELS, GRADUATION_PRECISION, standingOf, standings } from './graduation';
|
|
5
|
+
export type { RuleStanding } from './graduation';
|
|
6
|
+
export { formatReplay, replayWindow } from './replay';
|
|
7
|
+
export type { ReplayInput, ReplayReport, ReplayRow } from './replay';
|
|
8
|
+
export { RULES, SAFE_RULES } from './rules';
|
|
9
|
+
export type { RuleSpec } from './rules';
|
|
10
|
+
export { TANDEM_AUTHORED_SOURCES, isTandemAuthored } from './sources';
|
|
11
|
+
export type {
|
|
12
|
+
Candidate, DateCandidate, Decision, DecisionContext, DecisionLabel, EngineMode, EngineVerb,
|
|
13
|
+
ItemCandidate, ItemMatch, MatchStrength, OwnerRelation, RemoteCandidate, ResolutionCandidate, RuleId,
|
|
14
|
+
} from './types';
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE DRY RUN (bd startsim-vrmx5 slice 1): what the policy WOULD have done with
|
|
3
|
+
* what extraction already produced for one owner over a window, without writing.
|
|
4
|
+
*
|
|
5
|
+
* It replays stored evidence rather than calling a model: every extracted item's
|
|
6
|
+
* mentions, every resolution extraction applied, every "possibly done" still
|
|
7
|
+
* pending, and every document in the window, each turned into a candidate and
|
|
8
|
+
* run through `decide`. The report is counts per rule and ids only, never text,
|
|
9
|
+
* so it can be pasted into a bead or a message without carrying anyone's notes.
|
|
10
|
+
*
|
|
11
|
+
* WHAT A REPLAY CANNOT KNOW. Stored mentions already passed grounding and the
|
|
12
|
+
* verifier, so X-UNGROUNDED and X-UNVERIFIED never fire here; their counts come
|
|
13
|
+
* from a live pass. A later mention of an item is replayed as a merge onto that
|
|
14
|
+
* item: `exact` when its origin key matches the first mention's, `anchored`
|
|
15
|
+
* otherwise, because the wording that matched is not stored.
|
|
16
|
+
*/
|
|
17
|
+
import { identityOf, matchStrength } from '../commitments';
|
|
18
|
+
import { decide } from './decide';
|
|
19
|
+
import { isTandemAuthored } from './sources';
|
|
20
|
+
import type { Commitment, CommitmentMention, SourceDocument } from '../types';
|
|
21
|
+
import type {
|
|
22
|
+
Candidate, Decision, DecisionLabel, EngineMode, ItemMatch, OwnerRelation, RuleId,
|
|
23
|
+
} from './types';
|
|
24
|
+
|
|
25
|
+
export interface ReplayInput {
|
|
26
|
+
ownerSub: string;
|
|
27
|
+
/** Names the owner goes by in notes ("Quinn"), for items whose owner was never linked to a person. */
|
|
28
|
+
ownerNames: string[];
|
|
29
|
+
documents: SourceDocument[];
|
|
30
|
+
items: Commitment[];
|
|
31
|
+
/** Inclusive ISO lower bound on a document's `occurredAt`. */
|
|
32
|
+
since: string;
|
|
33
|
+
/** Inclusive ISO upper bound; omit for none. */
|
|
34
|
+
until?: string;
|
|
35
|
+
/** People on each document, when the caller read them from the raw row. */
|
|
36
|
+
participantCounts?: ReadonlyMap<string, number>;
|
|
37
|
+
labels?: readonly DecisionLabel[];
|
|
38
|
+
/**
|
|
39
|
+
* What a new item is matched against. Defaults to `items`. A fresh dry
|
|
40
|
+
* extraction passes the rows it would write as `items` and the owner's whole
|
|
41
|
+
* list here, so only the new evidence is judged but every item can match.
|
|
42
|
+
*/
|
|
43
|
+
pool?: Commitment[];
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export interface ReplayRow {
|
|
47
|
+
candidate: Candidate['kind'] | 'document';
|
|
48
|
+
/** Source key of the document the evidence came from. */
|
|
49
|
+
source: string;
|
|
50
|
+
/** The item the decision is about, or the document for document-level skips. */
|
|
51
|
+
id: string;
|
|
52
|
+
decision: Decision;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface ReplayReport {
|
|
56
|
+
ownerSub: string;
|
|
57
|
+
since: string;
|
|
58
|
+
documentsInWindow: number;
|
|
59
|
+
documentsRead: number;
|
|
60
|
+
/** Documents the owner owns that produced no candidate at all. */
|
|
61
|
+
documentsWithNothing: number;
|
|
62
|
+
/** Readable documents per source key. */
|
|
63
|
+
documentsBySource: Record<string, number>;
|
|
64
|
+
byRule: Array<{ rule: RuleId; mode: EngineMode; count: number; ids: string[] }>;
|
|
65
|
+
byMode: Record<EngineMode, number>;
|
|
66
|
+
/** Decisions per source key and rule: a meeting note and a dictated voice note are different evidence. */
|
|
67
|
+
bySource: Array<{ source: string; rule: RuleId; mode: EngineMode; count: number }>;
|
|
68
|
+
rows: ReplayRow[];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const norm = (value: string | undefined) => String(value ?? '').trim().toLowerCase();
|
|
72
|
+
|
|
73
|
+
function ownerRelation(item: Commitment, input: ReplayInput): OwnerRelation {
|
|
74
|
+
const subs = [...(item.ownerSubs ?? []), item.ownerSub ?? ''].filter(Boolean);
|
|
75
|
+
if (subs.includes(input.ownerSub)) return 'self';
|
|
76
|
+
if (subs.length) return 'other';
|
|
77
|
+
const name = norm(item.ownerName);
|
|
78
|
+
if (!name) return 'none';
|
|
79
|
+
const mine = input.ownerNames.map(norm).filter(Boolean);
|
|
80
|
+
return mine.some((alias) => name === alias || name.split(/[\s,]+/).includes(alias)) ? 'self' : 'other';
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** The best match among the owner's OTHER items that existed before this mention. */
|
|
84
|
+
function priorMatch(item: Commitment, at: string | null, pool: Commitment[]): ItemMatch | null {
|
|
85
|
+
const self = identityOf(item);
|
|
86
|
+
let best: ItemMatch | null = null;
|
|
87
|
+
const rank = { exact: 3, anchored: 2, unanchored: 1 } as const;
|
|
88
|
+
for (const other of pool) {
|
|
89
|
+
if (other.id === item.id) continue;
|
|
90
|
+
if (at && other.firstSeenAt && other.firstSeenAt > at) continue;
|
|
91
|
+
const strength = matchStrength(self, identityOf(other));
|
|
92
|
+
if (!strength) continue;
|
|
93
|
+
if (!best || rank[strength] > rank[best.strength]) {
|
|
94
|
+
best = { itemId: other.id, strength, itemOwnerSub: other.scope?.ownerSub ?? null };
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
return best;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export function replayWindow(input: ReplayInput): ReplayReport {
|
|
101
|
+
const context = { ownerSub: input.ownerSub };
|
|
102
|
+
const labels = input.labels ?? [];
|
|
103
|
+
const inWindow = input.documents.filter((doc) => !doc.occurredAt
|
|
104
|
+
|| (doc.occurredAt >= input.since && (!input.until || doc.occurredAt <= input.until)));
|
|
105
|
+
const byId = new Map(inWindow.map((doc) => [doc.id, doc]));
|
|
106
|
+
const owned = (input.pool ?? input.items).filter((item) => item.scope?.ownerSub === input.ownerSub);
|
|
107
|
+
const rows: ReplayRow[] = [];
|
|
108
|
+
const produced = new Set<string>();
|
|
109
|
+
|
|
110
|
+
const docOwner = (doc: SourceDocument) => doc.scope?.ownerSub ?? null;
|
|
111
|
+
const base = (doc: SourceDocument, quote: string) => ({
|
|
112
|
+
documentId: doc.id, documentOwnerSub: docOwner(doc), documentSource: String(doc.source), quote,
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
// Document-level refusals first: another owner's source, or Tandem's own output.
|
|
116
|
+
for (const doc of inWindow) {
|
|
117
|
+
if (docOwner(doc) !== input.ownerSub || isTandemAuthored(doc.source)) {
|
|
118
|
+
const decision = decide({
|
|
119
|
+
kind: 'item', ...base(doc, ''), extractor: 'rules', grounded: true, verified: true,
|
|
120
|
+
owner: 'none', subtype: 'action', status: 'open', participantCount: 0,
|
|
121
|
+
}, context, labels);
|
|
122
|
+
rows.push({ candidate: 'document', source: String(doc.source), id: doc.id, decision });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const readable = inWindow.filter((doc) => docOwner(doc) === input.ownerSub && !isTandemAuthored(doc.source));
|
|
126
|
+
|
|
127
|
+
for (const item of input.items) {
|
|
128
|
+
if (!item.extractorVersion) continue;
|
|
129
|
+
const mentions = [...item.mentions].sort((a, b) => String(a.occurredAt).localeCompare(String(b.occurredAt)));
|
|
130
|
+
mentions.forEach((mention: CommitmentMention, index) => {
|
|
131
|
+
const doc = byId.get(mention.documentId);
|
|
132
|
+
if (!doc || docOwner(doc) !== input.ownerSub || isTandemAuthored(doc.source)) return;
|
|
133
|
+
produced.add(doc.id);
|
|
134
|
+
const first = mentions[0];
|
|
135
|
+
const match: ItemMatch | null = index === 0
|
|
136
|
+
? priorMatch(item, mention.occurredAt, owned)
|
|
137
|
+
: { itemId: item.id, strength: mention.originKey === first.originKey ? 'exact' : 'anchored', itemOwnerSub: item.scope?.ownerSub ?? null };
|
|
138
|
+
const participants = input.participantCounts?.get(doc.id) ?? doc.participants.length;
|
|
139
|
+
const decision = decide({
|
|
140
|
+
kind: 'item', ...base(doc, mention.quote), extractor: mention.extractor, grounded: true, verified: true,
|
|
141
|
+
owner: ownerRelation(item, input), subtype: item.subtype, status: item.status,
|
|
142
|
+
// People besides the owner. An unknown count is treated as a group, never as a one-to-one.
|
|
143
|
+
participantCount: participants > 0 ? participants - 1 : 2,
|
|
144
|
+
match,
|
|
145
|
+
}, context, labels);
|
|
146
|
+
rows.push({ candidate: 'item', source: String(doc.source), id: item.id, decision });
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
// A resolution extraction applied, or one it left pending as "possibly done".
|
|
150
|
+
const resolvedBy = item.resolvedBy ? byId.get(item.resolvedBy) : undefined;
|
|
151
|
+
const pending = (item.possiblyDone ?? []).filter((claim) => claim.state === 'pending' && byId.has(claim.documentId));
|
|
152
|
+
const claims = [
|
|
153
|
+
...(resolvedBy ? [{ doc: resolvedBy, quote: item.statusReason ?? '', outcome: item.status === 'dropped' ? 'dropped' as const : 'done' as const }] : []),
|
|
154
|
+
...pending.map((claim) => ({ doc: byId.get(claim.documentId)!, quote: claim.quote, outcome: 'done' as const })),
|
|
155
|
+
];
|
|
156
|
+
for (const claim of claims) {
|
|
157
|
+
produced.add(claim.doc.id);
|
|
158
|
+
const decision = decide({
|
|
159
|
+
kind: 'resolution', ...base(claim.doc, claim.quote), outcome: claim.outcome,
|
|
160
|
+
matches: [{ itemId: item.id, strength: 'anchored', itemOwnerSub: item.scope?.ownerSub ?? null }],
|
|
161
|
+
}, context, labels);
|
|
162
|
+
rows.push({ candidate: 'resolution', source: String(claim.doc.source), id: item.id, decision });
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const groups = new Map<string, { rule: RuleId; mode: EngineMode; ids: Set<string>; count: number }>();
|
|
167
|
+
const byMode: Record<EngineMode, number> = { act: 0, propose: 0, skip: 0 };
|
|
168
|
+
for (const row of rows) {
|
|
169
|
+
const key = `${row.decision.rule}|${row.decision.mode}`;
|
|
170
|
+
const group = groups.get(key) ?? { rule: row.decision.rule, mode: row.decision.mode, ids: new Set<string>(), count: 0 };
|
|
171
|
+
group.count += 1;
|
|
172
|
+
group.ids.add(row.id);
|
|
173
|
+
groups.set(key, group);
|
|
174
|
+
byMode[row.decision.mode] += 1;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const sourceGroups = new Map<string, { source: string; rule: RuleId; mode: EngineMode; count: number }>();
|
|
178
|
+
for (const row of rows) {
|
|
179
|
+
const key = `${row.source}|${row.decision.rule}|${row.decision.mode}`;
|
|
180
|
+
const group = sourceGroups.get(key) ?? { source: row.source, rule: row.decision.rule, mode: row.decision.mode, count: 0 };
|
|
181
|
+
group.count += 1;
|
|
182
|
+
sourceGroups.set(key, group);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return {
|
|
186
|
+
ownerSub: input.ownerSub,
|
|
187
|
+
since: input.since,
|
|
188
|
+
documentsInWindow: inWindow.length,
|
|
189
|
+
documentsRead: readable.length,
|
|
190
|
+
documentsWithNothing: readable.filter((doc) => !produced.has(doc.id)).length,
|
|
191
|
+
documentsBySource: readable.reduce<Record<string, number>>((acc, doc) => {
|
|
192
|
+
acc[String(doc.source)] = (acc[String(doc.source)] ?? 0) + 1;
|
|
193
|
+
return acc;
|
|
194
|
+
}, {}),
|
|
195
|
+
byRule: [...groups.values()]
|
|
196
|
+
.sort((a, b) => b.count - a.count || a.rule.localeCompare(b.rule))
|
|
197
|
+
.map((group) => ({ rule: group.rule, mode: group.mode, count: group.count, ids: [...group.ids] })),
|
|
198
|
+
byMode,
|
|
199
|
+
bySource: [...sourceGroups.values()].sort((a, b) => a.source.localeCompare(b.source) || b.count - a.count),
|
|
200
|
+
rows,
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/** The report as plain lines: counts and ids, never text from a source. */
|
|
205
|
+
export function formatReplay(report: ReplayReport, idsPerRule = 5): string {
|
|
206
|
+
const lines = [
|
|
207
|
+
`owner ${report.ownerSub} since ${report.since}`,
|
|
208
|
+
`documents: ${report.documentsInWindow} in window, ${report.documentsRead} readable, ${report.documentsWithNothing} produced nothing`,
|
|
209
|
+
`readable by source: ${Object.entries(report.documentsBySource).map(([k, v]) => `${k} ${v}`).join(', ')}`,
|
|
210
|
+
`decisions: act ${report.byMode.act}, propose ${report.byMode.propose}, skip ${report.byMode.skip}`,
|
|
211
|
+
];
|
|
212
|
+
for (const group of report.byRule) {
|
|
213
|
+
const shown = group.ids.slice(0, idsPerRule).map((id) => id.replace(/^commit:/, '').slice(0, 8)).join(' ');
|
|
214
|
+
const more = group.ids.length > idsPerRule ? ` +${group.ids.length - idsPerRule}` : '';
|
|
215
|
+
lines.push(` ${group.rule.padEnd(13)} ${group.mode.padEnd(7)} ${String(group.count).padStart(4)} ${shown}${more}`);
|
|
216
|
+
}
|
|
217
|
+
lines.push('by source:');
|
|
218
|
+
for (const group of report.bySource) {
|
|
219
|
+
lines.push(` ${group.source.padEnd(13)} ${group.rule.padEnd(13)} ${group.mode.padEnd(7)} ${String(group.count).padStart(4)}`);
|
|
220
|
+
}
|
|
221
|
+
return lines.join('\n');
|
|
222
|
+
}
|