@telora/daemon 0.21.169 → 0.21.178
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/build-info.json +6 -3
- package/dist/completion/completion-decision.d.ts +16 -0
- package/dist/completion/completion-decision.d.ts.map +1 -1
- package/dist/completion/completion-decision.js +15 -0
- package/dist/completion/completion-decision.js.map +1 -1
- package/dist/completion/event-escalations.d.ts +26 -0
- package/dist/completion/event-escalations.d.ts.map +1 -1
- package/dist/completion/event-escalations.js +77 -19
- package/dist/completion/event-escalations.js.map +1 -1
- package/dist/completion/event-phases.d.ts +7 -0
- package/dist/completion/event-phases.d.ts.map +1 -1
- package/dist/completion/event-phases.js +19 -0
- package/dist/completion/event-phases.js.map +1 -1
- package/dist/completion/event.d.ts.map +1 -1
- package/dist/completion/event.js +1 -0
- package/dist/completion/event.js.map +1 -1
- package/dist/completion/human-only-act.d.ts +43 -0
- package/dist/completion/human-only-act.d.ts.map +1 -0
- package/dist/completion/human-only-act.js +75 -0
- package/dist/completion/human-only-act.js.map +1 -0
- package/dist/completion/machine-remediable-demotion.d.ts +14 -0
- package/dist/completion/machine-remediable-demotion.d.ts.map +1 -1
- package/dist/completion/machine-remediable-demotion.js +24 -1
- package/dist/completion/machine-remediable-demotion.js.map +1 -1
- package/dist/focus/focus-loop-registry.d.ts.map +1 -1
- package/dist/focus/focus-loop-registry.js +12 -0
- package/dist/focus/focus-loop-registry.js.map +1 -1
- package/dist/focus/listener-auto-advance.d.ts.map +1 -1
- package/dist/focus/listener-auto-advance.js +40 -25
- package/dist/focus/listener-auto-advance.js.map +1 -1
- package/dist/queries/agent-resolvable-aging.d.ts +88 -0
- package/dist/queries/agent-resolvable-aging.d.ts.map +1 -0
- package/dist/queries/agent-resolvable-aging.js +145 -0
- package/dist/queries/agent-resolvable-aging.js.map +1 -0
- package/dist/queries/agent-resolvable-promotion.d.ts +37 -8
- package/dist/queries/agent-resolvable-promotion.d.ts.map +1 -1
- package/dist/queries/agent-resolvable-promotion.js +77 -18
- package/dist/queries/agent-resolvable-promotion.js.map +1 -1
- package/dist/queries/escalation-consumption.d.ts +14 -0
- package/dist/queries/escalation-consumption.d.ts.map +1 -1
- package/dist/queries/escalation-consumption.js +15 -0
- package/dist/queries/escalation-consumption.js.map +1 -1
- package/dist/queries/focuses.d.ts +8 -0
- package/dist/queries/focuses.d.ts.map +1 -1
- package/dist/queries/focuses.js +19 -1
- package/dist/queries/focuses.js.map +1 -1
- package/dist/queries/routing-measurement.d.ts +65 -0
- package/dist/queries/routing-measurement.d.ts.map +1 -0
- package/dist/queries/routing-measurement.js +109 -0
- package/dist/queries/routing-measurement.js.map +1 -0
- package/dist/queries/routing-quality.d.ts +70 -0
- package/dist/queries/routing-quality.d.ts.map +1 -0
- package/dist/queries/routing-quality.js +66 -0
- package/dist/queries/routing-quality.js.map +1 -0
- package/dist/queries/schemas.d.ts +6 -0
- package/dist/queries/schemas.d.ts.map +1 -1
- package/dist/queries/schemas.js +6 -0
- package/dist/queries/schemas.js.map +1 -1
- package/dist/queries/sessions.d.ts +10 -0
- package/dist/queries/sessions.d.ts.map +1 -1
- package/dist/queries/sessions.js +14 -1
- package/dist/queries/sessions.js.map +1 -1
- package/dist/queries/source-reliability.d.ts +60 -0
- package/dist/queries/source-reliability.d.ts.map +1 -0
- package/dist/queries/source-reliability.js +70 -0
- package/dist/queries/source-reliability.js.map +1 -0
- package/dist/shell/control-state.d.ts +23 -7
- package/dist/shell/control-state.d.ts.map +1 -1
- package/dist/shell/control-state.js +41 -16
- package/dist/shell/control-state.js.map +1 -1
- package/dist/templates/claude-md.d.ts +1 -1
- package/dist/templates/claude-md.d.ts.map +1 -1
- package/dist/templates/claude-md.js +9 -0
- package/dist/templates/claude-md.js.map +1 -1
- package/package.json +3 -3
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Aging observer for the agent_resolvable (machine-owned) lane.
|
|
3
|
+
*
|
|
4
|
+
* agent_resolvable filings are deliberately HIDDEN from the operator inbox: they
|
|
5
|
+
* are machine-owned, ridden into a focus's coding spawns, and (only once the
|
|
6
|
+
* machine has demonstrably tried and failed) promoted to a human. Hiding the lane
|
|
7
|
+
* from people was the right call. Leaving it with NO observer was not: a filing
|
|
8
|
+
* nothing takes -- because its focus never spawns, or because the attempt gate
|
|
9
|
+
* correctly declines to promote it -- ages silently and indefinitely, invisible
|
|
10
|
+
* to everyone.
|
|
11
|
+
*
|
|
12
|
+
* This module separates those two: the lane stays hidden from humans, but its
|
|
13
|
+
* AGING is observable on its own terms. It emits a structured machine signal (a
|
|
14
|
+
* log line / returned summary) describing how the open machine-owned lane is
|
|
15
|
+
* aging -- oldest age, age buckets, the count past a staleness threshold, and the
|
|
16
|
+
* ANCHORLESS count (filings with no focus, hence no machine consumer at all). It
|
|
17
|
+
* is NOT a second human inbox: it files nothing, promotes nothing, and routes
|
|
18
|
+
* nothing to a person; it only makes the machine lane legible to the machine.
|
|
19
|
+
*
|
|
20
|
+
* The pure summary (summarizeAgentResolvableAging) is exercised from fixtures;
|
|
21
|
+
* the observer wraps it around the org-wide read and the daemon log.
|
|
22
|
+
*/
|
|
23
|
+
import { listOpenAgentResolvableForOrg as defaultListOpenAgentResolvableForOrg } from './escalation-consumption.js';
|
|
24
|
+
import { resolveAgentResolvablePromoteMs } from './agent-resolvable-promotion.js';
|
|
25
|
+
import { getFocusOrigins as defaultGetFocusOrigins } from './focuses.js';
|
|
26
|
+
import { isLowReliabilityOrigin } from './source-reliability.js';
|
|
27
|
+
import { createLogger } from '../shell/log.js';
|
|
28
|
+
const log = createLogger({ module: 'escalations' });
|
|
29
|
+
const HOUR_MS = 3_600_000;
|
|
30
|
+
const DAY_MS = 24 * HOUR_MS;
|
|
31
|
+
// Fixed ascending age bands. The final band (ltMs null) is open-ended.
|
|
32
|
+
const BUCKET_BOUNDS = [
|
|
33
|
+
{ label: '<1h', ltMs: HOUR_MS },
|
|
34
|
+
{ label: '1-6h', ltMs: 6 * HOUR_MS },
|
|
35
|
+
{ label: '6-24h', ltMs: DAY_MS },
|
|
36
|
+
{ label: '1-3d', ltMs: 3 * DAY_MS },
|
|
37
|
+
{ label: '3-7d', ltMs: 7 * DAY_MS },
|
|
38
|
+
{ label: '>7d', ltMs: null },
|
|
39
|
+
];
|
|
40
|
+
/**
|
|
41
|
+
* Pure: summarize how a set of open agent_resolvable filings is aging as of
|
|
42
|
+
* `nowMs`. A filing with an unparseable/absent createdAt is counted in `total`
|
|
43
|
+
* (and `anchorless` if it has no focus) but contributes no age -- it cannot be
|
|
44
|
+
* bucketed or judged stale on a bad timestamp, mirroring the promotion partition.
|
|
45
|
+
*/
|
|
46
|
+
export function summarizeAgentResolvableAging(items, nowMs, opts) {
|
|
47
|
+
const buckets = BUCKET_BOUNDS.map((b) => ({ label: b.label, ltMs: b.ltMs, count: 0 }));
|
|
48
|
+
const originByFocusId = opts.originByFocusId ?? new Map();
|
|
49
|
+
let oldestAgeMs = null;
|
|
50
|
+
let stalePastThreshold = 0;
|
|
51
|
+
let anchorless = 0;
|
|
52
|
+
let lowReliability = 0;
|
|
53
|
+
for (const item of items) {
|
|
54
|
+
if (!item.focusId)
|
|
55
|
+
anchorless += 1;
|
|
56
|
+
const origin = item.focusId ? (originByFocusId.get(item.focusId) ?? null) : null;
|
|
57
|
+
if (isLowReliabilityOrigin(origin))
|
|
58
|
+
lowReliability += 1;
|
|
59
|
+
const createdMs = Date.parse(item.createdAt);
|
|
60
|
+
if (Number.isNaN(createdMs))
|
|
61
|
+
continue; // no age signal on a bad timestamp
|
|
62
|
+
const ageMs = Math.max(0, nowMs - createdMs);
|
|
63
|
+
if (oldestAgeMs === null || ageMs > oldestAgeMs)
|
|
64
|
+
oldestAgeMs = ageMs;
|
|
65
|
+
if (ageMs > opts.staleThresholdMs)
|
|
66
|
+
stalePastThreshold += 1;
|
|
67
|
+
const bucket = buckets.find((b) => b.ltMs === null || ageMs < b.ltMs);
|
|
68
|
+
// The final band has ltMs null, so bucket is always defined.
|
|
69
|
+
if (bucket)
|
|
70
|
+
bucket.count += 1;
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
total: items.length,
|
|
74
|
+
oldestAgeMs,
|
|
75
|
+
stalePastThreshold,
|
|
76
|
+
staleThresholdMs: opts.staleThresholdMs,
|
|
77
|
+
anchorless,
|
|
78
|
+
lowReliability,
|
|
79
|
+
buckets,
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
function defaultAgingDeps() {
|
|
83
|
+
return {
|
|
84
|
+
listOpenForOrg: defaultListOpenAgentResolvableForOrg,
|
|
85
|
+
getFocusOrigins: defaultGetFocusOrigins,
|
|
86
|
+
now: () => Date.now(),
|
|
87
|
+
// A filing still in the machine lane past the promotion window is one the
|
|
88
|
+
// machine did not take -- the natural staleness mark for a "loss".
|
|
89
|
+
staleThresholdMs: resolveAgentResolvablePromoteMs(),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/** Render the summary as a single structured, machine-parseable log field string. */
|
|
93
|
+
export function formatAgingSummary(s) {
|
|
94
|
+
const oldestH = s.oldestAgeMs === null ? 'n/a' : (s.oldestAgeMs / HOUR_MS).toFixed(1);
|
|
95
|
+
const dist = s.buckets.map((b) => `${b.label}=${b.count}`).join(' ');
|
|
96
|
+
return (`total=${s.total} oldest_h=${oldestH} stale_past_${(s.staleThresholdMs / HOUR_MS).toFixed(0)}h=` +
|
|
97
|
+
`${s.stalePastThreshold} anchorless=${s.anchorless} low_reliability=${s.lowReliability} | ${dist}`);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Observe the org-wide open agent_resolvable lane and emit its aging as a
|
|
101
|
+
* machine signal. Returns the summary; logs it at info when the lane is
|
|
102
|
+
* non-empty (so a healthy empty lane stays quiet), and warns when there are
|
|
103
|
+
* stale or anchorless filings -- work that failed to get taken, which must
|
|
104
|
+
* register as a loss rather than vanish. Files/promotes/routes NOTHING.
|
|
105
|
+
*
|
|
106
|
+
* Best-effort: a read failure is logged and an empty summary returned, never
|
|
107
|
+
* thrown, so this never disturbs the tick it shares.
|
|
108
|
+
*/
|
|
109
|
+
export async function observeAgentResolvableAging(deps = {}) {
|
|
110
|
+
const d = { ...defaultAgingDeps(), ...deps };
|
|
111
|
+
let items = [];
|
|
112
|
+
try {
|
|
113
|
+
items = await d.listOpenForOrg();
|
|
114
|
+
}
|
|
115
|
+
catch (err) {
|
|
116
|
+
log.warn(`[agent-resolvable-aging] read failed: ${err.message}`);
|
|
117
|
+
return summarizeAgentResolvableAging([], (d.now ?? Date.now)(), { staleThresholdMs: d.staleThresholdMs });
|
|
118
|
+
}
|
|
119
|
+
// Resolve the producing source of each filing (its focus origin) so the
|
|
120
|
+
// summary can down-weight known-unreliable producers. Best-effort: if the
|
|
121
|
+
// origins read fails, fall back to treating every source as full weight rather
|
|
122
|
+
// than losing the whole aging signal.
|
|
123
|
+
let originByFocusId = new Map();
|
|
124
|
+
const focusIds = [...new Set(items.map((i) => i.focusId).filter((id) => !!id))];
|
|
125
|
+
if (focusIds.length > 0) {
|
|
126
|
+
try {
|
|
127
|
+
originByFocusId = await d.getFocusOrigins(focusIds);
|
|
128
|
+
}
|
|
129
|
+
catch (err) {
|
|
130
|
+
log.warn(`[agent-resolvable-aging] focus-origins read failed (full weight assumed): ${err.message}`);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
const summary = summarizeAgentResolvableAging(items, (d.now ?? Date.now)(), { staleThresholdMs: d.staleThresholdMs, originByFocusId });
|
|
134
|
+
if (summary.total > 0) {
|
|
135
|
+
const line = `[agent-resolvable-aging] ${formatAgingSummary(summary)}`;
|
|
136
|
+
if (summary.stalePastThreshold > 0 || summary.anchorless > 0) {
|
|
137
|
+
log.warn(line);
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
log.info(line);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
return summary;
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=agent-resolvable-aging.js.map
|
|
@@ -0,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EAAE,EAAE,gBAAgB,EAAE,CAAC,CAAC,gBAAgB,EAAE,eAAe,EAAE,CAAC,CAAC;IACvI,IAAI,OAAO,CAAC,KAAK,GAAG,CAAC,EAAE,CAAC;QACtB,MAAM,IAAI,GAAG,4BAA4B,kBAAkB,CAAC,OAAO,CAAC,EAAE,CAAC;QACvE,IAAI,OAAO,CAAC,kBAAkB,GAAG,CAAC,IAAI,OAAO,CAAC,UAAU,GAAG,CAAC,EAAE,CAAC;YAC7D,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjB,CAAC;aAAM,CAAC;YACN,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACjB,CAAC;IACH,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -11,12 +11,24 @@
|
|
|
11
11
|
* PROMOTED to a human by resolving the machine-routed row and refiling the same
|
|
12
12
|
* content as a needs_operator escalation, which the operator inbox DOES show.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
14
|
+
* Gate: RECORDED ATTEMPT EVIDENCE, not elapsed open-age. Open-age was the
|
|
15
|
+
* original proxy for "it survived N spawn cycles unresolved", but the proxy is
|
|
16
|
+
* inverted in practice: a filing anchored to an un-armed or wedged focus ages
|
|
17
|
+
* past the bound having had ZERO agent sessions, and promoting it hands a human a
|
|
18
|
+
* FIRST attempt dressed up as an exhausted machine. So promotion now gates on the
|
|
19
|
+
* actual count of agent sessions that ran on the filing's focus since it was
|
|
20
|
+
* created (countFocusSessionsSince): a filing with zero recorded attempts NEVER
|
|
21
|
+
* promotes, regardless of age. Open-age is retained only as a cheap CANDIDATE
|
|
22
|
+
* pre-filter (don't even count sessions for a fresh filing, which matters for the
|
|
23
|
+
* org-wide sweep's up-to-500-row scan); the promotion DECISION is the attempt
|
|
24
|
+
* count, and the count is carried into the promoted row's metadata so the human
|
|
25
|
+
* lane shows the evidence of the machine attempts that failed.
|
|
26
|
+
*
|
|
27
|
+
* A filing that cannot accrue attempts -- one with no focus anchor -- therefore
|
|
28
|
+
* does not promote either: it has no machine lane to be attempted in. New
|
|
29
|
+
* anchorless agent_resolvable filings are refused at the filing boundary, and
|
|
30
|
+
* un-taken machine-lane filings are made observable by the aging observer rather
|
|
31
|
+
* than dumped on a human.
|
|
20
32
|
*
|
|
21
33
|
* Promotion is idempotent: the needs_operator refile rides the shared cause-keyed
|
|
22
34
|
* gate keyed on the original escalation id, and the source row is resolved in the
|
|
@@ -24,8 +36,17 @@
|
|
|
24
36
|
*/
|
|
25
37
|
import { type AgentResolvableItem, type OrgAgentResolvableItem } from './escalation-consumption.js';
|
|
26
38
|
import { type FileEscalationIdempotentParams, type FileEscalationIdempotentResult } from './escalation-suppression.js';
|
|
27
|
-
/** Default hours an agent_resolvable filing may stay open before promotion. */
|
|
39
|
+
/** Default hours an agent_resolvable filing may stay open before it is a promotion CANDIDATE. */
|
|
28
40
|
export declare const DEFAULT_AGENT_RESOLVABLE_PROMOTE_HOURS = 24;
|
|
41
|
+
/**
|
|
42
|
+
* Minimum recorded agent sessions on a filing's focus (since it was created)
|
|
43
|
+
* before it may be promoted to a human. The decisive gate: at least this many
|
|
44
|
+
* spawns rode the filing in and none cleared it -- an exhausted machine, not a
|
|
45
|
+
* first attempt. A candidate below this floor is NOT promoted regardless of age.
|
|
46
|
+
*/
|
|
47
|
+
export declare const DEFAULT_AGENT_RESOLVABLE_PROMOTE_MIN_ATTEMPTS = 1;
|
|
48
|
+
/** Pure: whether a filing's recorded attempts meet the promotion floor. */
|
|
49
|
+
export declare function meetsAttemptFloor(attempts: number, minAttempts: number): boolean;
|
|
29
50
|
/**
|
|
30
51
|
* Resolve the promotion threshold (hours -> ms) from the typed, Zod-validated
|
|
31
52
|
* env-config -- the single declaration site for every operational knob
|
|
@@ -70,14 +91,18 @@ export declare function buildAgentResolvablePromotionParams(item: AgentResolvabl
|
|
|
70
91
|
organizationId: string;
|
|
71
92
|
focusId?: string;
|
|
72
93
|
productId?: string;
|
|
73
|
-
}, ageHours: number): FileEscalationIdempotentParams;
|
|
94
|
+
}, ageHours: number, attempts: number): FileEscalationIdempotentParams;
|
|
74
95
|
/** Injected IO for the promotion reconcile (real defaults; tests inject stubs). */
|
|
75
96
|
export interface AgentResolvablePromotionDeps {
|
|
76
97
|
listOpen: (focusId: string) => Promise<AgentResolvableItem[]>;
|
|
77
98
|
markResolved: (id: string, notes?: string) => Promise<void>;
|
|
78
99
|
file: (params: FileEscalationIdempotentParams) => Promise<FileEscalationIdempotentResult>;
|
|
100
|
+
/** Count agent sessions on a focus since an ISO timestamp (the attempt evidence). */
|
|
101
|
+
countSessionsSince: (focusId: string, since: string) => Promise<number>;
|
|
79
102
|
now?: () => number;
|
|
80
103
|
thresholdMs: number;
|
|
104
|
+
/** Minimum recorded attempts before a candidate may promote (see meetsAttemptFloor). */
|
|
105
|
+
minAttempts: number;
|
|
81
106
|
}
|
|
82
107
|
/**
|
|
83
108
|
* Reconcile a focus's open agent_resolvable filings and return the ones that
|
|
@@ -105,8 +130,12 @@ export interface AgentResolvableSweepDeps {
|
|
|
105
130
|
listOpenForOrg: () => Promise<OrgAgentResolvableItem[]>;
|
|
106
131
|
markResolved: (id: string, notes?: string) => Promise<void>;
|
|
107
132
|
file: (params: FileEscalationIdempotentParams) => Promise<FileEscalationIdempotentResult>;
|
|
133
|
+
/** Count agent sessions on a focus since an ISO timestamp (the attempt evidence). */
|
|
134
|
+
countSessionsSince: (focusId: string, since: string) => Promise<number>;
|
|
108
135
|
now?: () => number;
|
|
109
136
|
thresholdMs: number;
|
|
137
|
+
/** Minimum recorded attempts before a candidate may promote (see meetsAttemptFloor). */
|
|
138
|
+
minAttempts: number;
|
|
110
139
|
}
|
|
111
140
|
/**
|
|
112
141
|
* Sweep the org's OPEN agent_resolvable filings and promote every one that has
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-resolvable-promotion.d.ts","sourceRoot":"","sources":["../../src/queries/agent-resolvable-promotion.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"agent-resolvable-promotion.d.ts","sourceRoot":"","sources":["../../src/queries/agent-resolvable-promotion.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AASH,OAAO,EAAoJ,KAAK,mBAAmB,EAAE,KAAK,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACtP,OAAO,EAEL,KAAK,8BAA8B,EACnC,KAAK,8BAA8B,EACpC,MAAM,6BAA6B,CAAC;AAMrC,iGAAiG;AACjG,eAAO,MAAM,sCAAsC,KAAK,CAAC;AAEzD;;;;;GAKG;AACH,eAAO,MAAM,6CAA6C,IAAI,CAAC;AAE/D,2EAA2E;AAC3E,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,OAAO,CAEhF;AAED;;;;;;;;GAQG;AACH,wBAAgB,+BAA+B,CAAC,GAAG,GAAE,MAAM,CAAC,UAAwB,GAAG,MAAM,CAE5F;AAED;;;;;GAKG;AACH,wBAAgB,6BAA6B,CAAC,CAAC,SAAS;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,EAC3E,KAAK,EAAE,SAAS,CAAC,EAAE,EACnB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,MAAM,GAClB;IAAE,IAAI,EAAE,CAAC,EAAE,CAAC;IAAC,OAAO,EAAE,CAAC,EAAE,CAAA;CAAE,CAY7B;AAED,wFAAwF;AACxF,wBAAgB,gCAAgC,CAAC,oBAAoB,EAAE,MAAM,GAAG,MAAM,CAErF;AAED,yEAAyE;AACzE,eAAO,MAAM,8BAA8B,8BAA8B,CAAC;AAE1E;;;;;;;;;;;;;GAaG;AACH,wBAAgB,mCAAmC,CACjD,IAAI,EAAE,mBAAmB,EACzB,GAAG,EAAE;IAAE,cAAc,EAAE,MAAM,CAAC;IAAC,OA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AAC,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5D,IAAI,EAAE,CAAC,MAAM,EAAE,8BAA8B,KAAK,OAAO,CAAC,8BAA8B,CAAC,CAAC;IAC1F,qFAAqF;IACrF,kBAAkB,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;IACxE,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,wFAAwF;IACxF,WAAW,EAAE,MAAM,CAAC;CACrB;AAcD;;;;;;;;;;;;;GAaG;AACH,wBAAsB,8BAA8B,CAClD,IAAI,GAAE,OAAO,CAAC,wBAAwB,CAAM,GAC3C,OAAO,CAAC,0BAA0B,CAAC,CA+DrC"}
|
|
@@ -11,12 +11,24 @@
|
|
|
11
11
|
* PROMOTED to a human by resolving the machine-routed row and refiling the same
|
|
12
12
|
* content as a needs_operator escalation, which the operator inbox DOES show.
|
|
13
13
|
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
14
|
+
* Gate: RECORDED ATTEMPT EVIDENCE, not elapsed open-age. Open-age was the
|
|
15
|
+
* original proxy for "it survived N spawn cycles unresolved", but the proxy is
|
|
16
|
+
* inverted in practice: a filing anchored to an un-armed or wedged focus ages
|
|
17
|
+
* past the bound having had ZERO agent sessions, and promoting it hands a human a
|
|
18
|
+
* FIRST attempt dressed up as an exhausted machine. So promotion now gates on the
|
|
19
|
+
* actual count of agent sessions that ran on the filing's focus since it was
|
|
20
|
+
* created (countFocusSessionsSince): a filing with zero recorded attempts NEVER
|
|
21
|
+
* promotes, regardless of age. Open-age is retained only as a cheap CANDIDATE
|
|
22
|
+
* pre-filter (don't even count sessions for a fresh filing, which matters for the
|
|
23
|
+
* org-wide sweep's up-to-500-row scan); the promotion DECISION is the attempt
|
|
24
|
+
* count, and the count is carried into the promoted row's metadata so the human
|
|
25
|
+
* lane shows the evidence of the machine attempts that failed.
|
|
26
|
+
*
|
|
27
|
+
* A filing that cannot accrue attempts -- one with no focus anchor -- therefore
|
|
28
|
+
* does not promote either: it has no machine lane to be attempted in. New
|
|
29
|
+
* anchorless agent_resolvable filings are refused at the filing boundary, and
|
|
30
|
+
* un-taken machine-lane filings are made observable by the aging observer rather
|
|
31
|
+
* than dumped on a human.
|
|
20
32
|
*
|
|
21
33
|
* Promotion is idempotent: the needs_operator refile rides the shared cause-keyed
|
|
22
34
|
* gate keyed on the original escalation id, and the source row is resolved in the
|
|
@@ -24,13 +36,25 @@
|
|
|
24
36
|
*/
|
|
25
37
|
import { ESCALATION_REASONS, ESCALATION_DISPOSITIONS, loadEnvConfig, } from '@telora/daemon-core';
|
|
26
38
|
import { markEscalationResolved as defaultMarkEscalationResolved } from './escalations.js';
|
|
39
|
+
import { countFocusSessionsSince as defaultCountFocusSessionsSince } from './sessions.js';
|
|
27
40
|
import { listOpenAgentResolvableForFocus as defaultListOpenAgentResolvableForFocus, listOpenAgentResolvableForOrg as defaultListOpenAgentResolvableForOrg } from './escalation-consumption.js';
|
|
28
41
|
import { fileEscalationIdempotent as defaultFileEscalationIdempotent, } from './escalation-suppression.js';
|
|
29
42
|
import { computeCauseKey } from './cause-key.js';
|
|
30
43
|
import { createLogger } from '../shell/log.js';
|
|
31
44
|
const log = createLogger({ module: 'escalations' });
|
|
32
|
-
/** Default hours an agent_resolvable filing may stay open before promotion. */
|
|
45
|
+
/** Default hours an agent_resolvable filing may stay open before it is a promotion CANDIDATE. */
|
|
33
46
|
export const DEFAULT_AGENT_RESOLVABLE_PROMOTE_HOURS = 24;
|
|
47
|
+
/**
|
|
48
|
+
* Minimum recorded agent sessions on a filing's focus (since it was created)
|
|
49
|
+
* before it may be promoted to a human. The decisive gate: at least this many
|
|
50
|
+
* spawns rode the filing in and none cleared it -- an exhausted machine, not a
|
|
51
|
+
* first attempt. A candidate below this floor is NOT promoted regardless of age.
|
|
52
|
+
*/
|
|
53
|
+
export const DEFAULT_AGENT_RESOLVABLE_PROMOTE_MIN_ATTEMPTS = 1;
|
|
54
|
+
/** Pure: whether a filing's recorded attempts meet the promotion floor. */
|
|
55
|
+
export function meetsAttemptFloor(attempts, minAttempts) {
|
|
56
|
+
return attempts >= minAttempts;
|
|
57
|
+
}
|
|
34
58
|
/**
|
|
35
59
|
* Resolve the promotion threshold (hours -> ms) from the typed, Zod-validated
|
|
36
60
|
* env-config -- the single declaration site for every operational knob
|
|
@@ -83,29 +107,31 @@ export const AGENT_RESOLVABLE_PROMOTED_KIND = 'agent_resolvable_promoted';
|
|
|
83
107
|
* anchorless promotion simply files org-scoped with an empty anchor; a
|
|
84
108
|
* focus-anchored one still stamps the focus for provenance.
|
|
85
109
|
*/
|
|
86
|
-
export function buildAgentResolvablePromotionParams(item, ctx, ageHours) {
|
|
110
|
+
export function buildAgentResolvablePromotionParams(item, ctx, ageHours, attempts) {
|
|
87
111
|
const originalKind = item.escalationKind ?? 'agent_resolvable';
|
|
88
112
|
return {
|
|
89
113
|
causeKey: agentResolvablePromotionCauseKey(item.id),
|
|
90
114
|
organizationId: ctx.organizationId,
|
|
91
115
|
issueId: null,
|
|
92
116
|
reasonType: ESCALATION_REASONS.BLOCKED_BY_EXTERNAL,
|
|
93
|
-
// It was machine-routable, but
|
|
94
|
-
//
|
|
117
|
+
// It was machine-routable, but ${attempts} agent session(s) rode it in over
|
|
118
|
+
// ~${ageHours}h and none cleared it -- an exhausted machine, so a human takes it.
|
|
95
119
|
disposition: ESCALATION_DISPOSITIONS.NEEDS_OPERATOR,
|
|
96
120
|
// Anchor to the focus only when one exists; an anchorless filing files
|
|
97
121
|
// org-scoped (still visible in the operator inbox, keyed on disposition).
|
|
98
122
|
anchor: ctx.focusId ? { focusId: ctx.focusId } : {},
|
|
99
123
|
...(ctx.productId ? { productId: ctx.productId } : {}),
|
|
100
124
|
escalationKind: AGENT_RESOLVABLE_PROMOTED_KIND,
|
|
101
|
-
description: `A machine-routable (agent_resolvable) filing has
|
|
102
|
-
`
|
|
125
|
+
description: `A machine-routable (agent_resolvable) filing has had ${attempts} agent ` +
|
|
126
|
+
`session(s) on its focus (over ~${ageHours}h) without any of them clearing ` +
|
|
127
|
+
`it, so it is promoted to you.\n\n` +
|
|
103
128
|
`**Original kind:** ${originalKind}\n` +
|
|
104
|
-
`**Original filing:** ${item.id}\n
|
|
129
|
+
`**Original filing:** ${item.id}\n` +
|
|
130
|
+
`**Machine attempts that failed:** ${attempts}\n\n` +
|
|
105
131
|
`${item.description}`,
|
|
106
|
-
whatWasTried: `The filing rode into the focus's coding spawns
|
|
107
|
-
`(disposition agent_resolvable) but was
|
|
108
|
-
`exhausted its autonomous attempts.`,
|
|
132
|
+
whatWasTried: `The filing rode into the focus's coding spawns across ${attempts} recorded ` +
|
|
133
|
+
`agent session(s) over ~${ageHours}h (disposition agent_resolvable) but was ` +
|
|
134
|
+
`never resolved, so the machine has exhausted its autonomous attempts.`,
|
|
109
135
|
helpNeeded: `Resolve the underlying condition manually, or re-file with clearer intent if ` +
|
|
110
136
|
`the machine cannot act on it.`,
|
|
111
137
|
metadata: {
|
|
@@ -113,6 +139,10 @@ export function buildAgentResolvablePromotionParams(item, ctx, ageHours) {
|
|
|
113
139
|
originalEscalationId: item.id,
|
|
114
140
|
originalKind,
|
|
115
141
|
ageHours,
|
|
142
|
+
// Attempt evidence: the recorded agent sessions that failed to clear this
|
|
143
|
+
// filing. This is the proof the human lane carries that the machine was
|
|
144
|
+
// exhausted, not merely that time elapsed.
|
|
145
|
+
spawnsInWindow: attempts,
|
|
116
146
|
},
|
|
117
147
|
};
|
|
118
148
|
}
|
|
@@ -121,8 +151,10 @@ function defaultDeps() {
|
|
|
121
151
|
listOpen: defaultListOpenAgentResolvableForFocus,
|
|
122
152
|
markResolved: defaultMarkEscalationResolved,
|
|
123
153
|
file: defaultFileEscalationIdempotent,
|
|
154
|
+
countSessionsSince: defaultCountFocusSessionsSince,
|
|
124
155
|
now: () => Date.now(),
|
|
125
156
|
thresholdMs: resolveAgentResolvablePromoteMs(),
|
|
157
|
+
minAttempts: DEFAULT_AGENT_RESOLVABLE_PROMOTE_MIN_ATTEMPTS,
|
|
126
158
|
};
|
|
127
159
|
}
|
|
128
160
|
/**
|
|
@@ -142,8 +174,19 @@ export async function reconcileAgentResolvableForFocus(ctx, deps = {}) {
|
|
|
142
174
|
const { ride, promote } = partitionAgentResolvableByAge(open, (d.now ?? Date.now)(), d.thresholdMs);
|
|
143
175
|
for (const item of promote) {
|
|
144
176
|
const ageHours = Math.max(1, Math.floor(((d.now ?? Date.now)() - Date.parse(item.createdAt)) / 3_600_000));
|
|
177
|
+
// Attempt-evidence gate: only promote a candidate the machine actually TRIED
|
|
178
|
+
// and failed to clear. A candidate with zero agent sessions since it was
|
|
179
|
+
// filed is not exhausted -- it rides on (and the aging observer keeps it
|
|
180
|
+
// visible in the machine lane), never dumped on a human as a first attempt.
|
|
181
|
+
const attempts = await d.countSessionsSince(ctx.focusId, item.createdAt);
|
|
182
|
+
if (!meetsAttemptFloor(attempts, d.minAttempts)) {
|
|
183
|
+
log.info(`[escalations] Not promoting agent_resolvable ${item.id} (focus ${ctx.focusId}): ` +
|
|
184
|
+
`${attempts} recorded attempt(s) < floor ${d.minAttempts}; it rides on unattempted`);
|
|
185
|
+
ride.push(item);
|
|
186
|
+
continue;
|
|
187
|
+
}
|
|
145
188
|
try {
|
|
146
|
-
const result = await d.file(buildAgentResolvablePromotionParams(item, ctx, ageHours));
|
|
189
|
+
const result = await d.file(buildAgentResolvablePromotionParams(item, ctx, ageHours, attempts));
|
|
147
190
|
// Only retire the machine-routed row once the human-facing refile is in
|
|
148
191
|
// place (filed OR already suppressed by a prior promotion) -- never resolve
|
|
149
192
|
// the source without a landing spot, which would drop the signal entirely.
|
|
@@ -166,8 +209,10 @@ function defaultSweepDeps() {
|
|
|
166
209
|
listOpenForOrg: defaultListOpenAgentResolvableForOrg,
|
|
167
210
|
markResolved: defaultMarkEscalationResolved,
|
|
168
211
|
file: defaultFileEscalationIdempotent,
|
|
212
|
+
countSessionsSince: defaultCountFocusSessionsSince,
|
|
169
213
|
now: () => Date.now(),
|
|
170
214
|
thresholdMs: resolveAgentResolvablePromoteMs(),
|
|
215
|
+
minAttempts: DEFAULT_AGENT_RESOLVABLE_PROMOTE_MIN_ATTEMPTS,
|
|
171
216
|
};
|
|
172
217
|
}
|
|
173
218
|
/**
|
|
@@ -195,6 +240,20 @@ export async function sweepAgentResolvablePromotions(deps = {}) {
|
|
|
195
240
|
`cannot org-scope the refile (skipping)`);
|
|
196
241
|
continue;
|
|
197
242
|
}
|
|
243
|
+
// Attempt-evidence gate. A filing with no focus anchor cannot accrue agent
|
|
244
|
+
// sessions -- there is no machine lane to be attempted in -- so it has zero
|
|
245
|
+
// attempts and is NOT promoted (new anchorless filings are refused at the
|
|
246
|
+
// filing boundary; the aging observer keeps any residue visible). A
|
|
247
|
+
// focus-anchored candidate promotes only once the machine has actually tried
|
|
248
|
+
// and failed it minAttempts times.
|
|
249
|
+
const attempts = item.focusId
|
|
250
|
+
? await d.countSessionsSince(item.focusId, item.createdAt)
|
|
251
|
+
: 0;
|
|
252
|
+
if (!meetsAttemptFloor(attempts, d.minAttempts)) {
|
|
253
|
+
log.info(`[escalations] Org-wide sweep not promoting agent_resolvable ${item.id} ` +
|
|
254
|
+
`(focus ${item.focusId ?? '<none>'}): ${attempts} recorded attempt(s) < floor ${d.minAttempts}`);
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
198
257
|
const ageHours = Math.max(1, Math.floor(((d.now ?? Date.now)() - Date.parse(item.createdAt)) / 3_600_000));
|
|
199
258
|
const ctx = {
|
|
200
259
|
organizationId: item.organizationId,
|
|
@@ -202,7 +261,7 @@ export async function sweepAgentResolvablePromotions(deps = {}) {
|
|
|
202
261
|
...(item.productId ? { productId: item.productId } : {}),
|
|
203
262
|
};
|
|
204
263
|
try {
|
|
205
|
-
const result = await d.file(buildAgentResolvablePromotionParams(item, ctx, ageHours));
|
|
264
|
+
const result = await d.file(buildAgentResolvablePromotionParams(item, ctx, ageHours, attempts));
|
|
206
265
|
// Only retire the source once the human-facing refile is in place (filed OR
|
|
207
266
|
// already suppressed by a prior promotion) -- never resolve without a
|
|
208
267
|
// landing spot, which would drop the signal entirely.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agent-resolvable-promotion.js","sourceRoot":"","sources":["../../src/queries/agent-resolvable-promotion.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"agent-resolvable-promotion.js","sourceRoot":"","sources":["../../src/queries/agent-resolvable-promotion.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,aAAa,GACd,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,sBAAsB,IAAI,6BAA6B,EAAE,MAAM,kBAAkB,CAAC;AAC3F,OAAO,EAAE,uBAAuB,IAAI,8BAA8B,EAAE,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,+BAA+B,IAAI,sCAAsC,EAAE,6BAA6B,IAAI,oCAAoC,EAAyD,MAAM,6BAA6B,CAAC;AACtP,OAAO,EACL,wBAAwB,IAAI,+BAA+B,GAG5D,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,GAAG,GAAG,YAAY,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC;AAEpD,iGAAiG;AACjG,MAAM,CAAC,MAAM,sCAAsC,GAAG,EAAE,CAAC;AAEzD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,6CAA6C,GAAG,CAAC,CAAC;AAE/D,2EAA2E;AAC3E,MAAM,UAAU,iBAAiB,CAAC,QAAgB,E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CAAC"}
|
|
@@ -22,6 +22,7 @@ export interface AgentResolvableEscalationRow {
|
|
|
22
22
|
id: string;
|
|
23
23
|
status?: string | null;
|
|
24
24
|
disposition?: string | null;
|
|
25
|
+
resolutionClass?: string | null;
|
|
25
26
|
escalationKind?: string | null;
|
|
26
27
|
description?: string | null;
|
|
27
28
|
createdAt?: string | null;
|
|
@@ -29,6 +30,19 @@ export interface AgentResolvableEscalationRow {
|
|
|
29
30
|
focusId?: string | null;
|
|
30
31
|
productId?: string | null;
|
|
31
32
|
}
|
|
33
|
+
/** A resolved filing reduced to the two axes the routing-quality measure differences. */
|
|
34
|
+
export interface RoutingSampleRow {
|
|
35
|
+
disposition: string | null;
|
|
36
|
+
resolutionClass: string | null;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Sample the org's RESOLVED escalations, reduced to (disposition, resolution_class)
|
|
40
|
+
* -- the live population the routing-quality measure differences to compute the
|
|
41
|
+
* mis-route rate. Both axes ride in the summary base of transformEscalation, so
|
|
42
|
+
* detail:'summary' suffices. A bounded recent page (default 500) is enough for a
|
|
43
|
+
* rate; this is a measurement, not an exhaustive audit.
|
|
44
|
+
*/
|
|
45
|
+
export declare function listResolvedRoutingSample(deps?: CallApiDeps, limit?: number): Promise<RoutingSampleRow[]>;
|
|
32
46
|
/**
|
|
33
47
|
* An open agent_resolvable filing carrying its OWN anchor (org/focus/product).
|
|
34
48
|
* The focus-scoped read (listOpenAgentResolvableForFocus) already knows the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"escalation-consumption.d.ts","sourceRoot":"","sources":["../../src/queries/escalation-consumption.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAW,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAIxD,gFAAgF;AAChF,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,WAAW,EA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AAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,uEAAuE;IACvE,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC;AAED,UAAU,sBAAuB,SAAQ,4BAA4B;IACnE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CAC3C;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,SAAS,sBAAsB,EAAE,GACtC,wBAAwB,EAAE,CAqB5B;AAED;;;;;GAKG;AACH,wBAAsB,kCAAkC,CACtD,IAAI,GAAE,WAAgB,GACrB,OAAO,CAAC,wBAAwB,EAAE,CAAC,CAQrC"}
|
|
1
|
+
{"version":3,"file":"escalation-consumption.d.ts","sourceRoot":"","sources":["../../src/queries/escalation-consumption.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAW,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAIxD,gFAAgF;AAChF,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,sEAAsE;AACtE,MAAM,WAAW,4BAA4B;IAC3C,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,eAAe,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAChC,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,C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c,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,uEAAuE;IACvE,WAAW,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC;AAED,UAAU,sBAAuB,SAAQ,4BAA4B;IACnE,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAC;CAC3C;AAED;;;;;;GAMG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,EAAE,SAAS,sBAAsB,EAAE,GACtC,wBAAwB,EAAE,CAqB5B;AAED;;;;;GAKG;AACH,wBAAsB,kCAAkC,CACtD,IAAI,GAAE,WAAgB,GACrB,OAAO,CAAC,wBAAwB,EAAE,CAAC,CAQrC"}
|
|
@@ -12,6 +12,21 @@
|
|
|
12
12
|
import { callApi } from './shared.js';
|
|
13
13
|
import { OPEN_ESCALATION_STATUSES } from './holds.js';
|
|
14
14
|
import { DISPOSITION_AGENT_RESOLVABLE, DISPOSITION_NEEDS_INTENT } from './escalation-dispositions.js';
|
|
15
|
+
/**
|
|
16
|
+
* Sample the org's RESOLVED escalations, reduced to (disposition, resolution_class)
|
|
17
|
+
* -- the live population the routing-quality measure differences to compute the
|
|
18
|
+
* mis-route rate. Both axes ride in the summary base of transformEscalation, so
|
|
19
|
+
* detail:'summary' suffices. A bounded recent page (default 500) is enough for a
|
|
20
|
+
* rate; this is a measurement, not an exhaustive audit.
|
|
21
|
+
*/
|
|
22
|
+
export async function listResolvedRoutingSample(deps = {}, limit = 500) {
|
|
23
|
+
const call = deps.callApi ?? callApi;
|
|
24
|
+
const result = await call('escalation_list', { fields: { status: 'resolved' }, limit, detail: 'summary' });
|
|
25
|
+
return (result.escalations ?? []).map((e) => ({
|
|
26
|
+
disposition: e.disposition ?? null,
|
|
27
|
+
resolutionClass: e.resolutionClass ?? null,
|
|
28
|
+
}));
|
|
29
|
+
}
|
|
15
30
|
/**
|
|
16
31
|
* Pure: keep only the OPEN, agent_resolvable rows and shape them into
|
|
17
32
|
* AgentResolvableItems. The status re-check is defense-in-depth so a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"escalation-consumption.js","sourceRoot":"","sources":["../../src/queries/escalation-consumption.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,OAAO,EAAoB,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,4BAA4B,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"escalation-consumption.js","sourceRoot":"","sources":["../../src/queries/escalation-consumption.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,OAAO,EAAoB,MAAM,aAAa,CAAC;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,4BAA4B,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AA8BtG;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,OAAoB,EAAE,EACtB,KAAK,GAAG,GAAG;IAEX,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC;IACrC,MAAM,MAAM,GAAG,MAAM,IAAI,CACvB,iBAAiB,EACjB,EAAE,MAAM,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,CAC7D,CAAC;IACF,OAAO,CAAC,MAAM,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC5C,WAAW,EAAE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C,CAAC,EAAE,EAAE;QACT,MAAM,KAAK,GAAI,CAAC,CAAC,QAA2C,EAAE,WAAW,CAAC;QAC1E,OAAO;YACL,EAAE,EAAE,CAAC,CAAC,EAAE;YACR,cAAc,EAAE,CAAC,CAAC,cAAc,IAAI,IAAI;YACxC,WAAW,EAAE,CAAC,CAAC,WAAW,IAAI,EAAE;YAChC,SAAS,EAAE,CAAC,CAAC,SAAS,IAAI,EAAE;YAC5B,cAAc,EAAE,CAAC,CAAC,cAAc,IAAI,IAAI;YACxC,OAAO,EAAE,CAAC,CAAC,OAAO,IAAI,IAAI;YAC1B,SAAS,EAAE,CAAC,CAAC,SAAS,IAAI,IAAI;YAC9B,WAAW,EAAE,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,SAAS;SAC3D,CAAC;IACJ,CAAC,CAAC,CAAC;AACP,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,KAAK,UAAU,kCAAkC,CACtD,OAAoB,EAAE;IAEtB,MAAM,IAAI,GAAG,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC;IACrC,MAAM,MAAM,GAAG,MAAM,IAAI,CAA4C,iBAAiB,EAAE;QACtF,MAAM,EAAE,EAAE,QAAQ,EAAE,CAAC,SAAS,EAAE,WAAW,CAAC,EAAE;QAC9C,KAAK,EAAE,GAAG;QACV,MAAM,EAAE,MAAM;KACf,CAAC,CAAC;IACH,OAAO,2BAA2B,CAAC,MAAM,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC;AAC/D,CAAC"}
|
|
@@ -5,6 +5,14 @@
|
|
|
5
5
|
* can build a complete task DAG.
|
|
6
6
|
*/
|
|
7
7
|
import type { FocusDeliveryInfo, FocusIssueInfo, StageDirective, Workflow } from '../types/index.js';
|
|
8
|
+
/**
|
|
9
|
+
* Batch-read the provenance origin of a set of focuses, as a Map
|
|
10
|
+
* focusId -> origin|null. Feeds the machine-owned lane's source-reliability
|
|
11
|
+
* weighting: a filing's producing source is carried by its focus origin. A
|
|
12
|
+
* focusId not returned by the backend is absent from the map (the weighting
|
|
13
|
+
* treats a missing origin as a full-weight source). Empty input short-circuits.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getFocusOrigins(focusIds: readonly string[]): Promise<Map<string, string | null>>;
|
|
8
16
|
/** Result of a scan-all focus_list consumption. */
|
|
9
17
|
export interface ScanAllFocusesResult<F> {
|
|
10
18
|
/** Every focus accumulated across all pages. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"focuses.d.ts","sourceRoot":"","sources":["../../src/queries/focuses.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,cAAc,EAAE,QAAQ,EAAqC,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"focuses.d.ts","sourceRoot":"","sources":["../../src/queries/focuses.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,cAAc,EAAE,QAAQ,EAAqC,MAAM,mBAAmB,CAAC;AAWxI;;;;;;GAMG;AACH,wBAAsB,eAAe,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC,CAatG;AAkDD,mDAAmD;AACnD,MAAM,WAAW,oBAAoB,CAAC,CAAC;IACrC,gDAAgD;IAChD,OAAO,EAAE,CAAC,EAAE,CAAC;IACb,uEAAuE;IACvE,KAAK,EAAE,MAAM,CAAC;IACd;;;;OAIG;IACH,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,wEAAwE;IACxE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sFAAsF;IACtF,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,mDAAmD;IACnD,Q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GAAG,OAAO,CAAC,QAAQ,CAAC,CA8C1F"}
|
package/dist/queries/focuses.js
CHANGED
|
@@ -5,9 +5,27 @@
|
|
|
5
5
|
* can build a complete task DAG.
|
|
6
6
|
*/
|
|
7
7
|
import { callApi, callApiValidated } from './shared.js';
|
|
8
|
-
import { FocusDeliveriesResponseSchema, FocusIssuesResponseSchema, } from './schemas.js';
|
|
8
|
+
import { FocusDeliveriesResponseSchema, FocusIssuesResponseSchema, FocusOriginsResponseSchema, } from './schemas.js';
|
|
9
9
|
import { createLogger } from '../shell/log.js';
|
|
10
10
|
const log = createLogger({ module: 'scanAllFocuses' });
|
|
11
|
+
/**
|
|
12
|
+
* Batch-read the provenance origin of a set of focuses, as a Map
|
|
13
|
+
* focusId -> origin|null. Feeds the machine-owned lane's source-reliability
|
|
14
|
+
* weighting: a filing's producing source is carried by its focus origin. A
|
|
15
|
+
* focusId not returned by the backend is absent from the map (the weighting
|
|
16
|
+
* treats a missing origin as a full-weight source). Empty input short-circuits.
|
|
17
|
+
*/
|
|
18
|
+
export async function getFocusOrigins(focusIds) {
|
|
19
|
+
const map = new Map();
|
|
20
|
+
const ids = focusIds.filter((id) => typeof id === 'string' && id.length > 0);
|
|
21
|
+
if (ids.length === 0)
|
|
22
|
+
return map;
|
|
23
|
+
const result = await callApiValidated('daemon_get_focus_origins', FocusOriginsResponseSchema, { focusIds: ids });
|
|
24
|
+
for (const [focusId, origin] of Object.entries(result.origins)) {
|
|
25
|
+
map.set(focusId, origin);
|
|
26
|
+
}
|
|
27
|
+
return map;
|
|
28
|
+
}
|
|
11
29
|
// ---------------------------------------------------------------------------
|
|
12
30
|
// Paginated focus_list consumption
|
|
13
31
|
// ---------------------------------------------------------------------------
|