You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit c75f94b
Browse filesBrowse the repository at this point in the historyBrowse files
fix(notify): bound the refused map like the sent map
A permanently refused idempotency key was remembered for the life of the
process: notify.js kept `sent` to 1 000 entries but never dropped a key
from `refused`, and connectors.js hands over a fresh randomUUID() per send,
so a deleted channel or a revoked bot added one entry per send.
`refused` now keeps REFUSED_KEPT (1 000) entries and drops the oldest
first, the same shape `sent` already had. A permanent failure is still a
failure and still never retried inside one send; only the memory is
bounded, and an evicted key may be tried again.
Fixes#2808
A channel that keeps refusing a send no longer costs memory for the life of the process: the notifier remembered every permanently refused idempotency key and never dropped one, while the sent keys beside it were capped at 1 000. The refused keys now keep the same bound and drop the oldest first, so a deleted channel or a revoked bot stays a remembered failure without the table growing with every send. See [#2808](https://github.com/ThinkFlowLab/FlyBot/issues/2808).
Copy file name to clipboardExpand all lines: docs/subsystems/core-host.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -47,7 +47,7 @@ The server side of the patched `ds-bot` core (`core/`): the part of [ds-bot-core
47
47
| `core/src/host/reach.js` | Per-Bot grants and the owner-policy `reach()` check that hooks.js runs outside the plugin chain (#90); `rt.setGrants`, `rt.hasGrant`, `rt.hasAnyGrant`. A local Bot refused toward a friend's Bot is told that it is not shared with that friend and where to share it (Sharing, #273). `rt.reach` also reads the room a send already belongs to when the caller names none (#948): `sharedRoom` applies only to the `roomOnly` identity — the Bot holds no grant at all and came into that **face-to-face** room by its number (`isCodeJoined`) — and looks for the one such room where the **exact** target is still seated; a Bot that holds a grant, or a room of this home, is judged as it always was and keeps asking for an explicit `roomId`, so a Bot that joined a room by number — a `roomOnly` identity with no person-grant — may line that seat, which is the same allowance `reach()` already applies to an explicit `roomId`; the room itself is named outbound by the transport, never assumed here. A `user-mention` with no named room is also judged under `mentionRoom` (#1126): one live local or inbound group where that Bot is a member and the exact target is still a remote seat, including a seat a group invite admitted (`admittedBy: 'ticket'`). A plain line, `message_bot`, a seat that has left, and a stranger outside every such room stay on the grant rule. Face-to-face stays on `sharedRoom`. Tests: `core/test/reach-policy.test.js`, `core/test/flybot.test.js`. |
48
48
| `core/src/host/schedules.js` | Scheduled tasks through DSH's schedule service: list, create, edit, copy, pause/resume, retry and delete for Settings → Scheduled tasks, each task's last run, and moving a Bot's tasks to its fresh part, which rewrites the stored row in place so the task keeps its id, its delivery history and the instant it was already due (#354, #473, #1245, #1287, see **Scheduled tasks: edit, pause, missed runs**, **Scheduled tasks: copy** and **Scheduled tasks: last run and Retry**). Also the `bot_schedules` tool: the Bot-wide list DSH's own `schedule_list` cannot give, group chats' own Sessions included (#628, see **Scheduled tasks: the Bot-wide list**). Tests: `core/test/schedules.test.js`. Tests for team quiet hours, its refusals and the settings write: `core/test/quiet-hours.test.js`; the rule itself is in `core/src/shared/quiet-hours.js` (#1166). The `every` selector takes `seconds` (60 to 604800) as well as the older `minutes` form, so a 90-second repeat survives an edit; a value below 60s or above 7 days is refused with the same sentence (#1651). A task name is at most 120 code points (#1895), so 120 emoji is a valid name and one more is refused. The list is a read of the caller's own rows: `schedulesView(actor)` reads each row's Session through the module's own `sourceOf(sessionId, actor)` (the rule #1321 uses for a copy's source and an edit's own Session), so another owner's task stays out and an actor-less call under scoping answers no rows, while an unenforced one-person install answers the whole host; the `schedule-*` writes keep their Session and target gates. A narrowed view also carries `someHidden: true` when a known row was dropped for the caller — the active and the paused loop set it alike — so an empty answer from a narrow caller is not read as a host with nothing scheduled; a row with no known owner hides nothing and sets no flag, and an unenforced install (no actor narrowing anything) never sets it either. |
49
49
|`core/src/host/automation-default.js`| Automation tasks on by default (#378): once per profile, `offerBundle` asks DSH's plugin manager to switch on `@deepseek-ai/dsh-experimental-schedule-bundle` and writes the offer to `dsh-defaults.json` next to the team. Tests: `core/test/automation-default.test.js`. |
50
-
|`core/src/host/notify.js`| Out-of-app delivery, first half (#355): a transport-agnostic adapter with Slack's `chat.postMessage` shape, one key per reminder so a retried send cannot duplicate, exponential backoff that honours `Retry-After`, three attempts at most, a structural failure not retried, and zero transport calls while the channel is off. Ships `fakeSlack` for tests; nothing calls it until the real Slack transport lands (see **Out-of-app delivery, first half**). Tests: `core/test/notify.test.js`. |
50
+
|`core/src/host/notify.js`| Out-of-app delivery, first half (#355): a transport-agnostic adapter with Slack's `chat.postMessage` shape, one key per reminder so a retried send cannot duplicate, exponential backoff that honours `Retry-After`, three attempts at most, a structural failure not retried, and zero transport calls while the channel is off. Ships `fakeSlack` for tests; nothing calls it until the real Slack transport lands (see **Out-of-app delivery, first half**). Sent and permanently refused keys are each capped at 1 000 process-local entries, oldest dropped first (#2808). Tests: `core/test/notify.test.js`, `core/test/notify-refused-bound.test.js`. |
51
51
|`core/src/host/harness.js`| Declarative harness (#874 Option B). Step 0 (#903): `default` names today's prompt / tools / model / step·retry / verifiers (`rt.harness`, `rt.resolveHarness`); behavior-neutral. Step 1: `lite` / `medium` / `heavy` load through the same resolver with distinct declared budgets; `rt.routeHarness` reads one triage label (`harness:lite`, `harness:medium`, `harness:heavy`). `applied` stays false, so the named modules are not rewritten. `harnessPro` checks a config offline against CI, `core/dev/eval`, and `rsi-baseline` and does not call a model. Step 2: `rt.harnessExperience` reads the experience library and does not attach it to a tier. Tree prompt exception: `@flybot/tree` keeps its marked prompt under `plugins/tree` (outside the three mirrors); listed on the harness, injection stays outside this file. Installed in `MODULES` right after `store`. Tests: `core/test/harness.test.js`, `core/test/experience.test.js`. |
52
52
|`core/src/host/experience.js`| Experience library read API (#874 Step 2). `lookupExperience({ repo, techStack, query, root })` reads `core/dev/experience/`. Data and `check.mjs` stay under `core/dev/` (see [ds-bot-core](ds-bot-core.md)). Since #1899 the 600-character bound on `trigger`, `wrong` and `right` counts code points through `codePoints` (`text.js`), so an emoji costs one character, not two, and an entry written before this change whose text is over 600 UTF-16 units but within 600 characters still loads through the read path. |
53
53
|`core/src/host/usage.js`| Usage ledger at `$DSH_HOME/bot/usage.sqlite` (`calls`). Ledger v3 (#903): every row carries `harness`, `issue_pr`, `tool_calls`, `wall_ms`, plus existing token columns (`withUsageFields` / `missingUsageFields`). Session turns are metered via `foldCalls` over turn events (`tool/call` count, wall time from attempt start, `issuePr` from turn text or `rt.noteUsageIssuePr(sessionId, ref)`), not from llm/stream alone. A triage tier is stamped with `rt.noteUsageHarness(sessionId, idOrLabels)` and lands on the row's `harness` field; the resume cursor (`marks.fold`) stays provider / model / retry. Sample row fixture: `core/test/fixtures/usage-sample.sqlite`. Tests: `core/test/usage-fields.test.js`, `core/test/usage.test.js`. |
@@ -460,9 +460,9 @@ has lines (#2790, `core/test/room-read-floor-clamp.test.js`).
460
460
- A reminder has to reach the owner with the desktop app closed, so its delivery cannot be a client toast. `src/host/notify.js` is the adapter that half needs, and nothing calls it yet: `schedules.js` wiring is the second half, once a real channel exists.
461
461
-`createNotifier({ transport, channel })` speaks Slack's `chat.postMessage` shape — `postMessage({ channel, text, blocks?, threadTs? })` → `{ ok: true, ts }`, or a typed `{ ok: false, error }` — with the transport injected. The production Slack transport waits for the owner's credential and is not in this repo; `fakeSlack(script)` is the stand-in the tests run on, recording every call and scripting each answer (a function or an `Error` too), and `rateLimited(ms)` / `channelNotFound()` / `networkFailure()` spell the three failures.
462
462
- Delivery policy: one key per reminder, so the same reminder handed to `send()` again after it went out answers `duplicate` with the first `ts` and never reaches the transport, and one handed over while it is in flight joins that attempt. A retry waits `min(base · 2^(n-1), max)` — 500 ms then 1 s by default — and `retryAfterMs` from a 429 is a floor, never a ceiling: waiting less only earns another 429. Three attempts at most; running out is not a verdict about the channel, so a later call may try again.
463
-
- A structural failure (`channel_not_found`, `not_in_channel`, anything untyped) is permanent: one call, `permanent: true`, and a second `send()` for that key is answered without another call. A thrown error and `network` are the same broken link: retryable.
463
+
- A structural failure (`channel_not_found`, `not_in_channel`, anything untyped) is permanent: one call, `permanent: true`, and a second `send()` for that key is answered without another call. A thrown error and `network` are the same broken link: retryable. Those refused keys are kept the way sent ones are (`REFUSED_KEPT`, 1 000 process-local entries): the newest key is still answered from memory, and once the table is full the oldest is dropped and tried again — the failure is unchanged (a permanent error is never retried inside one send), only the memory is bounded (#2808). The bound is needed because `connectors.js` hands over a fresh `randomUUID()` per send, so a channel that is gone would otherwise add one entry per attempt forever.
464
464
-`enabled` is checked before every attempt, not only at the start, so switching a channel off stops a reminder that is already waiting out a backoff, and a channel that is off makes zero transport calls. Sent keys are capped at 1 000 process-local entries; nothing is persisted, so a restart forgets them and at-least-once survives a crash.
465
-
-`core/test/notify.test.js` drives every retry with fake timers, needs no network and no key.
465
+
-`core/test/notify.test.js` drives every retry with fake timers, needs no network and no key; `core/test/notify-refused-bound.test.js` fills the refused table past its bound and checks the oldest key reaches the transport again.
0 commit comments