Commit Graph

847 Commits

Author SHA1 Message Date
Peter Steinberger
1630607463 test: dedupe cron and channel fixtures 2026-04-23 18:29:32 +01:00
Mariano
3e956a4982 fix: align claude-cli prompt hooks (#70625)
Merged via squash.

Prepared head SHA: 3de89da38f
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Co-authored-by: mbelinky <132747814+mbelinky@users.noreply.github.com>
Reviewed-by: @mbelinky
2026-04-23 16:34:16 +02:00
Peter Steinberger
596b88986d chore: apply core lint cleanups 2026-04-23 05:30:49 +01:00
Peter Steinberger
cb16d22780 fix(cron): retire bundled mcp runtimes 2026-04-22 22:30:47 +01:00
Peter Steinberger
80f4c931e8 test: align telegram cron test doubles 2026-04-22 06:19:20 +01:00
Peter Steinberger
40719bcb74 refactor: move cron output policy to channel plugins 2026-04-22 06:11:49 +01:00
Ayaan Zaidi
2da1406b29 test(cron): trim message trace comments 2026-04-22 08:12:20 +05:30
davehappyminion
9db67e79a5 fix(cron): narrow accountId spoof guard to explicit mismatch only
Addresses codex P1 review on PR #69940: the previous guard rejected
targets that simply omitted accountId, but message-tool fills accountId
from the agent's bound account at exec time (message-tool.ts:730-733),
so account-bound cron jobs legitimately start with target.accountId
undefined. Rejecting that case lost skipMessagingToolDelivery, causing
dispatchCronDelivery to double-send.

Now we only reject when the tool explicitly names a *different*
accountId — which is the real CWE-284 spoof vector. Omission matches.

Tests updated accordingly:
- matcher unit test: flipped "omit accountId" case from false to true;
  "accountIds differ" case preserved as the real spoof guard
- integration tests: one legitimate-default case (rewrite happens),
  one explicit-mismatch case (rewrite suppressed)

658 cron tests pass.
2026-04-22 08:12:20 +05:30
davehappyminion
851bef9c25 fix(cron): rewrite generic message provider in trace + guard accountId spoof
When a cron job sends via the generic `message` tool, the delivery trace
previously recorded `messageToolSentTo[i].channel = "message"` even
though the send was resolved to a specific channel (e.g. telegram). This
made `jq` diffing intended-vs-actual awkward for the happy path.

Fix:
- `normalizeMessagingToolTarget` now rewrites `channel: "message"`
  to the resolved channel when `matchesMessagingToolDeliveryTarget`
  confirms the tool send matches the resolved cron delivery target.
  Genuinely unmatched generic sends keep the literal "message" so
  audits can still flag them.

- `matchesMessagingToolDeliveryTarget` now requires strict accountId
  equality whenever the resolved delivery carries an `accountId`. An
  omitted `target.accountId` previously short-circuited the guard and
  was treated as a wildcard, letting a generic send spoof attribution to
  any bot identity in the cron delivery trace (CWE-284). This was
  flagged by Aisle on #69771.

Tests:
- Unit: `matchesMessagingToolDeliveryTarget` rejects omitted-accountId
  against account-tied delivery; still matches same-accountId.
- Integration: cron run trace rewrites generic "message" to the
  resolved channel, preserves accountId on both sides, and leaves the
  literal "message" provider in place when the tool send omits
  accountId against an account-tied delivery.
2026-04-22 08:12:20 +05:30
Peter Steinberger
f1805ab54d fix: centralize provider thinking profiles 2026-04-21 09:13:35 +01:00
Ayaan Zaidi
b9d2e0f86d fix(cron): gate delivery prompt on message tool availability 2026-04-21 12:01:06 +05:30
Ayaan Zaidi
5579fef673 fix(cron): align dry-run delivery previews with target policy 2026-04-21 12:01:06 +05:30
Ayaan Zaidi
0b25a73288 fix(cron): resolve delivery preview server-side 2026-04-21 12:01:06 +05:30
Ayaan Zaidi
4f0a978fc2 fix(cron): track implicit message sends 2026-04-21 12:01:06 +05:30
Ayaan Zaidi
9e160d5c0f fix(cron): make delivery previews dry-run safe 2026-04-21 12:01:06 +05:30
Ayaan Zaidi
c18b6fc9da feat(cron): preview resolved delivery targets 2026-04-21 12:01:06 +05:30
Ayaan Zaidi
4c8299ca3d fix(cron): log delivery target trace 2026-04-21 12:01:06 +05:30
Ayaan Zaidi
d083702a7b fix(cron): require verified message delivery target 2026-04-21 12:01:06 +05:30
Ayaan Zaidi
4c1f187da0 fix(cron): keep message tool for chat delivery 2026-04-21 12:01:06 +05:30
Peter Steinberger
6ce17db11a fix: gate max thinking by model support 2026-04-21 07:02:43 +01:00
Dexter (Miaigi)
47bb5ddece fix(cost): snapshot estimatedCostUsd instead of accumulating (#69347)
The bug: three persist sites accumulated cost instead of snapshotting
it like tokens. This caused cost to be inflated 1x-72x on multi-persist
sessions because the same cumulative usage was added repeatedly.

Root cause: persistSessionUsageUpdate, updateSessionStoreAfterAgentRun,
and the cron isolated-agent run path all used:
  estimatedCostUsd = existingCost + runCost

But runCost was already computed from cumulative run usage, so this
added the same cost repeatedly on redundant persists.

Fix: snapshot cost directly like tokens already do:
  estimatedCostUsd = runCost

Files affected:
- src/auto-reply/reply/session-usage.ts
- src/agents/command/session-store.ts
- src/cron/isolated-agent/run.ts

Tests added:
- session-store.test.ts: verify cost is snapshotted, not accumulated
- session.test.ts: updated existing test to verify snapshot behavior

Fixes #69347
2026-04-21 03:44:25 +01:00
Peter Steinberger
14ceec27fa test: use synthetic config cron channel fixtures 2026-04-21 01:19:35 +01:00
Peter Steinberger
72571f0d38 test: decouple outbound target tests from bundled plugins 2026-04-20 23:14:50 +01:00
Peter Steinberger
8d1e734213 test: share cron store rename spy helper 2026-04-20 22:17:34 +01:00
Peter Steinberger
911cfe2adc refactor: use structured clone for local copies 2026-04-20 20:28:47 +01:00
Gustavo Madeira Santana
9641f9ebbb Reject array-shaped cron state sidecars 2026-04-20 15:20:20 -04:00
Peter Steinberger
bdc5a96db6 test: keep cron executor delivery default typed 2026-04-20 19:30:34 +01:00
Peter Steinberger
40c9d0affc test: share cron message tool fixtures 2026-04-20 19:25:22 +01:00
Feelw00
4be6ff9d5f feat(cron): split jobs.json into config and runtime state files (#63105)
Merged via squash.

Prepared head SHA: 470bb2561f
Co-authored-by: Feelw00 <45638585+Feelw00@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
2026-04-20 14:23:18 -04:00
Peter Steinberger
33e63d914b test: share cron delivery job fixture 2026-04-20 19:22:41 +01:00
Peter Steinberger
e3dd80f9d4 refactor: share cron list page types 2026-04-20 14:31:56 +01:00
Peter Steinberger
0c444ff5ba fix: classify no-delivery cron runs correctly (#69285) 2026-04-20 14:15:53 +01:00
Peter Steinberger
6c711a64cb style: apply formatter fixes 2026-04-20 12:27:15 +01:00
Ayaan Zaidi
b64e1d8b91 fix(cron): require explicit recipient for mode none 2026-04-20 08:25:16 +05:30
Ayaan Zaidi
03de50e70b test(cron): cover mode none implicit recipient leak 2026-04-20 08:25:16 +05:30
Ayaan Zaidi
7d9a9d83ff fix: preserve isolated message targets (#69153)
* test(cron): cover delivery target context for mode none

* fix(cron): preserve target context for delivery mode none

* test(cron): cover isolated message target forwarding

* fix(cron): forward isolated message targets into embedded runs

* fix(cron): ignore implicit last-target context for mode none

* fix(cron): keep mode none channel explicit only

* test(cron): fix isolated target test typing

* fix: preserve isolated message targets (#69153)

* fix: preserve isolated message targets (#69153)
2026-04-20 08:05:32 +05:30
Ayaan Zaidi
9b38606d5c fix(gateway): preserve cron delivery validation behavior 2026-04-19 23:18:27 +05:30
Ayaan Zaidi
1d4e4314dd fix: preserve deferred cron heartbeat target (#69021)
* test(cron): cover deferred heartbeat target preservation

* fix(cron): preserve deferred heartbeat target override

* test(cron): update timer expectation for deferred heartbeat target

* fix(cron): preserve agent heartbeat config for targeted wakes

* test(cron): use wake request type in scheduler helper

* fix(cron): forward heartbeat overrides through gateway wake adapter

* fix(cron): preserve coalesced wake heartbeat overrides

* fix: preserve deferred cron heartbeat target (#69021)
2026-04-19 22:48:46 +05:30
Ayaan Zaidi
34334f0e68 test(cron): cover recurring delivery dedupe 2026-04-19 21:16:57 +05:30
Ayaan Zaidi
21cfc21e4f fix(cron): key delivery dedupe by execution 2026-04-19 21:16:57 +05:30
Ayaan Zaidi
f44a7423c2 refactor(cron): share execution id helper 2026-04-19 21:16:57 +05:30
Mariano
0787266637 tasks: extract detached task lifecycle runtime (#68886)
* tasks: extract detached task lifecycle runtime

* tests: relax gateway seam expectation

---------

Co-authored-by: Mariano Belinky <mariano@mb-server-643.local>
2026-04-19 10:56:31 +02:00
Peter Steinberger
6f076dcde7 test: share core channel delivery harness 2026-04-19 01:27:04 +01:00
Peter Steinberger
550b946696 test: share telegram forum delivery harness 2026-04-19 01:21:35 +01:00
Peter Steinberger
e1fe71872c test: share unresolved cron next-run fixtures 2026-04-19 01:05:15 +01:00
Peter Steinberger
c96a0b1112 test: share cron isolated job fixtures 2026-04-19 01:02:26 +01:00
Peter Steinberger
4fa961d4f1 refactor(lint): enable map spread rule 2026-04-18 20:37:12 +01:00
lukeboyett
c39314c14a fix(agents): prefer target agent's bound Matrix account for subagent spawns (#67508)
Merged via squash.

Prepared head SHA: 9300111038
Co-authored-by: lukeboyett <46942646+lukeboyett@users.noreply.github.com>
Co-authored-by: gumadeiras <5599352+gumadeiras@users.noreply.github.com>
Reviewed-by: @gumadeiras
2026-04-18 14:02:53 -04:00
Peter Steinberger
66385670e4 refactor: reduce unnecessary dynamic imports 2026-04-18 16:15:33 +01:00
Ted Li
9501656a8e fix(cron): clean up deleteAfterRun direct deliveries (#67807)
Merged via squash.

Prepared head SHA: d23711c2e9
Co-authored-by: MonkeyLeeT <6754057+MonkeyLeeT@users.noreply.github.com>
Co-authored-by: hxy91819 <8814856+hxy91819@users.noreply.github.com>
Reviewed-by: @hxy91819
2026-04-18 18:17:18 +08:00