Skip to content

fix(channels): DM-capable channels reject the documented DM history overrides - #117306

Closed
ayaangazali wants to merge 4 commits into
openclaw:mainfrom
ayaangazali:fix/dm-history-limit-schema-parity
Closed

ayaangazali wants to merge 4 commits into
openclaw:mainfrom
ayaangazali:fix/dm-history-limit-schema-parity

Conversation

@ayaangazali

@ayaangazali ayaangazali commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

docs/gateway/config-channels.md:864 documents the DM history resolver as explicitly channel-agnostic:

This resolver reads channels.<provider>.dmHistoryLimit and channels.<provider>.dms.<id>.historyLimit for any channel whose session key follows the standard provider:direct:<id> (or legacy provider:dm:<id>) shape, so it works across bundled and plugin channels alike, not just a fixed list.

Six bundled channels that expose a DM policy reject that key, so following the docs refuses the whole config. Verified against current main (dccb1b90138) with dist rebuilt from that commit, isolated state dir:

$ openclaw config get channels.sms
- channels.sms: invalid config: must not have additional properties: "dmHistoryLimit"

Affected: line, mattermost, nostr, sms, zalo, zalouser.

The reader matches the doc claim. src/agents/embedded-agent-runner/history.ts:117-146 walks every cfg.channels entry and matches by normalized provider id with no fixed list, then :154-160 returns providerConfig.dms?.[userId]?.historyLimit ?? providerConfig.dmHistoryLimit for direct and legacy dm sessions. Callers are core and channel-agnostic (run/attempt-history-prepare.ts:185, compaction-session-execution.ts:342).

