@commonlyai/cli 0.1.393 → 0.1.394
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 +1 -1
- package/src/commands/agent.js +2 -4
- package/src/lib/enforcement.js +44 -1
package/package.json
CHANGED
package/src/commands/agent.js
CHANGED
|
@@ -170,6 +170,7 @@ import {
|
|
|
170
170
|
import { missingHarnessHint, reportMissingHarness } from '../lib/missing-harness.js';
|
|
171
171
|
import {
|
|
172
172
|
ADDRESSED_EVENT_TYPES,
|
|
173
|
+
pickAdmissionEntry,
|
|
173
174
|
isPersonMention,
|
|
174
175
|
CASCADE_DEFAULTS,
|
|
175
176
|
CASCADE_ENV_VARS,
|
|
@@ -4346,10 +4347,7 @@ export const performRun = ({
|
|
|
4346
4347
|
}
|
|
4347
4348
|
return { entries };
|
|
4348
4349
|
}
|
|
4349
|
-
const admissionEvent = wakingEntries
|
|
4350
|
-
ADDRESSED_EVENT_TYPES.has(entry.event.type) || entry.event.payload?.addressed === true
|
|
4351
|
-
))
|
|
4352
|
-
|| wakingEntries[0];
|
|
4350
|
+
const admissionEvent = pickAdmissionEntry(wakingEntries);
|
|
4353
4351
|
if (admissionEvent) {
|
|
4354
4352
|
const admission = cascadeGovernor.admit(
|
|
4355
4353
|
eventPodId,
|
package/src/lib/enforcement.js
CHANGED
|
@@ -89,6 +89,49 @@ export const classifyTrigger = (event, recentMessages) => {
|
|
|
89
89
|
// race is a free stand-down.
|
|
90
90
|
export const ADDRESSED_EVENT_TYPES = new Set(['chat.mention', 'thread.mention', 'dm.message']);
|
|
91
91
|
|
|
92
|
+
// A board wake about a row this seat owns: it is the assignee or holds the
|
|
93
|
+
// claim, and someone else created or changed that row (F592). It rides
|
|
94
|
+
// message.posted, but it names this seat as surely as a mention does, so the
|
|
95
|
+
// cascade governor gives it the addressed grace. It still counts toward the
|
|
96
|
+
// streak, so two seats editing each other's rows stop at cap + grace per
|
|
97
|
+
// window. Wakes about a seat's previous or dependent rows stay broadcasts. A
|
|
98
|
+
// board wake whose reason the CLI can't classify (missing, or one the kernel
|
|
99
|
+
// adds later) fails toward delivery and takes the grace too.
|
|
100
|
+
const NOT_OWNED_WAKE_REASONS = new Set(['prevAssignee', 'prevClaimant', 'dependentAssignee', 'dependentClaimant']);
|
|
101
|
+
export const isOwnedWorkWake = (payload) => (
|
|
102
|
+
payload?.boardWake === true && !NOT_OWNED_WAKE_REASONS.has(payload?.wakeReason)
|
|
103
|
+
);
|
|
104
|
+
|
|
105
|
+
// The one grace rule: admit() gives the addressed grace to these, and the
|
|
106
|
+
// batch ranking reads the same predicate, so the page's pick never hides a
|
|
107
|
+
// grace an entry in it would have had alone.
|
|
108
|
+
export const takesAddressedGrace = (eventType, payload) => (
|
|
109
|
+
ADDRESSED_EVENT_TYPES.has(eventType) || isOwnedWorkWake(payload)
|
|
110
|
+
);
|
|
111
|
+
|
|
112
|
+
// The inbox batch prices one cascade admission for its whole page, on the
|
|
113
|
+
// entry ranked first here, earliest on a tie:
|
|
114
|
+
// 0. a mention with no dmKind: exempt from the cap (the kernel dampens it);
|
|
115
|
+
// 1. an entry that takes the addressed grace: a mention, a DM, or an
|
|
116
|
+
// owned-work board wake (F592): cap + grace;
|
|
117
|
+
// 2. a payload flagged addressed: no grace in admit(), but still ahead of a
|
|
118
|
+
// plain broadcast, as before;
|
|
119
|
+
// 3. otherwise the page's first entry.
|
|
120
|
+
// Without the owned-work case a broadcast sibling decided the page and refused
|
|
121
|
+
// the assignment with it; without rank 0 first, an owned wake past cap + grace
|
|
122
|
+
// refused an exempt mention; and with the flag ahead of rank 1, a flagged
|
|
123
|
+
// entry refused an owned wake at the plain cap.
|
|
124
|
+
const admissionRank = (event) => {
|
|
125
|
+
if (MENTION_EVENT_TYPES.has(event.type) && !event.payload?.dmKind) return 0;
|
|
126
|
+
if (takesAddressedGrace(event.type, event.payload)) return 1;
|
|
127
|
+
if (event.payload?.addressed === true) return 2;
|
|
128
|
+
return 3;
|
|
129
|
+
};
|
|
130
|
+
export const pickAdmissionEntry = (wakingEntries) => wakingEntries.reduce(
|
|
131
|
+
(best, entry) => (best === undefined || admissionRank(entry.event) < admissionRank(best.event) ? entry : best),
|
|
132
|
+
undefined,
|
|
133
|
+
);
|
|
134
|
+
|
|
92
135
|
/**
|
|
93
136
|
* A person @-mentioned this seat in a pod (ADR-018 D9.2): the one wake that
|
|
94
137
|
* carries unread message bodies. `trigger` is classifyTrigger's verdict, so an
|
|
@@ -270,7 +313,7 @@ export const createCascadeGovernor = ({
|
|
|
270
313
|
admit(podId, trigger, eventType, payload = {}) {
|
|
271
314
|
if (trigger !== 'agent') return { allowed: true, streak: 0, addressed: false };
|
|
272
315
|
const s = stateFor(podId);
|
|
273
|
-
const addressed =
|
|
316
|
+
const addressed = takesAddressedGrace(eventType, payload);
|
|
274
317
|
if (MENTION_EVENT_TYPES.has(eventType) && !payload?.dmKind) {
|
|
275
318
|
// Named mentions are bounded upstream by the kernel's shared
|
|
276
319
|
// bot-to-bot mention dampener. A DM emits chat.mention too, but its
|