Commit Graph

1945 Commits

Author SHA1 Message Date
pick-cat e20a0039b3 fix(telegram): catch unhandled rejections in webhook and ingress worker shutdown (#100998)
* fix(telegram): isolate webhook/ingress-worker shutdown errors and guard all cleanup

- Wrap entire shutdown() body in outer try/catch so sync throws never
  produce unhandled rejections from fire-and-forget abort listeners.
- bot.stop() rejection is caught and logged; finally block ensures
  closeTransportOnce(), noteWebhookStop(), and stopDiagnosticHeartbeat()
  always execute regardless of bot.stop() outcome.
- closeTransportOnce() rejection is caught independently in the finally
  block so noteWebhookStop() and stopDiagnosticHeartbeat() are not skipped.
- Startup failure path: bot.stop() and closeTransportOnce() get
  .catch(() => undefined) so cleanup rejections never mask the original
  startup error.
- Both abort-listener call sites use consistent void shutdown() since
  the never-reject contract is now internal.
- Ingress worker stop() shares an in-flight stopPromise for idempotency;
  worker.terminate() rejections are observed via .catch(() => undefined).

Co-Authored-By: nebulacoder-v8.0 <noreply@zte.com.cn>

* fix(telegram): continue webhook cleanup after sync server.close throw

Extract independently guarded shutdown phases so a synchronous
server.close() failure still runs bot.stop, transport close, status,
and diagnostic heartbeat cleanup. Add sync-throw regression coverage
and a loopback real-behavior proof (negative/positive/valid).

* fix(telegram): clear webhook CI lint, knip, and test-types

Restore curly-safe drain timer clear, stop exporting the unused
shutdown phases interface, and narrow the transport close spy for
tsgo test types.

* chore(telegram): drop committed webhook shutdown proof script

* test(telegram): inline webhook shutdown proof cases without proof script

* fix(telegram): drop stale reply-fence import after main rebase

telegram-reply-fence.ts was deleted on main (f7786a16cf) during the
core drain refactor. The rebased webhook.ts no longer calls these
functions; remove the dangling import so the module resolves.

Co-Authored-By: nebulacoder-v8.0 <noreply@zte.com.cn>

* fix(telegram): continue webhook shutdown after phase failures

Keep each fallible Telegram-owned teardown phase independent so an early failure cannot skip transport, ingress, status, or diagnostic cleanup.

Co-authored-by: Pick-cat <huang.ting3@xydigit.com>

---------

Co-authored-by: nebulacoder-v8.0 <noreply@zte.com.cn>
Co-authored-by: Vincent Koc <vincentkoc@ieee.org>
2026-07-30 01:21:12 +08:00
Peter Steinberger 986e5d1758 refactor(channels): share ingress retention defaults (#115824) 2026-07-29 06:24:30 -04:00
Zakaria Rahali a9391d7312 fix(telegram): linkPreview:false is ignored on streamed replies (#114125)
* fix(telegram): linkPreview:false is ignored on streamed replies

Replies delivered through draft streaming still unfurled the first URL
even with channels.telegram.linkPreview: false. Non-streamed sends
already honored the flag.

createTelegramDraftStream never received linkPreview and never set
link_preview_options, on either its initial sendMessage or its
editMessageText calls. Finalization could not clean it up: it skips the
final edit when the streamed draft text already equals the final text,
which is the common case, so the draft message stays as-is with the
preview attached.

Passes linkPreview from telegramCfg into the draft stream and applies
link_preview_options: { is_disabled: true } on the send and on every
edit, since an edit that omits the field re-enables the preview
server-side. Rich messages keep expressing this as skip_entity_detection
at render time, which already worked.

Call arity is preserved when no preview options apply, so existing edit
assertions are unaffected.

Closes #111525

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>

* test(telegram): cover streamed reply option parity

Co-authored-by: Zakaria Rahali <zakariarahali288@gmail.com>

---------

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-07-29 06:18:35 -04:00
Peter Steinberger 382ea7b74e refactor: centralize channel streaming config hints (#115739)
* refactor: centralize channel streaming config hints

* fix: repair code mode static checks

* fix: restore QA evidence validator import
2026-07-29 04:42:23 -04:00
Peter Steinberger 104322c5cc fix(telegram): prevent false empty replies after message-tool delivery (#115588)
* fix(telegram): suppress message-tool-only reply fallbacks

Honor message-tool-only delivery when a non-silent Telegram reply is skipped in both ordinary group dispatch and native slash-command turns. Keep the existing visible fallback for genuinely empty native replies and cover both dispatch surfaces with regression tests.

Fixes #90091

* fix(telegram): preserve genuine delivery failure fallbacks

Suppress only non-silent skips owned by message-tool-only delivery. Preserve visible fallbacks when the same turn also encounters a real dispatch or final-delivery failure, with an explicit regression for the mixed failure path.

* fix(telegram): preserve native message-tool delivery errors

Track genuine native slash delivery failures so message-tool-only skip suppression never hides a failed response. Cover the exact mixed empty-skip and real-error path with a regression while preserving true-empty and intentionally cancelled fallbacks.

* test(telegram): preserve synchronous native delivery callbacks
2026-07-29 04:19:43 -04:00
Peter Steinberger 302f262e6b refactor: deduplicate extension normalization primitives (#115650)
* refactor(plugins): reuse SDK normalization primitives

* fix(ci): repair code-mode matrix checks

* fix(ci): satisfy code-mode matrix gates

* fix(ci): use matrix evidence export

* fix(ci): validate matrix evidence artifact
2026-07-29 04:10:06 -04:00
Peter Steinberger c650d2c8c9 fix(telegram): keep update retry checks read-only (#115613)
Use the non-mutating dedupe-cache contract when checking unaccepted Telegram updates. Preserve active handler and completed-update deduplication while allowing a real update to be accepted after repeated handler skip probes.

Fixes #105192
2026-07-29 04:02:55 -04:00
Peter Steinberger c29d889b9c fix: prevent sustained inbound messages from starving delivery (#115682)
Fixes #104106

Reported-by: @masatohoshino (#104106)
2026-07-29 03:44:35 -04:00
Peter Steinberger bf4122b0a7 fix(telegram): stop retrying blocked recipients (#115640)
Classify pinned Grammy blocked, kicked, and deactivated recipient 403 responses as permanently unreachable. Preserve retry behavior for recoverable permissions and flood control, inspect wrapped causes, and prove real SQLite ingress drain dead-lettering without duplicate dispatch.

Fixes #112893
2026-07-29 02:39:48 -04:00
Peter Steinberger a24c1ceb3a fix(channels): release inbound debounce at admission (#115603)
Track full dispatch completion separately for error handling and shutdown drain while allowing same-session follow-ups to steer active runs. Fixes #113180.

Co-authored-by: Taksh <takshkothari09@gmail.com>
2026-07-29 01:38:15 -04:00
Dallin Romney 96ea0fbf56 improve(qa): align Telegram coverage with startup behavior (#113527)
* test(telegram): align coverage with startup behavior

* fix(qa): register Slack MPIM coverage
2026-07-29 12:59:42 +08:00
黄云龙 5dbe0fa7e3 fix(telegram): break long HTML chunks on word boundaries, not mid-word (#104473)
* fix(telegram): break long HTML chunks on word boundaries

* test(telegram): cover word-safe HTML chunk boundaries
2026-07-29 00:38:36 -04:00
Peter Steinberger 4e651a43f4 fix(compaction): apply host transcript byte guard to codex sessions (#115192) (#115514)
Co-authored-by: pcpilot-dev <pcpilot-dev@users.noreply.github.com>
2026-07-29 00:23:44 -04:00
Peter Steinberger 430c293ee0 refactor: remove duplicate provider and runtime code (#115529)
* refactor: remove duplicated runtime and provider code

* refactor: exclude unrelated browser test cleanup

* refactor: preserve canonical subagent cleanup ordering
2026-07-29 00:04:52 -04:00
Arseniy Palagin ede8fe33df fix(telegram): surface draft stream delivery failures at warn level (#111065)
* fix(telegram): surface draft stream delivery failures at warn level

createTelegramDraftController wired the draft stream's warn callback to
logVerbose, so preview send/edit/cleanup failures ("telegram stream
preview failed: ...", "telegram stream preview cleanup failed: ...")
were only emitted when verbose logging was enabled. In the default
configuration a dying preview/draft stream left no operator-visible
trace: the bot just went quiet, especially in progress stream mode
where the activity window is the only delivery surface.

Route the warn callback through the telegram subsystem logger
(telegram/draft-stream) at warn level with lane, chatId, and threadId
context so draft delivery failures show up in default logs. The
verbose log callback is unchanged.

Co-authored-by: Claude <noreply@anthropic.com>

* test(telegram): simplify draft warning logger proof

Co-authored-by: Arseniy Palagin <valeradzigurda3@gmail.com>

* fix(telegram): emit draft terminal delivery diagnostics

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: d1bd0f71-7638-463a-958d-d5b3e2da1047

* fix(telegram): keep draft visibility change scoped

Remove the diagnostic expansion so this contributor PR remains focused on its original warn-level logging repair.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: d1bd0f71-7638-463a-958d-d5b3e2da1047

---------

Co-authored-by: Arseniy Palagin <valeradzigurda3@gmail.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: Peter Steinberger <steipete@gmail.com>
Co-authored-by: Gio Della-Libera <giodl73@gmail.com>
Copilot-Session: d1bd0f71-7638-463a-958d-d5b3e2da1047
2026-07-28 23:36:19 -04:00
Ayaan Zaidi b00a1aaeae test(telegram): give the media harness a bot identity instead of per-context ids
The previous commit patched me.id into 13 contexts in one suite. That treated the
symptom: the harness itself never passes botInfo, so resolveBotUserId has no
fallback when a test ctx carries only a username.

Fix the harness instead. Production always builds the bot from getMe(), so
botInfo is present in every real path; supplying telegramBotInfoForTest matches
that and drops the per-context ids.

Also revives bot.media.stickers-and-fragments.e2e.test.ts, which shares the
harness and failed 3/6 for the same reason and was not covered before.

The other ~84 bare me literals across 8 Telegram suites are fine: those tests
supply botInfo through their own harnesses. Verified, 371 pass, so no sweep.
2026-07-29 09:55:41 +09:00
Ayaan Zaidi cc434dd5fe test(telegram): cover forward-burst debounce coalescing through durable ingress
PR #115401 fixed the album split by separating durable claim lifetime from lane
occupancy (deferredLaneOccupancy="release"), and stated the same change repairs
the text/forwarded-message debounce, which defers its spooled participant the
same way. The album path got a durable-drain regression test; the debounce path
did not, because the suite that would cover it fails 10/10 on main.

Restore that suite: its harness supplies me.username without me.id, which
resolveBotUserId has required since #114532. Production grammY populates ctx.me
from getMe(), so this is harness drift, not a runtime gap.

Then extend the durable-ingress regression file to both buffers and rename it
off media-group. Two new tests admit a forwarded burst through the spool and
core drain, live and from a restart backlog, asserting one turn carrying both
notes plus independent tombstones.

Both fail with deferredLaneOccupancy reverted to "hold" (second note lands in a
separate turn), so they pin the lane contract rather than restate it.
2026-07-29 09:55:41 +09:00
Peter Steinberger ee3d084048 fix(telegram): coalesce durable album ingress into one turn (#115401)
* fix(telegram): coalesce durable album ingress

Split durable claim lifetime from lane occupancy so Telegram can admit later album members while every deferred claim remains heartbeated, recoverable, and independently settled.

With deferredLaneOccupancy=release, an unrelated later same-lane Telegram message can reach reply admission before an album that is still inside its 500 ms flush window. That restores the pre-f7786a16 contract, not a new defect; grammY sequentialize still preserves handler-entry order and the reply lane serializes once a turn is admitted.

* fix(telegram): preserve deferred abort semantics

Release deferred claims when their owner aborts before settlement, while preserving adoption when settlement won the race. Supersede every accepted pre-adoption state on released lanes without admitting past a surviving lane owner.

* fix(telegram): separate participant rejection from settlement failure

The detached deferred continuation chained its rejection handler with .catch
after .then, so it observed not only a participant.task rejection but also any
error thrown by onFailed()/onAdopted() and re-drove that infrastructure error
through onFailed().

That applied the wrong disposition when the claim was still pre-adoption, and
silently discarded the error once it was not: onAdopted() sets phase to adopted
before its tombstone write, so a wedged write reached a re-entrant onFailed()
that returned early on the phase guard and never reached the logging handler.

Use the two-argument then form so task rejection and lifecycle settlement
failure stay on separate paths.

* fix(channels): satisfy ingress CI guards
2026-07-28 17:50:20 -04:00
Peter Steinberger 9692e62119 test: align release validation fixtures (#115146)
* test: forward-port release validation fixtures

* test(telegram): isolate native command test dependencies

* test(telegram): await async file logs
2026-07-28 07:08:08 -04:00
Peter Steinberger 4273ca9dbd refactor(sessions): remove file-era transcript runtime (#113233)
* refactor(sessions): keep helper transcripts in memory

* refactor(sessions): remove file-era transcript storage

* test(sessions): use SQLite identity in attempt persistence

* test(codex): isolate legacy transcript fixtures

* fix(sessions): preserve SQLite transcript identity

* fix(sessions): harden transcript lifecycle invariants

* fix(sessions): validate transcript identities

* fix(sessions): close identity compatibility gaps

* fix(sessions): preserve leaf and plugin identities

* fix(sessions): retain dispatch transcript targets

* fix(sessions): preserve active transcript context

* fix(sessions): isolate artifact accounting

* fix(sessions): bound SQLite usage accounting

* fix(sessions): retain bounded latest usage

* fix(sessions): align rebased transcript targets

* test(sessions): align accessor scope fixture

* fix(telegram): derive SQLite transcript identity

* refactor(sessions): remove file-era compaction residue

* chore(sessions): lower max-lines baseline

* fix(sessions): preserve structured transcript identity

* test(sessions): align doctor identity assertions

* fix(sessions): isolate default SDK database

* refactor(sessions): remove dead file-era exports

* fix(sessions): reconcile SQLite transcript identity

* fix(sessions): pass checkpoint identity explicitly

* test(sessions): make entry field probe explicit

* test(sessions): satisfy transcript cleanup lint

* test(sessions): align diagnostics identity proof

* fix(sessions): finish transcript runtime teardown

* fix(sessions): preserve transcript identity invariants

* fix(sessions): harden transcript compatibility edges

* fix(sessions): preserve checkpoint transcript anchors

* fix(sessions): preserve SQLite lifecycle invariants

* fix(sessions): retarget compaction successors

* test(sessions): preserve transcript fixture semantics

* feat(plugin-sdk): add command transcript targets

* fix(sessions): serialize transcript rewrites

* fix(sessions): validate legacy successor identity

* fix(sessions): normalize compaction ownership

* fix(sessions): validate successor identity before adoption

* fix(sessions): preserve plugin transcript ownership

* fix(sessions): carry transcript identity through commands

* fix(sessions): import legacy checkpoint artifacts into SQLite

* fix(sessions): preserve successor transcript ownership

* fix(sessions): align transcript consumers with target identity

* fix(sessions): scope transcript token estimates

* fix(sessions): retain agent identity across lifecycle hooks

* fix(sessions): resolve scoped SQLite targets

* fix(sessions): isolate lifecycle transcript targets

* fix(sessions): validate compaction agent ownership

* fix(sessions): preserve reset and cleanup lifecycle

* fix(sessions): serialize prompt cleanup lifecycle

* fix(sessions): remove stale lock import

* fix(sessions): preserve reset target context

* fix(sessions): fence prompt reload takeover

* fix(sessions): unblock abort and default lifecycle reads

* fix(sessions): validate legacy successor scope

* fix(sessions): reject metadata-only runtime rows

* fix(sessions): propagate custom transcript stores

* fix(sessions): preserve adopted retry targets

* fix(sessions): allow unkeyed usage reads

* fix(sessions): harden runtime target boundaries

* fix(sessions): serialize retry transcript writes

* fix(sessions): bound prompt reload disposal

* fix(sessions): complete retry marker identity

* fix(sessions): keep legacy marker identity minimal

* test(sessions): tighten teardown fixture types

* fix(sessions): preserve compatibility target identity

* test(sessions): persist post-checkpoint boundary turn

* test(sessions): align runtime store mock contracts

* style(sessions): simplify persisted identity guard

* fix(sessions): prefer complete typed targets

* fix(sessions): recover legacy marker targets

* test(sessions): align marker lookup fixture scope

* fix(sessions): validate partial transcript targets

* fix(sessions): reconcile partial transcript identities

* fix(sessions): canonicalize compatibility identities

* test(sessions): cover compatibility aliases

* fix(sessions): adopt legacy successor identity

* fix(sessions): preserve usage read identity

* fix(sessions): preserve partial marker compatibility

* fix(sessions): validate legacy successor mappings

* fix(sessions): reconcile marker store mappings

* fix(sessions): preserve legacy fallback identity

* fix(sessions): harden marker alias resolution

* fix(sessions): prefer verified successor aliases

* fix(sessions): resolve preferred marker aliases

* fix(sessions): serialize cleanup admission

* fix(sessions): align marker lookup scopes

* fix(codex): type marker alias summaries

* style(sessions): satisfy changed lint

* test(sessions): align structured target assertions

* fix(sessions): reconcile latest identity contracts

* fix(sessions): validate transcript identity boundaries

* docs(sessions): explain stable registry keys

* fix(sessions): harden compatibility target round trips

* fix(sessions): port usage identity to split modules

* test(sessions): align subagent transcript identity

* fix(sessions): finish transcript identity migration

* fix(agents): route subagent completion capture through transcript targets

* fix(agents): settle SQLite prompt handoff during cleanup

* chore: shrink max-lines baseline after teardown

* fix(sessions): port teardown across split runtime owners

* fix(sessions): carry transcript targets through split owners

* test(agents): use SQLite compaction target in abort coverage

* chore: retain unrelated max-lines suppressions

* chore: shrink max-lines baseline after main splits

* style(agents): const compaction checkpoint locals

* fix(sessions): harden SQLite teardown boundaries

* test(sessions): use typed metadata in predicate isolation fixture

* test(agents): cover malformed settlement rejections lint-safely

* fix(sessions): close remaining SQLite identity races

* fix(agents): fail closed on incomplete successor targets

* fix(sessions): preserve transcript identity fallbacks

* fix(agents): preserve session-key abort admission

* fix(trajectory): validate incomplete export targets

* test(sessions): drop retired pricing cache imports

* fix(sessions): validate partial transcript identities

* fix(sessions): close transcript identity edge cases

* fix(plugins): reserve retired transcript locator slot

* fix(sessions): scope transcript locks by target

* style(sessions): simplify SDK initialization error

* fix(sessions): preserve initialized transcript state

* fix(codex): verify mirrored history session keys

* fix(sessions): reject stale transcript ownership

* fix(sessions): anchor asynchronous transcript ownership

* fix(sessions): measure active transcript state

* fix(sessions): preserve scoped transcript compaction

* fix(sessions): harden transcript identity and lifecycle

* fix(sessions): resolve scoped command transcript stores

* fix(sessions): make transcript appends failure-atomic

* fix(sessions): enforce scoped transcript ownership

* fix(sessions): reject cross-owner transcript handoffs

* fix(sessions): fence cleanup transcript ownership

* fix(sessions): retire stale write ownership contexts

* fix(sessions): preserve pending session migration state

* fix(sessions): validate migrated transcript ownership

* fix(sessions): validate usage transcript targets

* fix(sessions): clear predecessor transcript metadata

* fix(sessions): align durable session event targets

* fix(sessions): fence late prompt handoffs

* fix(sessions): fence lifecycle transcript fallbacks

* fix(sessions): bound zero-length memory capture

* fix(sessions): preserve transcript teardown ownership

* fix(sessions): reject duplicate cleanup ownership

* fix(sessions): serialize runtime writes with sqlite leases

* fix(sessions): close sqlite teardown concurrency gaps

* fix(sessions): preserve nested lifecycle failures

* fix(sessions): canonicalize sqlite transcript ownership

* fix(sessions): settle disposed prompt handoffs

* fix(sessions): resolve canonical attempt lock targets

* test(sessions): align canonical target fixtures

* test(sessions): retire redundant jsonl parser coverage

* refactor(sessions): split active transcript cursors

* test(memory): retire legacy marker fixture

* fix(sessions): preserve canonical transcript access after rebase

* fix(sessions): fence prompt lease and return transcript targets

* fix(sessions): colocate transcript leases with target store

* fix(sessions): canonicalize transcript lease and worker targets

* fix(sessions): preserve plugin and fork identity markers

* fix(sessions): complete sqlite transcript target migration

* fix(sessions): integrate canonical followup identity

* fix(sessions): preserve bounded transcript topology

* fix(sessions): validate transcript identity boundaries

* fix(context): separate caller and successor targets

* test(sessions): split persistence compatibility coverage

* test(sessions): preserve fixture topology efficiently

* chore(sdk): refresh plugin api baseline

* test(agents): align compaction lock target mocks

* test(sessions): seed malformed transcript fixtures directly

* fix(agents): canonicalize transcript compatibility inputs

* fix(agents): type optional tool result ids

* test(ci): stabilize loaded process timing

* test(tui): wait for collect queue admission
2026-07-27 22:33:24 -04:00
joshavant d0669429d8 fix(telegram): suppress unsafe reply previews 2026-07-27 20:31:51 -05:00
Peter Steinberger a1e0c9ea09 refactor(packages): DM-policy contract suite, dead routes, package folds (#114776)
* test(channels): share DM policy contract suite

* refactor(memory): remove dead host CLI routes

* refactor(acp): use canonical normalization helpers

* refactor(web): fold provider runtime into core

* refactor(packages): remove dead runtime exports

* chore(knip): drop retired ACP entry roots
2026-07-27 20:20:13 -04:00
Ayaan Zaidi b37e819d74 fix(telegram): show progress for queued replies (#114590)
* fix(telegram): preserve queued followup progress
* fix(auto-reply): restore queued progress lifecycle

---------

Co-authored-by: Ayaan Zaidi <hi@obviy.us>
2026-07-28 08:12:17 +09:00
Ayaan Zaidi 5e8555a7c9 fix(telegram): keep media-less unmentioned group messages on the canonical mention gate 2026-07-28 06:57:02 +09:00
Peter Steinberger 17e42229d2 feat: teach models to use collapsible details where supported (#114706)
* feat: teach models to use collapsible details where supported

* fix: accept nullable accountId in telegram rich-messages helper

* docs: regenerate docs map for collapsible details heading

* fix(ci): remove duplicate Codex prewarm test route
2026-07-27 16:06:33 -04:00
Peter Steinberger 9e5849a0e8 feat: render model-authored collapsible details (#114556)
* feat: render model-authored collapsible details in web UI and flatten for plain channels

* fix: guard markdown-it line-index access in details block rule

* fix: satisfy no-new-array lint in disclosure scanners

* fix: unexport internal disclosure scanner types

* fix: respect markdown code boundaries in details scanners

* fix: preserve escaped disclosure tags
2026-07-27 09:05:14 -04:00
Harjoth Khara 9e9536e0e0 fix(telegram): correct invalid 401 recovery guidance (#112492)
Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-07-27 08:20:32 -04:00
Peter Steinberger 187b604e50 fix(telegram): release validation stalls in isolated test runs (#114532)
* fix(telegram): isolate extension tests from shared state

* test(telegram): extract isolated bot fixtures

* test(telegram): restore harness dependency type
2026-07-27 07:45:02 -04:00
carlosjarenom c93652cbe4 fix(telegram): persist update offset only after durable spool write in isolated polling (#113368)
* fix(telegram): persist update offset only after durable spool write in isolated polling

Closes #113315

In isolated polling ingress, the parent session now persists the Telegram
update offset only after the update has been durably written to the spool.
This prevents an update from being acknowledged (via the offset) before it
has been safely enqueued, which could lead to permanent data loss if the
process crashes between offset persistence and spool write.

Changes:
- Call persistUpdateId(updateId) after writeTelegramSpooledUpdate succeeds.
- Add structured logs for poll-start, update receipt, spool success/failure,
  and offset persistence success/failure.
- In isolated mode, stop passing onUpdateId to the bot so the offset is only
  persisted once, after the spool write.
- Add regression tests verifying spool-before-offset ordering and the
  failure path when spooling fails.

* fix(telegram): persist isolated polling offset only across contiguous spooled updates

Closes #113315

- Track successfully spooled update ids and advance the persisted offset only
  through a contiguous boundary. This prevents a later update_id from being
  persisted before an earlier one has finished spooling, which would make the
  earlier update unrecoverable after a restart.
- Serialize spooling while no durable offset floor exists, so the first
  successful spool becomes the persisted floor.
- Coalesce duplicate worker deliveries for the same update_id and ack both
  success and failure paths.
- Fix TypeScript cast errors in polling-session.test.ts.

* fix(telegram): serialize durable polling offsets (#113368)

---------

Co-authored-by: Carlos <carlos@example.com>
Co-authored-by: Ayaan Zaidi <hi@obviy.us>
2026-07-27 17:21:03 +09:00
Peter Steinberger 08b1ff73e2 refactor(channels): fix account resolution and setup isolation (#114395)
* refactor(channels): fix account resolution and setup isolation

* fix(channels): keep account resolvers safely destructurable
2026-07-27 03:49:37 -04:00
dandriscoll 71eb9a3ec9 fix: Telegram forum topics answered twice (duplicate conversation per topic) (#113063)
* fix: Telegram forum topics answered twice (duplicate conversation per topic)

* fix(telegram): repair General topic conversation identity

Co-authored-by: Dan Driscoll <thedandriscoll.org@gmail.com>

* fix: keep doctor repair detail internal

---------

Co-authored-by: Dan Driscoll <thedandriscoll.org@gmail.com>
Co-authored-by: Peter Steinberger <steipete@gmail.com>
2026-07-27 00:42:00 -04:00
joshavant 44378dd24a fix(channels): harden record session override 2026-07-26 23:15:06 -05:00
joshavant d8de71258a refactor(channels): route bundled command replies 2026-07-26 23:15:06 -05:00
JesusSerrano-Seimako 0ac926b8fb fix(telegram): scope dispatch dedupe by bot identity (#113667)
* fix(telegram): scope dispatch dedupe by bot identity

* refactor(telegram): require bot identity for dispatch dedupe

* docs(telegram): explain dedupe key cutover

---------

Co-authored-by: JesusSerrano-Seimako <269908146+JesusSerrano-Seimako@users.noreply.github.com>
Co-authored-by: Ayaan Zaidi <hi@obviy.us>
2026-07-27 07:04:48 +05:30
Jesse Merhi d7627d6f4c refactor(prompt): use plain inbound context labels and drop system-tag sanitizer (#112000)
* refactor(prompt): plain inbound context labels with a provenance marker

Replaces trust-worded inbound context labels ("(untrusted metadata)",
"(untrusted, for context)") with plain labels plus a fixed provenance
marker suffix appended to every OpenClaw-injected context header.

Detection keys on the marker, not label text, so strippers stay correct
across UI, TUI, replay, /trace segmentation, memory recall, and the Swift
chat preprocessor. Drops sanitizeInboundSystemTags in favor of the marker
boundary plus trusted system-prompt narration.

Renames the untrusted-named plugin SDK context identifiers to
channel-provenance names, keeping deprecated aliases registered for
removal after 2026-09-08.

Adds `openclaw doctor --fix` migrations that rewrite legacy inbound
labels in stored SQLite transcripts and purge legacy envelope-
contaminated LanceDB recall rows.

* fix(ci): resolve gate failures for plain inbound context labels

- doctor sqlite readers: open read-only connections via openNodeSqliteDatabase
  so the Kysely connection-boundary guardrail holds; unexport the now-internal
  transcript snapshot type (Knip unused-export gate).
- compat registry: split the record table into registry-records.ts and
  plugin-sdk-subpath-records.ts. The new compat record pushed registry.ts past
  the 700-line oxlint cap; suppressions are disallowed, so follow the existing
  sibling record-module pattern. Public exports and PluginCompatCode literals
  unchanged.
- acp-runtime test: assert current finalization behavior (newline normalization
  only). The bracket de-fang and System: rewrite it expected were removed with
  sanitizeInboundSystemTags; forged system lines are neutralized at the
  system-event queue, the single chokepoint feeding the System:-per-line render.
- regenerate docs_map and the plugin SDK API baseline manifest.

* fix(prompt): harden inbound context label migration and drop in-band sanitizer

Review follow-ups on the plain-label + provenance-marker change:

- Remove src/security/system-tags.ts. Rewriting inbound text to neutralize
  look-alike `System:`/`[System]` markers corrupted legitimate user text and is
  not a real injection boundary; role separation plus external-content wrapping
  is. Explicit product decision, recorded at the system-event queue.
- Narrow the LanceDB legacy-row purge so it cannot delete benign memories. It
  now requires a complete known legacy sentinel line, a legacy label followed by
  a fenced JSON body, or the complete legacy external-content header. The prior
  predicates matched ordinary prose such as `Notes (untrusted metadata):`, and
  deletion is irreversible.
- Make explicit-empty canonical ChannelStructuredContext win over the deprecated
  alias via a present/absent result instead of collapsing `[]` to undefined.
- Keep `\r?` in the active-memory doctor rule. It is the only rule spanning the
  header's line break, migrated assistant rows skip newline normalization, and
  without it the marked-header replace wins and the body strips to empty. Added
  a CRLF regression test.
- Fix stale comments that described removed behavior, and cover the Swift
  prose-block strip path.

Claude-Session: https://claude.ai/code/session_01WNzsPddQmxy9Y7jKD4wAxH
2026-07-27 11:27:53 +10:00
Peter Steinberger 93a0fdb9b8 fix(release): align extension validation contracts (#113919) 2026-07-25 17:07:51 -07:00
Peter Steinberger 332006bc1f test: consolidate OpenClaw test state fixtures (#113576)
* test: consolidate OpenClaw test state fixtures

* test(plugin-sdk): expose isolated test state

Promote the isolated OpenClaw test-state lifecycle through a narrow published Plugin SDK subpath so extension tests no longer import private core helpers. This intentional SDK surface addition is maintainer-approved.

* test: use SDK test-state seam in extensions

Route bundled extension suites through the focused repo-local Plugin SDK test-state entrypoint and remove the Codex projector harness exports made stale by fixture consolidation. Keep the seam out of production builds and published package artifacts while auditing its real consumers in the full-tree deadcode scan.

* test(plugins): map test-state in package boundaries
2026-07-25 05:30:52 -07:00
Peter Steinberger 3d1369ff4f test(telegram): consolidate bot test harness (#113571)
* test(telegram): consolidate bot test harness

* test(plugin-sdk): expose isolated test state

Promote the isolated OpenClaw test-state lifecycle through a narrow published Plugin SDK subpath so extension tests no longer import private core helpers. This intentional SDK surface addition is maintainer-approved.

* test(telegram): use public test-state seam

* test(plugin-sdk): keep test state local-only

Match the existing channel test-helper boundary: bundled extension tests can import the focused SDK source entrypoint, while ordinary builds and the published npm package exclude it. The earlier public classification existed only on this unmerged PR branch and was never a shipped contract.

* test(plugins): map test-state in package boundaries
2026-07-25 05:28:26 -07:00
Vincent Koc 21667ef33c refactor(telegram): reuse shared error coercion (#113589) 2026-07-25 17:10:51 +08:00
Peter Steinberger d2b6573690 refactor(channels): remove v2026.7.2-gated compat (flat streaming keys, group intro hint) (#113533)
* refactor(channels): remove flat streaming compat

maintainer-approved early removal of v2026.7.2-gated compat

* refactor(channels): remove group intro hint adapter

maintainer-approved early removal of v2026.7.2-gated compat

Plugin SDK surface baseline update is maintainer-approved for this intentional removal.
2026-07-25 01:09:25 -07:00
Peter Steinberger a5d758e74b refactor(plugin-sdk): share channel DM policy setup (#113537) 2026-07-25 01:00:53 -07:00
Peter Steinberger 92a35b599a refactor: share channel probe runner (#113540) 2026-07-25 00:24:31 -07:00
Peter Steinberger 0881c7d27b refactor: share feishu docx/broadcast and telegram send bookkeeping (#113541)
* refactor(feishu): deduplicate docx insertion stages

* refactor(feishu): share broadcast inbound adapter

* refactor(telegram): share outbound send bookkeeping
2026-07-25 00:18:28 -07:00
Peter Steinberger 82d1a03f25 refactor(agents): move implicit-main fallback into load-time roster injection (#112678)
* refactor(agents): require explicit roster defaults

* feat(onboard): create named first roster agent

* refactor(agents): remove runtime main fallbacks

* style(agents): apply roster refactor formatting

* refactor(agents): finish roster-only runtime sweep

* fix(doctor): migrate legacy main session sqlite

* fix(doctor): harden roster session migrations

* fix(onboard): commit first agent atomically

* fix(config): support empty-roster analysis

* fix(agents): preserve legacy main state during creation

* fix(setup): materialize baseline agent roster

* fix(agents): harden legacy default transfer recovery

* fix(agents): simplify roster-only legacy compatibility

* fix(agents): preserve staged first-agent entries

* fix(config): migrate persisted implicit-main rosters

* fix(config): preserve staged empty rosters

* fix(agents): finalize roster-only upgrade paths

* fix(sessions): close legacy main migration outcomes

* fix(config): migrate legacy roster markers at load

* fix(sessions): preserve roster upgrade history

* refactor(sessions): restore lean legacy main compatibility

* fix(setup): prepare first-agent credentials before publish

* fix(config): stabilize roster snapshot migration

* refactor(sessions): shrink legacy main compatibility

* fix(agents): restore roster compatibility fidelity

* fix(sessions): preserve divergent legacy history

* refactor(agents): narrow roster-only scope

* fix(config): isolate roster migration

* test(agents): align roster-only fixtures

* fix(agents): keep main agent undeletable

* fix(agents): harden roster migration invariants

* fix(agents): close setup and audit scope gaps

* fix(cron): scope session reaper throttles by agent

* fix(agents): preserve scoped owner precedence

* fix(config): preserve authored config ownership

* fix(setup): keep default workspace and roster in sync

* fix(setup): preserve default entry workspace on bare runs

* fix(agents): adapt roster rebase to keyed entries

* fix(agents): honor both roster representations

* fix(agents): route roster reads through shared helpers

* fix(config): preserve canonical roster writes

* fix(cron): resolve dynamic default for session reaper

* fix(agents): close dynamic default migration gaps

* fix(agents): align scoped session ownership

* fix(sessions): preserve legacy main directory casing

* fix(agents): align cron and legacy auth ownership

* fix(setup): provision the committed default workspace

* fix(cron): align scoped ownership and reaping

* fix(cron): treat blank agent ids as absent

* fix(cron): retain configured session-store owners

* fix(agents): repair roster-aware CI boundaries

* fix(cron): preserve scoped ownership resolution

* fix(agents): preserve rosterless maintenance paths

* fix(agents): propagate roster ownership through runtime boundaries

* fix(agents): preserve roster ownership across runtime paths

* fix(agents): harden roster diagnostics and legacy routing

* fix(agents): remove redundant diagnostic import

* test(agents): type CLI policy fixture explicitly

* fix(config): preserve canonical roster mutation identity

* fix(doctor): read canonical agent rosters consistently

* fix(config): resolve compound roster unsets safely

* fix(config): finalize main-session reconciliation

* fix(doctor): read canonical session state safely

* fix(sessions): preserve current visibility alias

* fix(config): track roster include provenance

* test(config): type roster provenance cases

* fix(config): refine roster include ownership

* fix(agents): preserve staged roster invariants

* test(config): align fixtures with explicit roster ownership

* test(node-host): preserve optional plan typing

* fix(config): preserve authored roster projections

* test(config): keep raw roster fixtures explicit

* test(config): normalize rosters at runtime fixtures

* fix(config): protect authored roster ownership

* fix(agents): require explicit session ownership

* fix(agents): enforce scoped roster ownership

* fix(sessions): merge fixed-store agent partitions

* fix(agents): harden roster ownership boundaries

* fix(config): reject ambiguous roster projections

* fix(sessions): preserve persisted store ownership

* fix(sessions): keep collision diagnostics additive

* fix(security): scan malformed roster workspaces

* test(config): align snapshot fixtures after rebase

* test(agents): use explicit roster fixtures

* fix(config): harden roster diagnostic boundaries

* fix(sessions): isolate fixed-store agent databases

* test(agents): type malformed default markers

* refactor(sessions): extract store collision resolution

* test(system-agent): split oversized setup coverage

* style(system-agent): format split setup suite

* fix(sessions): preserve promoted store ownership

* fix(sessions): derive scoped owner before target

* fix(sessions): preserve explicit sqlite ownership

* fix(agents): restore roster compatibility across CI

* fix(agents): enforce roster-owned runtime boundaries

* fix(agents): satisfy default lookup lint

* test(sessions): split known-owner coverage

* fix(state): satisfy path identity lint

* fix(agents): preserve malformed roster safety boundaries

* fix(agents): restore roster compatibility at runtime boundaries

* fix(config): satisfy roster boundary type checks

* fix(agents): preserve roster ownership across runtime probes

Setup inference probes now execute as the configured roster owner. Malformed agent-prefixed session rows are intentionally omitted by the fail-closed visibility contract rather than normalized by tests.

* fix(agents): satisfy session list owner lint

* fix(agents): preserve roster-owned runtime boundaries

Restore shared logical rows for exact SQLite session locators while keeping their physical database owner separate. The ownership regression test now constructs an explicit sole-owner database directly instead of relying on first-touch capture, matching the intentional shared-store contract.

* fix(sessions): preserve multiply owned exact stores

* fix(sessions): restore runtime owner boundaries

Keep incognito sentinels agent-owned, fold default-agent approvals into the global snapshot, and preserve the configless legacy-main CLI policy fallback. Also repair the existing CLI watchdog test lifecycle so the compact shard observes its timeout without an unawaited assertion or async timer stall; product behavior is unchanged by that test-only fix.

* test(ci): align owner-scoped fixtures

These assertions are unchanged. The fixtures now declare the intended non-default runner, expose the session-key constant imported by production status code, and select the main approvals bucket explicitly on Windows.

* fix(agents): close final roster ownership gaps
2026-07-24 22:38:09 -07:00
joshavant 66a75bb9e5 fix(channels): unify routed outbound hook ownership 2026-07-24 20:05:30 -05:00
Peter Steinberger 73bba03e4c refactor: canonicalize session delivery state (#113225)
* refactor: canonicalize session delivery state

* test: canonicalize reply persistence fixtures

* test: canonicalize talk delivery fixtures

* test: canonicalize voice session routes

* test: canonicalize attachment delivery fixtures

* test: migrate gateway delivery fixtures

* fix: skip invalid session delivery rows

* test: align delivery SDK surface gates

* fix: preserve legacy delivery precedence

* test: canonicalize heartbeat delivery fixtures

* fix: preserve delivery route prompt identity

* test: canonicalize session delivery fixtures

* fix: preserve recoverable legacy delivery routes

* fix: canonicalize remaining session state

* fix: preserve canonical session classification

* style: format delivery state changes

* test: refresh plugin SDK delivery baseline

* test: avoid mutating session fixture input

* style: simplify delivery identity check

* style: simplify delivery origin spread

* fix: preserve fresh delivery route metadata

* test: assert canonical surface route switch

* fix: canonicalize doctor file-store imports

* fix: preserve transitional delivery migration state

* fix: satisfy canonical delivery CI gates

* ci: scope GitHub App token permissions

* test: infer canonical delivery projections

* test: canonicalize ACP requester delivery fixtures

* test: canonicalize harness rollback fixture

* style: apply pinned formatter
2026-07-24 01:01:19 -07:00
Peter Steinberger aae10cade5 refactor(markdown): unify format profile declarations (#113254)
* refactor(markdown): unify format profile declarations

* test(markdown): avoid suppression inventory drift
2026-07-24 00:37:59 -07:00
Peter Steinberger 07e625dac3 refactor(telegram): split outbound send operations (#113222)
* refactor(telegram): split outbound send operations

* refactor(telegram): keep test handle in send barrel
2026-07-23 23:38:37 -07:00
joshavant d8f1f098e5 fix(cron): honor explicit authority for senderless runs 2026-07-24 01:24:03 -05:00
Peter Steinberger 5fb3136be0 feat(telegram): render rich markdown lists natively (#113158) 2026-07-23 15:41:21 -07:00