Repository navigation
fix(channels): DM-capable channels reject the documented DM history overrides - #117306
ayaangazali wants to merge 4 commits into
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed August 8, 2026, 2:56 PM ET / 18:56 UTC. ClawSweeper reviewWhat this changesThe PR adds documented root and per-contact DM history override fields to bundled channel schemas, types, generated metadata, and a contract test. Merge readiness⛔ Blocked until stronger real behavior proof is added - 9 items remain Keep open: the documented root override repair is valid, but the exact head still accepts account-scoped values the core silently ignores and misses ClickClack’s direct-message route. Priority: P1 Review scores
Verification
How this fits togetherChannel configuration is validated by each bundled channel schema before the gateway starts. Direct-message sessions then pass through the shared history resolver, which chooses a per-contact or channel history limit for the agent transcript window. flowchart LR
A[Operator channel settings] --> B[Channel schema validation]
B --> C[Generated channel metadata]
C --> D[Direct-message session routing]
D --> E[Shared history resolver]
E --> F[Agent transcript window]
G[Account-specific settings] --> E
Before merge
Findings
Agent review detailsSecurityNone. PR surfaceSource +54, Tests +64, Generated 0. Total +118 across 20 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Refresh and land or incorporate the account-first resolver repair from #119326, add ClickClack to the schema parity repair, then prove root and account precedence on the exact rebased head. Do we have a high-confidence way to reproduce the issue? Yes, from source: ClickClack has direct routes and a strict schema without the documented fields, while affected multi-account schemas accept account values that the current resolver never reads. Is this the best way to solve the issue? No. The schema additions must be paired with the owner-level account resolver fix and complete direct-route coverage rather than leaving accepted settings inert or omitted. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 82f6280fa86a. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (10 earlier review cycles; latest 8 shown)
|
|
Pushed a baseline fix: Regenerated with the repo generator ( I hit the same thing on my other schema PRs today and have fixed each one the same way. |
|
All three findings addressed in 1. Per-DM Feishu needed different handling and my first attempt there was wrong. It already has a 2. Extension configuration types. Added 3. Account-level claim. You are right and I have removed it. One unrelated failure I want to be upfront about: I will update the PR body to match the corrected account-level wording. |
|
Picking up the P2 about Splitting root and account schemas here would make these channels inconsistent with the shipped core shape rather than more correct. Ten channels already accept it under The account-blind reader is also the outlier in core. Every sibling key in this family already resolves account then root:
So I am fixing the resolver instead of narrowing these schemas. One sibling gap worth naming while I am here: |
|
The resolver fix is up as #119326. It makes |
2c90849 to
f5ece16
Compare
|
Widened this PR after the same blind spot turned up on its sibling. Rebased onto current What I found. The selector here keys DM capability on const dmCapableChannels = ... Object.hasOwn(properties, "dmPolicy") ...Three channels route DMs without publishing that key, so they were invisible to it and their strict schemas were rejecting settings the resolver would have applied:
Widening it immediately surfaced a second gap I had not intended to find: the per-DM map. The first run after the change failed with because I had added This is the same class of finding you raised on #118152, where Twitch and Tlon route group sessions without a group allowlist. Both selectors were inferring a capability from an unrelated config surface. I have now checked the remaining rejecting channels rather than guessing: buzz, clickclack, and qa-channel build no One caveat I have flagged before and will repeat here: Tlon's live zod is permissive while its generated schema is closed, so for Tlon "the schema rejects this" is precisely true only of the packaged schema. The addition is still correct, and explicit beats accidental passthrough. Verification: contract test 43/43, |
f5ece16 to
4ceaa46
Compare
|
Rebased onto current Re-verified all six channels before rebasing rather than trusting the original write-up: on current Conflicts were only the three generated artifacts. I reset them to This is the widest of the schema-parity set, so if the scope is the sticking point I am happy to split it per channel or close it. |
All three declare direct chat types and build kind:direct routes, so the session-key resolver applies dmHistoryLimit and dms.<id>.historyLimit for them, but their strict schemas rejected both. The contract selector keyed on dmPolicy, which none of them publishes, so it could not catch the gap.
4ceaa46 to
e6c0517
Compare
|
CI note after the rebase, since the red here is not an assertion failure.
I checked the obvious suspicion first, that my regenerated Locally on this branch both generator I do not have rerun rights on this repo, so I cannot retrigger those two jobs directly. Happy to push again if you want another attempt, or to split the generated-artifact refresh into its own commit if that makes the failing lanes cheaper to judge. |
|
Sharper cause for the red checks than my note above, now that I have measured it.
Fork PRs cannot reach the Blacksmith runners and fall back to the standard 2-core GitHub runner. The build-spawning shards, whose Every currently-passing PR I sampled was a same-repo branch; the failing ones I found were forks. So I am not pushing a speculative fix for these three, since anything I changed would be guessing at an infrastructure limit. |
|
Closing this one deliberately, to keep my open queue under this repo's 20-PR author cap. Not withdrawn on merit: the gap still reproduces on current This is also the one carrying an unresolved P1 from review about accepting account scopes the resolver ignores, so it is the fairest of the set to pull back and rework rather than leave sitting. The branch |
What Problem This Solves
docs/gateway/config-channels.md:864documents the DM history resolver as explicitly channel-agnostic:Six bundled channels that expose a DM policy reject that key, so following the docs refuses the whole config. Verified against current
main(dccb1b90138) withdistrebuilt from that commit, isolated state dir:Affected:
line,mattermost,nostr,sms,zalo,zalouser.The reader matches the doc claim.
src/agents/embedded-agent-runner/history.ts:117-146walks everycfg.channelsentry and matches by normalized provider id with no fixed list, then:154-160returnsproviderConfig.dms?.[userId]?.historyLimit ?? providerConfig.dmHistoryLimitfordirectand legacydmsessions. Callers are core and channel-agnostic (run/attempt-history-prepare.ts:185,compaction-session-execution.ts:342).zalouseris the sharpest illustration: it already acceptshistoryLimitbut rejectsdmHistoryLimit, so group history is tunable there while DM history is not.Why This Change Was Made
Same owner-boundary shape as #112392, #117206, #117287 and #117302: the runtime and docs agree on a key, and individual strict schemas do not.
dmHistoryLimitis part of the shared common channel account shape (src/config/zod-schema.channel-messaging-common.ts) and ofReplyRuntimeConfigSchemaShape(src/config/zod-schema.core.ts:695), which is why channels built on either already accept it. These six hand-roll their account schema and omit it.Each channel gets the same one-line optional non-negative integer beside its existing
dmPolicy, matching the shared shape's definition. Declaring it on the account base covers the channel level andaccounts.<id>for the multi-account channels.User Impact
Operators of these channels can set
channels.<id>.dmHistoryLimitandchannels.<id>.dms.<id>.historyLimitas documented, instead of having the entire config refused. No behavior change when the key is absent: it is optional, and the resolver's existing precedence and no-limit default are untouched.Evidence
After this change the same config loads and the value round-trips:
The contract test derives its channel list from the generated metadata rather than hardcoding it, so any future DM-capable channel is covered automatically. Before the schema fix:
After:
What I checked and deliberately did not change:
clickclack,qa-channel,raft,twitchandbuzzalso lack it, but they declare nodmPolicy, so noprovider:direct:<id>session exists for them and the key would be inert config surface. The contract test scopes itself the same way.historyLimit, the resolver, its precedence, or the no-limit default.accounts.<id>.dmHistoryLimit) validates because the key sits on the shared account base, but the resolver reads channel level only (history.ts:117-146never descends intoaccounts), so this PR does not claim account-scoped DM limits are honored.dmHistoryLimitis not retired: it is absent fromsrc/config/dead-config-keys.test.tsand from the doctor retired-migration list.AI-assisted: researched, written, and validated with Claude Code under my direction. I have read and understand the change.