zalouser is the sharpest illustration: it already accepts historyLimit but rejects dmHistoryLimit, 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. dmHistoryLimit is part of the shared common channel account shape (src/config/zod-schema.channel-messaging-common.ts) and of ReplyRuntimeConfigSchemaShape (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 and accounts.<id> for the multi-account channels.

User Impact

Operators of these channels can set channels.<id>.dmHistoryLimit and channels.<id>.dms.<id>.historyLimit as 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:

$ openclaw config get channels.sms
  "accountSid": "AC123",
  "dmHistoryLimit": 20,

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:

× line accepts channels.<id>.dmHistoryLimit
× mattermost accepts channels.<id>.dmHistoryLimit
× nostr accepts channels.<id>.dmHistoryLimit
× sms accepts channels.<id>.dmHistoryLimit
× zalo accepts channels.<id>.dmHistoryLimit
× zalouser accepts channels.<id>.dmHistoryLimit
  (plus the accounts.<account> cases)

After:

$ node scripts/run-vitest.mjs src/plugins/contracts/channel-dm-history-limit.contract.test.ts
Tests  37 passed (37)

$ node scripts/run-vitest.mjs extensions/line        478 passed
$ node scripts/run-vitest.mjs extensions/mattermost  742 passed
$ node scripts/run-vitest.mjs extensions/nostr       266 passed
$ node scripts/run-vitest.mjs extensions/sms         100 passed
$ node scripts/run-vitest.mjs extensions/zalo        146 passed
$ node scripts/run-vitest.mjs extensions/zalouser    270 passed

$ node --import tsx scripts/generate-bundled-channel-config-metadata.ts --check
(clean)

What I checked and deliberately did not change:

  • I did not add the key to channels without a DM surface. clickclack, qa-channel, raft, twitch and buzz also lack it, but they declare no dmPolicy, so no provider:direct:<id> session exists for them and the key would be inert config surface. The contract test scopes itself the same way.
  • I did not touch historyLimit, the resolver, its precedence, or the no-limit default.
  • Account-level (accounts.<id>.dmHistoryLimit) validates because the key sits on the shared account base, but the resolver reads channel level only (history.ts:117-146 never descends into accounts), so this PR does not claim account-scoped DM limits are honored.
  • I confirmed dmHistoryLimit is not retired: it is absent from src/config/dead-config-keys.test.ts and from the doctor retired-migration list.
  • The regenerated metadata snapshot came from the repo generator, not hand editing.
  • The contract test asserts against the generated channel metadata rather than calling the validator in-process, because the in-process validator resolves plugin schemas through built output and can report a channel as passing while its schema is still broken. I hit exactly that on fix(channels): feishu and mattermost reject the contextVisibility key their runtime reads #117287.

AI-assisted: researched, written, and validated with Claude Code under my direction. I have read and understand the change.

Copilot AI review requested due to automatic review settings August 1, 2026 08:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@openclaw-barnacle openclaw-barnacle Bot added channel: line Channel integration: line channel: mattermost Channel integration: mattermost channel: nostr Channel integration: nostr channel: zalo Channel integration: zalo channel: zalouser Channel integration: zalouser channel: sms Channel integration: sms size: S labels Aug 1, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 8, 2026, 2:56 PM ET / 18:56 UTC.

ClawSweeper review

What this changes

The 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
Reviewed head: e6c0517bb4c6880e9bcece9fcecf3513e5f98374

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The root-level premise is sound, but two P1 correctness gaps and stale subset proof prevent merge readiness.
Proof confidence 🦐 gold shrimp (3/6) Needs stronger real behavior proof before merge: The prior SMS terminal transcript proves an earlier subset, but it predates the final Raft/Reef/Tlon expansion and does not demonstrate the exact head after the required repairs. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Patch quality 🦪 silver shellfish (2/6) 2 actionable review findings remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: The prior SMS terminal transcript proves an earlier subset, but it predates the final Raft/Reef/Tlon expansion and does not demonstrate the exact head after the required repairs. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed 6 items Root-only resolver: Current main accepts only a session key and config, returns the channel root object, and reads root dms and dmHistoryLimit; it has no account lookup.
Account schema reuse: The multi-account schema builder reuses a channel base schema for accounts.&lt;id> unless overridden, so the added fields validate at account scope for affected multi-account channels.
ClickClack omission: ClickClack declares direct chat routing but its strict schema still lacks both DM history fields; the new test’s manual direct-routing list omits it.
Findings 2 actionable findings [P1] Honor account-scoped DM limits before accepting them
[P1] Cover ClickClack's direct-message history overrides
Security None None.

How this fits together

Channel 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
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: The prior SMS terminal transcript proves an earlier subset, but it predates the final Raft/Reef/Tlon expansion and does not demonstrate the exact head after the required repairs. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
  • Honor account-scoped DM limits before accepting them (P1) - This shared base is reused under accounts.&lt;id>, so the new fields validate there, but the current resolver reads only the channel root. The configuration will round-trip yet never affect history; fold in or depend on the account-first resolver repair before accepting this scope.
  • Cover ClickClack's direct-message history overrides (P1) - The new exception list includes only Raft, Reef, and Tlon, but ClickClack also creates standard direct sessions and its strict schema still rejects both fields. Add ClickClack to the repair and make the contract’s eligibility source cover this route.
  • Resolve merge risk (P1) - Merging now lets affected multi-account channels accept and echo account-scoped DM limits that do nothing at runtime.
  • Resolve merge risk (P1) - The new parity test excludes ClickClack, so a documented direct-message override remains rejected after merge.
  • Complete next step (P2) - Hold for the linked core owner-boundary repair, the ClickClack parity fix, exact-head real-behavior proof, and green exact-head CI.
  • Improve patch quality - Honor account-first history precedence or stop accepting account-scoped fields.
  • Improve patch quality - Add ClickClack to the direct-message schema repair and parity coverage.
  • Improve patch quality - Post a redacted exact-head terminal proof for a newly covered direct-routing channel after the fixes.

Findings

  • [P1] Honor account-scoped DM limits before accepting them — extensions/line/src/config-schema.ts:35-36
  • [P1] Cover ClickClack's direct-message history overrides — src/plugins/contracts/channel-dm-history-limit.contract.test.ts:29-40
Agent review details

Security

None.

PR surface

Source +54, Tests +64, Generated 0. Total +118 across 20 files.

View PR surface stats
Area Files Added Removed Net
Source 16 54 0 +54
Tests 1 64 0 +64
Docs 0 0 0 0
Config 0 0 0 0
Generated 3 17 17 0
Other 0 0 0 0
Total 20 135 17 +118

Review metrics

Metric Value Why it matters
Configuration surface 9 channel schemas gain 2 DM-history fields; Feishu gains 1 per-DM leaf; channel baseline +66 These additive settings must match resolver scope and every direct-routing bundled channel before merge.
Production versus tests production +71/-17, tests +64/-0 The production growth is contract alignment, but the remaining P1 gaps mean it is not yet a complete alignment.

Stored data model

Persistent data-model change detected: unknown-data-model-change: src/config/bundled-channel-config-metadata.generated.ts, vector/embedding metadata: src/plugins/contracts/channel-dm-history-limit.contract.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Repair the resolver and complete channel coverage (recommended)
    Make the resolver honor account-first DM history values, add ClickClack’s documented fields and regression coverage, then rebase this PR onto that result.
  2. Pause until the core repair is viable
    Hold this schema PR until the linked core repair is refreshed against current main and its account-precedence behavior is proven.

Technical review

Best 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:

  • [P1] Honor account-scoped DM limits before accepting them — extensions/line/src/config-schema.ts:35-36
    This shared base is reused under accounts.&lt;id>, so the new fields validate there, but the current resolver reads only the channel root. The configuration will round-trip yet never affect history; fold in or depend on the account-first resolver repair before accepting this scope.
    Confidence: 0.98
  • [P1] Cover ClickClack's direct-message history overrides — src/plugins/contracts/channel-dm-history-limit.contract.test.ts:29-40
    The new exception list includes only Raft, Reef, and Tlon, but ClickClack also creates standard direct sessions and its strict schema still rejects both fields. Add ClickClack to the repair and make the contract’s eligibility source cover this route.
    Confidence: 0.96

Overall correctness: patch is incorrect
Overall confidence: 0.94

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 82f6280fa86a.

Labels

Label justifications:

  • P1: The PR leaves documented direct-message history settings rejected for ClickClack and accepts account settings that silently have no runtime effect.
  • merge-risk: 🚨 compatibility: This changes channel config acceptance while account-scoped values remain accepted but ignored by the shared resolver.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: The prior SMS terminal transcript proves an earlier subset, but it predates the final Raft/Reef/Tlon expansion and does not demonstrate the exact head after the required repairs. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Evidence

What I checked:

Likely related people:

  • steipete: Current resolver, schema-builder, and documentation lines trace to the current-main history refactor commit. (role: recent area contributor; confidence: medium; commits: f4f53103558a; files: src/agents/embedded-agent-runner/history.ts, src/channels/plugins/config-schema.ts, docs/gateway/config-channels.md)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (10 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-01T18:00:43.028Z sha f5aef126aa807bdc6f09e817c4a4677a7a55cfcd :: needs changes before merge. :: [P2] Accept the documented per-DM dms override | [P2] Keep the plugin configuration types aligned
  • reviewed 2026-08-01T18:35:11.864Z sha f5aef126aa807bdc6f09e817c4a4677a7a55cfcd :: needs changes before merge. :: [P2] Accept the documented per-DM dms override | [P2] Keep extension configuration types aligned | [P2] Do not claim account-level DM limits without a resolver
  • reviewed 2026-08-01T19:23:02.398Z sha 2c908498de074c04ca9aa591fa184db9821306bf :: needs maintainer review before merge. :: none
  • reviewed 2026-08-01T19:43:03.485Z sha 2c908498de074c04ca9aa591fa184db9821306bf :: needs maintainer review before merge. :: none
  • reviewed August 4, 2026, 11:19 AM ET / 15:19 UTC sha unknown :: needs changes before merge. :: [P2] Keep DM history overrides out of account schemas
  • reviewed August 5, 2026, 11:06 AM ET / 15:06 UTC sha unknown :: found issues before merge. :: [P2] Keep DM history overrides out of account schemas
  • reviewed 2026-08-05T20:47:05.543Z sha f5ece16cba4db354bc6efd2ac690743695ca48a3 :: needs real behavior proof before merge. :: [P2] Honor account-scoped DM limits before accepting them
  • reviewed 2026-08-07T18:45:59.933Z sha f5ece16cba4db354bc6efd2ac690743695ca48a3 :: needs real behavior proof before merge. :: [P1] Avoid accepting account scopes the resolver ignores

@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Aug 1, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 1, 2026
@ayaangazali

Copy link
Copy Markdown
Contributor Author

Pushed a baseline fix: scripts/generate-config-doc-baseline.ts --check was reporting a hash mismatch on this branch because adding a config key changes the generated config-surface baseline, and I had not regenerated it.

Regenerated with the repo generator (--write), so docs/.generated/config-baseline.counts.json and config-baseline.sha256 are now current and the gate passes. The channel count stays within the existing budget, so no budget raise was needed here.

I hit the same thing on my other schema PRs today and have fixed each one the same way.

@ayaangazali

Copy link
Copy Markdown
Contributor Author

All three findings addressed in 2c908498de0. The third one was a genuine over-claim on my part.

1. Per-DM dms override. Correct: the doc sentence covers channels.<provider>.dms.<id>.historyLimit as well, and src/agents/embedded-agent-runner/history.ts:157-159 reads it before falling back to dmHistoryLimit, so fixing only half the sentence left the documented per-DM form still rejected. Added dms: z.record(z.string(), DmConfigSchema.optional()).optional() to the six channels, mirroring the shared shape.

Feishu needed different handling and my first attempt there was wrong. It already has a dms map, but its own local DmConfigSchema is { enabled, systemPrompt }, a different per-DM concept that has no historyLimit. I initially scripted in a second dms key plus a colliding import, caught it, reverted, and instead widened Feishu's existing leaf with the shared historyLimit field. That keeps its existing per-DM options intact.

2. Extension configuration types. Added dmHistoryLimit and dms to the hand-written account types for line, mattermost, nostr, sms, zalo and zalouser. Feishu needs no change there because its types are z.infer of its schema.

3. Account-level claim. You are right and I have removed it. resolveProviderConfig (history.ts:117-146) matches channels[provider] and returns that object directly; it never descends into accounts.<id>, so there is no account-level resolver for DM history. My contract test was asserting accounts.<account>.dmHistoryLimit as though it were supported behavior. Those assertions are gone, replaced with coverage of the per-DM dms.<id>.historyLimit form that the resolver does read. The keys still validate at account level because they sit on the shared account base, but the PR no longer implies the resolver honors them.

$ node scripts/run-vitest.mjs src/plugins/contracts/channel-dm-history-limit.contract.test.ts
Tests  37 passed (37)

line 478, mattermost 742, nostr 266, sms 100, zalo 146, zalouser 270 - all passed
metadata --check clean, config-doc baseline --check clean

One unrelated failure I want to be upfront about: extensions/feishu/src/doctor.test.ts > removes only unhealthy Feishu direct sessions ... fails for me locally, and it fails identically with my changes stashed, so it is not from this PR.

I will update the PR body to match the corrected account-level wording.

@ayaangazali ayaangazali changed the title fix(channels): DM-capable channels reject the documented dmHistoryLimit override fix(channels): DM-capable channels reject the documented DM history overrides Aug 1, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 1, 2026
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Aug 4, 2026
@ayaangazali

Copy link
Copy Markdown
Contributor Author

Picking up the P2 about dmHistoryLimit remaining in the base that accounts.* reuses. The finding is right that an account-level value validates while getHistoryLimitFromSessionKey only reads the channel root, so it is accepted and ignored. Of the two remedies you named, I want to argue for the second one, and I would rather show the evidence than just assert it.

Splitting root and account schemas here would make these channels inconsistent with the shipped core shape rather than more correct. buildCommonChannelAccountShape declares both keys as part of the common account shape (src/config/zod-schema.channel-messaging-common.ts:126-128), which is why account-scope acceptance is already shipped broadly. Reading the generated metadata on main:

dmHistoryLimit    root=true  accounts.<id>=true   discord, feishu, googlechat, imessage,
                                                  irc, nextcloud-talk, signal, slack,
                                                  telegram, whatsapp

Ten channels already accept it under accounts.<id>, including discord, telegram, and whatsapp. Slack is the only one that independently reads the account value (extensions/slack/src/monitor/provider.ts:293 reads account.config.dmHistoryLimit), so on the other nine it is inert today, with or without this PR. In other words the account-scope no-op is pre-existing behavior owned by the resolver, not something this branch introduces.

The account-blind reader is also the outlier in core. Every sibling key in this family already resolves account then root:

  • contextVisibility - src/config/context-visibility.ts:54-59
  • heartbeatVisibility - src/infra/heartbeat-visibility.ts:50-54
  • configWrites - src/channels/plugins/config-write-policy-shared.ts:98
  • responsePrefix - src/agents/identity.ts:109-121
  • mediaMaxMb - src/media/configured-max-bytes.ts:45-50

historyLimit and dmHistoryLimit were the only ones whose reader stopped at the channel root. The docs also already promise the account form (docs/concepts/messages.md:90 names channels.telegram.accounts.<id>.historyLimit).

So I am fixing the resolver instead of narrowing these schemas. attempt.agentAccountId already carries the channel account id at the single production call site, so it is a small change at the owner boundary that fixes every channel at once. I am opening that as a separate core PR rather than folding it in here, since it stands on its own and this PR is schema-only. I will link it here as soon as it is up, and I am happy to rebase this one on top of it if you would prefer they land in order.

One sibling gap worth naming while I am here: dms (which carries dms.<id>.historyLimit, read by the same resolver) is rejected by the DM-capable channels in this PR's list, line, mattermost, nostr, sms, zalo, and zalouser. I left it out to keep this diff to one key, but say the word and I will fold it in here rather than filing another PR.

@ayaangazali

Copy link
Copy Markdown
Contributor Author

The resolver fix is up as #119326. It makes getHistoryLimitFromSessionKey resolve the active account before the channel root, so the account-scoped values this PR accepts stop being inert. Happy to rebase this one on top of it if you would rather they land in order.

@ayaangazali
ayaangazali force-pushed the fix/dm-history-limit-schema-parity branch from 2c90849 to f5ece16 Compare August 5, 2026 19:57
@openclaw-barnacle openclaw-barnacle Bot added channel: tlon Channel integration: tlon channel: raft Channel integration: Raft channel: reef Channel integration: reef labels Aug 5, 2026
@ayaangazali

Copy link
Copy Markdown
Contributor Author

Widened this PR after the same blind spot turned up on its sibling. Rebased onto current main at the same time.

What I found. The selector here keys DM capability on dmPolicy:

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:

  • Raft, chatTypes: ["direct"] (channel.ts:39), builds kind: "direct" at inbound.ts:37
  • Reef, chatTypes: ["direct"] (channel.ts:110), builds kind: "direct" at channel.ts:163 and :275
  • Tlon, chatTypes: ["direct", "group", "thread"] (channel.ts:110), builds kind: "direct" at session-route.ts:36

getHistoryLimitFromSessionKey keys on the session kind, not on any channel allowlist, so provider:direct:<id> sessions on those three do consult dmHistoryLimit and dms.<id>.historyLimit. Added both keys to all three and widened the selector, with the reasoning at the call site rather than as a bare list.

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

× raft accepts channels.<id>.dms.<id>.historyLimit
× reef accepts channels.<id>.dms.<id>.historyLimit
× tlon accepts channels.<id>.dms.<id>.historyLimit

because I had added dmHistoryLimit alone. dms is read by the same resolver, so adding one without the other would have left the documented per-contact override still rejected. Both are in now, matching how this PR already declares them for the other channels.

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 kind: "direct" routes, so they stay out.

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, extensions/raft 11 tests, extensions/reef 287, extensions/tlon 279, generate-bundled-channel-config-metadata.ts --check clean, boundary check exit 0, tsgo -p tsconfig.extensions.json clean, git diff --check clean. Both generators re-run; channel config surface 3738 to 3758.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P1 High-priority user-facing bug, regression, or broken workflow. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P2 Normal backlog priority with limited blast radius. labels Aug 5, 2026
@ayaangazali
ayaangazali force-pushed the fix/dm-history-limit-schema-parity branch from f5ece16 to 4ceaa46 Compare August 8, 2026 16:55
@ayaangazali

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (74b1627f888); this is mergeable again.

Re-verified all six channels before rebasing rather than trusting the original write-up: on current main, dmHistoryLimit is still rejected by closed schemas on line, mattermost, nostr, sms, zalo and zalouser, plus the raft, reef and tlon additions from the later commits in this branch.

Conflicts were only the three generated artifacts. I reset them to main and re-ran both generators rather than hand-merging, so they reflect current main plus this change. Both --check gates pass, the contract suite is 43/43, and tsgo -p tsconfig.core.json is clean.

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.
@ayaangazali
ayaangazali force-pushed the fix/dm-history-limit-schema-parity branch from 4ceaa46 to e6c0517 Compare August 8, 2026 17:10
@ayaangazali

Copy link
Copy Markdown
Contributor Author

CI note after the rebase, since the red here is not an assertion failure.

checks-fast-bun-launcher ends with [test] failed 1 Vitest shard in 300.57s after a run whose tsdown-build invocations each take 37 to 48 seconds, and build-artifacts ends [vitest] FAILED (exit 143), which is SIGTERM rather than a failed expectation. Both look like the heavy build-spawning shards hitting their wall clock, and they failed the same way across two independent runs on two different bases, so it is not a single bad run.

I checked the obvious suspicion first, that my regenerated bundled-channel-config-metadata.generated.ts was wrong, because the textual diff against main is large. It is not: parsing both files and comparing gives the same 27 channels with no channel missing, and the byte delta is 290,208 to 290,422, which is the one added key. The large diff is only the packed string chunks re-wrapping when content shifts.

Locally on this branch both generator --check gates pass, the contract suite is green, and tsgo -p tsconfig.core.json is clean.

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.

@ayaangazali

Copy link
Copy Markdown
Contributor Author

Sharper cause for the red checks than my note above, now that I have measured it.

build-artifacts, checks-fast-bun-launcher and check-sqlite-session-flip-proof fail here because of the runner a fork PR gets, not anything in this diff. Comparing the same job on this PR and on a same-repo PR from the same hour:

runner label duration result
fork PR ubuntu-24.04 (2 core) ~8 min killed
same-repo PR blacksmith-32vcpu-ubuntu-2404 ~6 min passed

Fork PRs cannot reach the Blacksmith runners and fall back to the standard 2-core GitHub runner. The build-spawning shards, whose tsdown-build invocations take 37 to 48 seconds each, do not fit in the wall clock there, so they end in exit 143, which is SIGTERM rather than a failed expectation.

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.

@ayaangazali

Copy link
Copy Markdown
Contributor Author

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 main (I checked all six channels plus the raft/reef/tlon additions this morning), the branch is rebased and mergeable, and both generator --check gates pass. But openclaw-barnacle has auto-closed three of my newer PRs for exceeding the cap, so holding my widest unreviewed changes open was costing other work its slot.

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 ayaangazali:fix/dm-history-limit-schema-parity stays intact. Happy to resubmit it narrower, per channel, with that P1 addressed, if this is a repair you want.

@ayaangazali ayaangazali closed this Aug 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: feishu Channel integration: feishu channel: line Channel integration: line channel: mattermost Channel integration: mattermost channel: nostr Channel integration: nostr channel: raft Channel integration: Raft channel: reef Channel integration: reef channel: sms Channel integration: sms channel: tlon Channel integration: tlon channel: zalo Channel integration: zalo channel: zalouser Channel integration: zalouser docs Improvements or additions to documentation merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: S status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants