Skip to content

fix(channels): bundled channels reject the documented mediaMaxMb override - #118157

Merged
steipete merged 6 commits into
openclaw:mainfrom
ayaangazali:fix/media-max-mb-schema-parity
Aug 28, 2026
Merged

steipete merged 6 commits into
openclaw:mainfrom
ayaangazali:fix/media-max-mb-schema-parity

Conversation

@ayaangazali

@ayaangazali ayaangazali commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Several bundled channels reject the documented mediaMaxMb setting, and merely accepting it does not ensure the native media sender enforces it. The original PR identified the schema gap. Maintainer follow-through found unchecked byte consumers, account-resolution mismatches, false media-delivery acknowledgements in QA Channel, and stale channel policy after a global media-limit reload.

Why This Change Was Made

The repair follows actual byte ownership. It enables the existing documented root/account setting for ClickClack, Mattermost, QA Channel, SMS, Tlon, and Zalo Personal, and passes the resolved cap into their native byte loaders. Buzz and Twitch do not gain ineffective media settings or new media capabilities. Transport-specific ceilings remain intact.

Account lookup uses the canonical normalized account resolver, including existing iMessage and Signal callbacks. Zalo's native credential-profile selection remains separate from an authoritative routed account; unrelated account caps cannot leak into profile tools. The existing pure resolver is exported through the existing focused account-helpers SDK entrypoint; the shipped older export stays available.

QA Channel now acknowledges media only after durable attachment publication. Existing caption/tool-trace ownership suppresses identical follow-through text without losing new attachments or genuinely different tool traces. Preview updates, deletion, and durable delivery share the existing async lock: a partial callback cannot edit a preview while its deletion is in flight, and one failed operation cannot poison later delivery. Remote batches preload all attachments before publication; shared local reply preparation keeps its established valid-file-plus-warning behavior. Mattermost cannot send an unchecked original URL after a bounded upload fails, while Tlon retains its existing fallback only after a successful bounded download.

The live tests exposed a second caption defect in the shared reply owner: with block streaming off, a suppressed text callback was nevertheless marked delivered before the later media block. The existing option resolver now chooses the message boundary in that mode, preserving the caption on the attachment. Enabled block modes and explicit per-turn precedence are unchanged. The producer repair removes four net production lines; no channel-specific workaround or new state is needed.

Changing the global fallback refreshes registered channel runtimes through the existing reload planner. Contributed plugin rules keep precedence, and automatic reload/rollback preserves manually stopped accounts. Explicit account starts still work. No new dependency, storage schema, protocol, SDK subpath, or parallel reload mechanism is introduced.

User Impact

Configured media limits are accepted where bytes are consumed and enforced at root, normalized account, and global fallback scope. Oversized media does not bypass the cap through a raw URL or stale runtime. Valid media retains its original bytes and caption, inbound failures are recorded as unavailable attachments, and later valid messages remain usable.

Thanks to Ayaan Gazali (@ayaangazali) for the original schema work; contributor credit is preserved in the maintainer rewrite.

Evidence

Final publication head: 9ef6fa11f222827028571ea49a9e1d4ae486a0a7. Exact-head hosted CI completed successfully, including the required aggregate gate; no checks remain pending. The source/build/live evidence below is tied to a51d7e0; the only later change is the two-file test-allocation repair described at the end. Historical pending-CI wording below is superseded by this final status.

Pre-fix failures were captured for native byte enforcement, account lookup, inbound staging, unchecked fallback URLs, non-final media false acknowledgements, identical caption follow-through, global-limit hot reload, and manual-stop preservation. The repairs use the existing persistence, reload, and durable-delivery owners rather than weaker assertions or larger timeouts.

The initial integrated candidate passed independent whole-effect Codex review across two complete chunks and the full changed-file gate. The changed-test run passed 560 tests in 11 files before a Tlon timeout cascade. Inspection of installed Vitest 4.1.11 showed that expired async test bodies could resume after teardown, install one-shot mocks, and start monitors in later cases. The fixture now checks the native test-context cancellation signal immediately after the same timed import, binds monitor cancellation to it, and resets the affected mock queues. It does not move the import, increase its deadline, or weaken assertions. The corrected three-file Tlon group passes all 35 tests; all remaining plugin tests pass too. Final combined coverage is 712 tests across 23 files. The final test-delta check passed, and a fresh whole-effect Codex review is clean across both complete chunks.

The final canonical SDK comparison from main 9a38b5ec8f6025dd52f89ab040d8a3413a473dd7 to a51d7e05ecb76540a5f48cc8ff0c3d186af8edb4 reports exactly one addition: the existing resolveChannelMediaMaxBytes function on existing account-helpers, with no removed or changed exports and no new entrypoint (acknowledgement digest 35246b79). The final full OPENCLAW_BUILD_PRIVATE_QA=1 pnpm build passed, including SDK exports and Control UI budgets. On the earlier byte-owner candidate, all six affected channel entrypoint imports completed under default profiler deadlines: QA Channel128.8MB, ClickClack539.8MB, Mattermost134.2MB, SMS150.9MB, Tlon128.7MB, Zalo Personal138.5MB peak RSS; this is not a before/after memory improvement claim.

Source-blind compiled-Gateway validation of the initial candidate found a real streamed-caption failure at 512/1024 bytes: a detached partial edited a deleted preview and poisoned final delivery. That failed run is retained. Two deferred-deletion tests reproduced both identical and changed-partial races before repair. The queue correction passes 38 focused tests and independent review. The test compiler rejected direct Promise.withResolvers; tests use the existing SDK deferred helper without changing runtime behavior, assertions or compiler settings. A second frozen run at 8533dd4c38257b07f72ae6a21fecb4a991dde110 passed 16/18 product cases and 18/18 recovery barriers but still failed both strict caption cases: exact media arrived with an empty caption. That failure was not relabeled; it led to the shared producer repair above. Three additional real resolver → subscriber → delivery tests failed before that repair; all 22 directive cases now pass, including enabled/disabled modes, per-turn precedence, partial previews and captionless media.

At a51d7e05ecb76540a5f48cc8ff0c3d186af8edb4, production LOC is +363/-219 (net +144); tests and test support +1540/-141; documentation +58/-3; generated +22/-22; tooling +4/-2; assertion baseline -1. Production growth implements six real byte consumers, the native profile/account boundary, and the missing reload dependency. Existing canonical resolvers and durable-delivery paths absorb nearby fixes; generated changes come only from canonical regeneration and preserve current main's other fields.

The live contract exercises the actual isolated compiled Gateway and HTTP QA bus with a controlled model provider. It requests exact bytes, cap boundaries, mixed local versus remote batches, normalized named accounts, inbound notices, recovery, CLI-driven global fallback changes, manual stop/start, restart, and streamed caption/tool traces. It is not authenticated external-channel or real-model proof. Final source-blind validation at a51d7e05ecb76540a5f48cc8ff0c3d186af8edb4 passed all 18 assigned product probes and 18 recovery barriers. Both formerly failing streamed 512/1024-byte cases now publish the exact attachment and caption in the same durable message; the later repeated caption carries an actual new read-tool trace and correctly stays visible. Ordinary and captionless media controls also pass. Removing the channel cap activates the 4096-byte fallback; tightening it through the real CLI to 1024 rejects remote 2881-byte and inbound 3072-byte attachments without an explicit Gateway restart. A manually stopped account remains stopped; after an explicit start, its separate 2048-byte override accepts remote 1536-byte media and rejects 2111 bytes. After an explicit Gateway restart, oversized rejection and valid 512-byte outbound/inbound controls still pass. All six remote preflights returned HTTP 200 with exact fixture bytes. Recorded diagnostics distinguish size rejection from network failure.

The final fixture terminated successfully: Gateway PID absent, all three listeners closed, cleanup errors empty, and the frozen 12,481-file/271,029,144-byte runtime graph unchanged (SHA-256 21916eeac9f36b6289dba30e77e38f93d847b5a3984d8f871ebdce70a2a1a629). Same-trace caption repetition and an exact 3072-byte remote fixture remain unexercised live; remote 2881-byte evidence is not claimed as 3072. The distinct-trace caption case and limit-specific local diagnostic are directly observed. The preserved previous failures remain failures, not overwritten by this passing run.

The final refresh integrates main 9a38b5ec8f6025dd52f89ab040d8a3413a473dd7, including the auth-owner repair in #131519. Two actual conflicts were generated config baselines only; all production/test patches replayed identically. Canonical regeneration and an AST-based semantic audit preserve every other channel metadata field from main and add only the 12 intended positive-number root/account media-limit entries. Generated counts are core 2359 / channel 3674 / plugin 4034. The final changed gate passes, normal whole-branch independent review is clean across two complete chunks, and 540 tests across 7 files pass (458 Gateway, 22 directive, 60 QA). Earlier integration 553/14 and byte-owner 712/23 runs remain separate evidence, not summed as unique coverage. Exact-head hosted CI is pending; this is not yet a completed landing.

Latest ClawSweeper review read: its QA loader enforcement finding is addressed at the native loader before bus publication, with root/account/fallback rejection and recovery proof; its request for a successful complete build is also addressed. The broader byte-owner and caption repairs merit a fresh re-review after publication. Caption provenance: 35ae782c84c23ae81686baf03e557c5f6c79036b (Peter Steinberger,2026-05-30) introduced the structured-media message-end suppression involved in the reproduced loss; no associated PR is guessed.

Named follow-up: concurrent test/check processes can race the same Vitest filesystem cache lifetime. The full final gate and tests run serially; the original failed parallel attempt is retained. The separately fixed full-iMessage registry retention issue landed in #130518 and is included in this baseline.

The first hosted run at a51d7e0 caught a genuine test-allocation limit: plugins-platform had 721 roots against its unchanged 720-root ceiling. The follow-up moves the entire 39-root media group into the existing messaging shard (682 and 526 roots respectively). The actual guard failed before and passed after; both affected type-check shards, eight existing partition tests, the changed gate, and a fresh normal independent review pass. No tests were removed, no limit was raised, and exact-once canonical coverage is preserved. This follow-up changes only two test configuration files: the live-tested production source and dependencies remain identical to a51d7e0. A fresh hosted run is required on the resulting head before landing.

Copilot AI review requested due to automatic review settings August 2, 2026 19:50

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 docs Improvements or additions to documentation channel: mattermost Channel integration: mattermost channel: nostr Channel integration: nostr channel: tlon Channel integration: tlon channel: zalouser Channel integration: zalouser channel: twitch Channel integration: twitch channel: qa-channel Channel integration: qa-channel channel: sms Channel integration: sms channel: raft Channel integration: Raft channel: reef Channel integration: reef channel: buzz size: S labels Aug 2, 2026
@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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Aug 2, 2026
@clawsweeper

clawsweeper Bot commented Aug 2, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed August 28, 2026, 12:34 AM ET / 04:34 UTC.

ClawSweeper review

What this changes

The branch admits mediaMaxMb in seven bundled channel schemas, aligns their public types and generated config metadata, and adds a schema-parity contract test.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⛔ Blocked until stronger real behavior proof is added - 6 items remain

Keep open: the exact head still makes QA Channel’s documented cap valid without enforcing it before attachment delivery, and an active integration comment already identifies that owner-boundary repair.

Priority: P1
Reviewed head: 8298288e55e9e996c73db1d59d57b8d2b487739a

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) PR readiness rating was derived from proof quality, review findings, security review, and reviewer confidence.
Proof confidence 🦪 silver shellfish (2/6) Needs stronger real behavior proof before merge: ClawSweeper live verification failed on the reviewed terminal surface. 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 🧂 unranked krab (1/6) 1 actionable review finding remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs stronger real behavior proof before merge: ClawSweeper live verification failed on the reviewed terminal surface. 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 7 items Introduced reachable setting: The PR introduces the QA Channel mediaMaxMb field, making a previously rejected operator setting valid.
QA sender omits the configured limit: The direct QA media owner loads every attachment without maxBytes, base64-encodes it, and sends it to QA Bus; no configured cap reaches this path.
Loader contract: The public outbound-media loader accepts maxBytes specifically as the maximum payload size before rejection and forwards it to the web-media policy.
Findings 1 actionable finding [P1] Enforce QA’s configured cap before loading attachments
Security None None.

Live Verification

Command: pnpm build && pnpm openclaw --help

Result: FAIL (failed) — step 1 expect_output Usage:: expected terminal output was not visible within 30 seconds: "Usage:"

[failure]
expected terminal output was not visible within 30 seconds: "Usage:"

[command 1 combined output]
$ node --import ./scripts/tsx.mjs scripts/build-all.mts
[build-all] plugins:assets:build
$ node --import ./scripts/tsx.mjs scripts/bundled-plugin-assets.mts --phase build
[canvas] build: node scripts/bundle-a2ui.mjs
[log] ‹DIR›/a2ui.bundle.js  chunk │ size: 399.96 kB
[log] ‹DIR›/a2ui-v0.9.bundle.js  chunk │ size: 615.66 kB
[log]
[success] rolldown v1.2.0 Finished in 110.40 ms
[diffs] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts curated
[diffs-language-pack] build: node --import tsx ../../scripts/build-diffs-viewer-runtime.mts full
[discord] build: node --import tsx ../../scripts/build-discord-activity-sdk.mts
[build-all] plugins:assets:build done in 2.21s
[build-all] tsdown-ai
[PLUGIN_TIMINGS] Your build spent significant time in plugins. Here is a breakdown:
  - tsdown:deps (47%)
  - rolldown-plugin-dts:generate (22%)
  - rolldown-plugin-dts:fake-js (21%)
See https://rolldown.rs/reference/InputOptions.checks#plugintimings for more details.

[tsdown-build] invocation 1/1 finished in 4.9s
[build-all] tsdown-ai done in 5.52s
[build-all] tsdown-packages

Assertions:

  • FAIL expect_output: Usage:

How this fits together

Channel plugins validate operator configuration before outbound media is loaded and handed to a channel transport. The QA Channel has its own media sender, which encodes loaded attachments for QA Bus delivery.

flowchart LR
A[Operator QA media limit] --> B[QA configuration schema]
B --> C[QA media sender]
C --> D[Shared media loader]
D --> E[QA Bus attachment]
C --> F[Size-limit decision]
Loading

Before merge

  • Add real behavior proof - Needs stronger real behavior proof before merge: ClawSweeper live verification failed on the reviewed terminal surface. 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.
  • Enforce QA’s configured cap before loading attachments (P1) - This hunk makes the QA cap valid, but QA loads media without maxBytes before base64 encoding and QA Bus delivery. The shared loader supports that limit, so a configured cap is silently ignored on QA’s direct media path; resolve and pass the effective channel/account cap here, then prove rejection before the bus send.
  • Resolve merge risk (P1) - Merging this head would let QA operators set a valid per-channel or per-account cap that the direct QA sender ignores, allowing oversized attachments to be loaded and delivered contrary to the documented setting.
  • Complete next step (P2) - A narrow owner-boundary repair and validation path are known; preserve the contributor stack while completing the active QA enforcement integration.
  • Improve patch quality - Add after-fix proof from a real setup, such as a short recording, terminal output, linked artifact, or redacted logs.
  • Improve patch quality - Address the highest-priority review finding and re-run the changed-surface validation.

Findings

  • [P1] Enforce QA’s configured cap before loading attachments — extensions/qa-channel/src/config-schema.ts:30
Agent review details

Security

None.

PR surface

Source +22, Tests +105, Generated 0. Total +127 across 19 files.

View PR surface stats
Area Files Added Removed Net
Source 15 23 1 +22
Tests 1 105 0 +105
Docs 0 0 0 0
Config 0 0 0 0
Generated 3 26 26 0
Other 0 0 0 0
Total 19 154 27 +127

Review metrics

Metric Value Why it matters
Media-limit configuration surface 8 schema fields added across 7 bundled plugins; 7 public types aligned Each newly admitted setting must be traced to a sender that actually honors it.
Production versus test delta production +23/-1 (net +22), tests +105, generated +26/-26 The added configuration contract is only justified once QA’s owner-boundary enforcement is included.

Stored data model

Persistent data-model change detected: unknown-data-model-change: src/config/bundled-channel-config-metadata.generated.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Complete QA sender enforcement (recommended)
    Pass the resolved QA channel/account limit into the media loader and add a boundary regression showing rejection before the QA Bus send.
  2. Pause schema admission
    Do not merge the QA schema field if the sender cannot honor the documented cap in this PR.

Technical review

Best possible solution:

Resolve QA’s root/account cap at its outbound owner, pass it to the shared loader without exceeding any transport ceiling, and prove oversized attachments are rejected before QA Bus delivery.

Do we have a high-confidence way to reproduce the issue?

Yes—source reproducible with high confidence: configure a small QA cap and send an oversized media URL through QA’s direct delivery path; the current loader receives no maxBytes. This read-only review did not execute that runtime scenario.

Is this the best way to solve the issue?

No: schema admission alone is not the best fix because QA’s sender never consumes the admitted value; enforcement belongs at the QA outbound loader before QA Bus delivery.

Full review comments:

  • [P1] Enforce QA’s configured cap before loading attachments — extensions/qa-channel/src/config-schema.ts:30
    This hunk makes the QA cap valid, but QA loads media without maxBytes before base64 encoding and QA Bus delivery. The shared loader supports that limit, so a configured cap is silently ignored on QA’s direct media path; resolve and pass the effective channel/account cap here, then prove rejection before the bus send.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.99

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 629a47e3cc20.

Labels

Label changes:

  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦪 silver shellfish and patch quality is 🧂 unranked krab.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🧂 unranked krab, so this older rating label is no longer current.

Label justifications:

  • P1: A documented channel-media control becomes valid but silently fails to constrain QA attachment delivery.
  • merge-risk: 🚨 compatibility: Existing documented root and account configuration becomes accepted for QA without delivering its promised behavior.
  • merge-risk: 🚨 message-delivery: An oversized QA attachment can still be loaded and sent despite the configured cap.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🦪 silver shellfish and patch quality is 🧂 unranked krab.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs stronger real behavior proof before merge: ClawSweeper live verification failed on the reviewed terminal surface. 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

Acceptance criteria:

  • [P1] node scripts/run-vitest.mjs extensions/qa-channel/src/inbound.test.ts.
  • [P1] node scripts/run-vitest.mjs src/plugins/contracts/channel-media-max-mb.contract.test.ts.
  • [P1] node --import tsx scripts/generate-bundled-channel-config-metadata.ts --check.
  • [P1] node --import tsx scripts/generate-config-doc-baseline.ts --check.
  • [P1] Run an isolated Gateway/QA-bus scenario proving an oversized attachment is rejected before QA Bus delivery.

What I checked:

Likely related people:

  • Josh Avant: Current-media loader and QA Bus batch-delivery lines blame to the latest relevant QA implementation commit. (role: current QA outbound owner; confidence: high; commits: 14bc69814131; files: extensions/qa-channel/src/outbound.ts, extensions/qa-channel/src/inbound.ts)
  • steipete: Their PR comment explicitly says they are integrating the QA enforcement repair and final exact-head validation. (role: active integration owner; confidence: high; files: extensions/qa-channel/src/outbound.ts, extensions/qa-channel/src/channel.ts)

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 (29 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-26T21:15:58.484Z sha c48f38d9ca8701d12f349cd61dc5a2d7ad4f0330 :: needs real behavior proof before merge. :: [P1] Enforce the cap before QA-bus media delivery
  • reviewed 2026-08-26T21:49:55.372Z sha 3db8ef1a92f9ccb1ab0b148cab7e4d89f15d7d75 :: needs real behavior proof before merge. :: [P1] Enforce the QA media cap before delivery
  • reviewed 2026-08-26T23:53:30.615Z sha 4c3aad4e1ac09a1f0d59d70b2e1e356d4683781e :: needs real behavior proof before merge. :: [P1] Enforce QA mediaMaxMb before delivery
  • reviewed 2026-08-27T01:47:42.617Z sha c1e8543cdc8c990ad557184edc39303aa3020b6d :: needs real behavior proof before merge. :: [P1] Enforce the configured cap before QA media delivery
  • reviewed 2026-08-27T03:51:04.822Z sha 628516114e158889edae275c90eb390e3c7d7d45 :: needs real behavior proof before merge. :: [P1] Wire QA mediaMaxMb into the attachment loader
  • reviewed 2026-08-27T05:55:50.657Z sha 09ff44a7fef18d3a09640615a0b9dea65876cd3b :: needs real behavior proof before merge. :: [P1] Enforce the QA cap before attachment delivery
  • reviewed 2026-08-27T20:06:59.638Z sha f490e9add261db9e890b0c8dd86792b403fdbbf9 :: needs real behavior proof before merge. :: [P1] Apply QA’s configured cap before loading media
  • reviewed 2026-08-28T00:24:16.584Z sha e98c05ca45c73eb807a67cef5f3efb969961583c :: needs real behavior proof before merge. :: [P1] Enforce QA's admitted cap before loading attachments

@ayaangazali

Copy link
Copy Markdown
Contributor Author

Real behavior proof added to the PR body, taken from from-scratch builds on both sides so a stale dist cannot flatter the result.

Before, clean build of main (b7f9cd0a016), root and account forms both refused:

- channels.mattermost: invalid config: must not have additional properties: "mediaMaxMb"
- channels.mattermost.accounts.ops: invalid config: must not have additional properties: "mediaMaxMb"

After, clean build of this branch:

  "mediaMaxMb": 25,
    "ops": {
      "baseUrl": "https://ops.example.org",
      "mediaMaxMb": 10,

Worth stating explicitly since it differs from the account-scope finding you raised on #118152: both forms here have a real resolver contract. resolveChannelAccountMediaMaxMb (src/media/configured-max-bytes.ts:27-51) reads the account value first and falls back to the channel value, so accepting the account form is not an empty promise in this case.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@ayaangazali
ayaangazali force-pushed the fix/media-max-mb-schema-parity branch from 97b0a1e to 31f7ba2 Compare August 3, 2026 16:13
@ayaangazali

Copy link
Copy Markdown
Contributor Author

Addressed in 31f7ba24805. The branch was 497 commits behind, which is why the baselines were stale.

Rebased onto current main (df0cf7604be) and regenerated both artifacts with the repo generators rather than resolving them by hand. The three conflicts were all generated files, so I took main's copies and re-ran:

  • scripts/generate-bundled-channel-config-metadata.ts --write
  • scripts/generate-config-doc-baseline.ts --write

Both gates are clean on the new head, and the eleven schema edits plus the contract test survived the rebase intact:

$ node --import tsx scripts/generate-bundled-channel-config-metadata.ts --check
(clean)
$ node --import tsx scripts/generate-config-doc-baseline.ts --check
OK docs/.generated/config-baseline.sha256 and docs/.generated/config-baseline.counts.json

$ node scripts/run-vitest.mjs src/plugins/contracts/channel-media-max-mb.contract.test.ts
Tests  55 passed (55)

$ git diff --check
(clean)

The clean-build before/after transcripts already in the PR body still describe this change; the rebase moved the base and the generated snapshots, not the behavior.

@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. and removed 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. labels Aug 3, 2026
@ayaangazali

Copy link
Copy Markdown
Contributor Author

Disclosure that affects how the channel list on this PR should be read, found while gathering clean-build proof for a sibling PR.

I have been using the generated channel metadata (src/config/bundled-channel-config-metadata.generated.ts, closed schema plus key absent) as my oracle for which channels reject a key. For two channels that oracle over-reports, because their generated JSON Schema says additionalProperties: false while their live zod schema is permissive:

matrix  live runtime.safeParse({ totallyBogusKey: 1 })  -> accepted
tlon    live runtime.safeParse({ totallyBogusKey: 1 })  -> accepted
buzz / raft                                              -> correctly strict

Confirmed end to end on a from-scratch build of main: channels.matrix.dmHistoryLimit, a key matrix's generated schema marks absent-and-closed, is accepted by the CLI. So in a source checkout these two channels were not actually refusing the documented key, and for them the "rejects the key" framing in my PR body is imprecise.

What I think this does and does not change:

  • The schema additions themselves stay correct and harmless for these channels: declaring the key makes it explicit and typed rather than silently passing through an open object, and it matches what every channel on the shared account shape already publishes.
  • It does matter for the packaged path, where validation falls back to the generated metadata, so the same config can behave differently between a source checkout and a dist-only install. That divergence looks like its own defect, and I am not folding a fix for it into this PR.
  • The other channels in this PR were verified strict, so the finding is scoped to the ones named above.

I would rather you hear this from me than discover it in review. Happy to drop the affected channel from the list, or to keep it with the framing corrected to "declares the key explicitly" instead of "rejects it", whichever you prefer.

@ayaangazali

Copy link
Copy Markdown
Contributor Author

Good catch, and it was a real hole. Fixed in this push.

You are right that mediaChannels was selected from the very field it was meant to protect. If a supported channel dropped mediaMaxMb, it fell out of the table and both non-vacuity checks still passed, so the contract could not fail for the regression it existed to catch.

The set is now anchored to media capability instead:

const NON_MEDIA_CHANNELS = new Set(["buzz", "nostr", "raft", "reef"]);
const mediaChannels = GENERATED_BUNDLED_CHANNEL_CONFIG_METADATA
  .map((entry) => entry.channelId)
  .filter((channelId) => !NON_MEDIA_CHANNELS.has(channelId));

I checked that split against delivery rather than schema before pinning it: Nostr and Reef declare media: false, Buzz and Raft ship no sendMedia, and the other 23 bundled channels all declare media: true. Every media-capable channel is asserted at root and at any closed account scope, so nothing can quietly leave the table.

Proof both directions now fail:

# tlon (supported) drops mediaMaxMb
× tlon accepts channels.<id>.mediaMaxMb
× tlon accepts channels.<id>.accounts.<account>.mediaMaxMb
  Tests  2 failed | 47 passed (49)

# nostr (cannot deliver media) re-adds it
× nostr does not offer a cap it cannot apply
  Tests  1 failed | 48 passed (49)

# as shipped
  Tests  49 passed (49)

The non-media assertion also requires the root schema to be closed first, since rejectsKey answers false for an open schema and the rejection would otherwise prove nothing. Same reason the account-scope check skips Matrix, whose account schema is z.unknown() on purpose.

Tradeoff worth naming: the four excluded channels are now a literal in the test. I preferred that over deriving from the field, since the derivation is what made the contract self-referential, and capability is not exposed in the generated config metadata today. If you would rather have this driven by exported capability metadata, that is a larger change and I am happy to do it separately.

Validation: channel-media-max-mb.contract 49 passed, schema.help.quality 24, config-cli 187, both generator --check gates clean.

AI-assisted.

@ayaangazali

Copy link
Copy Markdown
Contributor Author

Rebased onto current main; main had moved 185 commits ahead.

On the red check-lint: that one is the fork-runner limit rather than a lint problem. The job log shows Image: ubuntu-24.04, [oxlint] FAILED (exit 143) and The operation was canceled, with zero error eslint(...) or error typescript(...) lines anywhere in it. exit 143 is SIGTERM, so oxlint was killed mid-run rather than reporting a violation. The rebase re-runs that lane on the new head, which has resolved the same signature on my other PRs.

Validation on the new head: config-cli and schema.help.quality pass, both generator --check gates clean, merges clean with main.

AI-assisted.

@ayaangazali

Copy link
Copy Markdown
Contributor Author

Rebased onto current main (46e44baf460). This branch had picked up the recurring conflict in the generated config baseline (docs/.generated/config-baseline.counts.json and config-baseline.sha256); it is now 0 commits behind and merge-clean.

The baseline was not hand-merged. I reset both generated files to main and re-ran both generators, so the artifacts match what CI regenerates:

node --import tsx scripts/generate-config-doc-baseline.ts --check                  clean
node --import tsx scripts/generate-bundled-channel-config-metadata.ts --check      clean

Local proof at head f14657e3fb7:

src/plugins/contracts + src/config/schema.help.quality.test.ts   43 files, 1085 passed
src/cli/config-cli.test.ts                                      190 passed

On the red marks: check-lint, check-lint-core-5 and check-docs are failing here, and I do not believe any of them are this branch. All three die during pnpm install before their actual check step runs (::error::pnpm install failed, then Process completed with exit code 1), with no rule violations or docs drift reported. check-lint and check-lint-core-5 are also currently red on main itself (for example 44b41d5686d). This branch touches no package.json, pnpm-lock.yaml or pnpm-workspace.yaml.

I also think I made that worse: I pushed nine rebases within about a minute, so nine fork CI runs hit dependency install at once. That was my mistake in batching, not a change in the code. Happy to re-push to re-trigger if you would rather see a clean run.

AI-assisted.

@ayaangazali

Copy link
Copy Markdown
Contributor Author

Rebased onto current main, 0 behind and merge-clean. Both generated-artifact gates clean, contracts 1085 and config-cli 191 green locally.

The one red, checks-node-compact-small-11, is the gateway harness timeout again:

FAIL gateway-server src/gateway/server.chat.gateway-server-chat.test.ts
AssertionError: expected +0 to be 1

This is the third of my PRs to hit it today, after #119356 and #117287, all on unrelated diffs. The cause I traced on #119356 is the WebSocket wait in src/gateway/test-helpers.server.ts rejecting with a bare Error: timeout on a fixed timeoutMs = 10_000, which a loaded hosted shard can exceed. The count then reads +0 because the awaited message never arrived.

This branch changes channel mediaMaxMb schemas and one contract test. It touches nothing under src/gateway.

I have not raised that timeout, since larger timeouts are one of the things AGENTS.md names as masking a root cause, and it is shared by every gateway test. Flagging the pattern rather than patching around it.

AI-assisted.

@ayaangazali

Copy link
Copy Markdown
Contributor Author

Owner-boundary evidence added, as asked. Rebased to 0acf26ab5e1, 0 behind.

You were right that the earlier transcript only proved schema acceptance. The missing half is whether a configured cap actually reaches the send path, so here is the whole chain.

1. Whether the cap can exist at all. Same probe over the generated schema oracle, only bundled-channel-config-metadata.generated.ts swapped between main and this branch:

main                          this branch
tlon        false             tlon        true
clickclack  false             clickclack  true
sms         false             sms         true
qa-channel  false             qa-channel  true
zalouser    false             zalouser    true
mattermost  false             mattermost  true
twitch      true              twitch      true

Six of the seven refuse mediaMaxMb on main, so an operator who sets it gets a config-load failure and the cap never exists. Twitch already accepted it, which is why it is unchanged here.

2. What the accepted value does at the send boundary. Driving the real resolver the outbound adapter uses, createScopedChannelMediaMaxBytesResolver from src/channels/plugins/outbound/direct-text-media.ts:

channels.tlon.mediaMaxMb = 1              -> maxBytes handed to sender: 1048576
channels.tlon.accounts.ops.mediaMaxMb = 2 -> maxBytes handed to sender: 2097152
a 3145728-byte attachment is over the root cap: true
...and over the ops account cap: true

That is the value createDirectTextMediaOutbound passes into buildOptions({ ..., maxBytes }) before calling the channel's send function, and the account override wins over the channel root.

So the two halves join up: on main the cap is unreachable because config load refuses the key; with this change it is accepted, converted to bytes, and handed to the sender, where a 3 MB attachment exceeds a 1 MB cap.

One correction to my own method while building this. My first probe printed nothing at all and I nearly read that as "no schema". The export is GENERATED_BUNDLED_CHANNEL_CONFIG_METADATA and it is an array keyed by channelId, not a record. The harness was wrong, not the metadata.

Validation at 0acf26ab5e1:

  • both generator --check gates: exit 0
  • src/plugins/contracts: 1090 passed, 43 files
  • src/config/schema.help.quality.test.ts: 24 passed
  • src/cli/config-cli.test.ts: 198 passed

Honest limit: this is the resolver and the schema oracle, not a live channel send. Enforcement of maxBytes past that point lives in each channel's own send function, which this PR does not touch.

@ayaangazali

Copy link
Copy Markdown
Contributor Author

Rebased onto current main.

Worth flagging for review: #129710 landed historyLimit on MattermostAccountSchemaBase, on the same line this branch adds mediaMaxMb, so the rebase had a real conflict there rather than the usual generated-artifact one. I kept both keys rather than taking either side, so the merged historyLimit is preserved intact:

historyLimit: z.number().int().min(0).optional(),
mediaMaxMb: z.number().positive().optional(),

Local checks at the new head: channel-media-max-mb.contract.test.ts 49/49, src/plugins/contracts 1074/1074, mattermost lane 777/778, and both generator gates (generate-bundled-channel-config-metadata --check, generate-config-doc-baseline --check) clean.

The one mattermost failure is model-picker.test.ts > resolves current and parent model overrides from targeted session entries. It fails the same way on pristine upstream/main with this branch checked out elsewhere, so it is pre-existing and not from this change.

@ayaangazali

Copy link
Copy Markdown
Contributor Author

checks-fast-contracts-plugins-b was mine. Fixed in 3db8ef1a92f.

The failure was my own contract test: channel mediaMaxMb contract > a2a accepts channels.<id>.mediaMaxMb, expected true to be false.

Cause: A2A is a new channel plugin, landed in #130008 (ad1e946c7ad), and it is not yet present in the committed src/config/bundled-channel-config-metadata.generated.ts on main. Rebasing this branch regenerates that file, so A2A appears in the metadata here first. My contract derives its expected set from every metadata entry minus an explicit non-media list, precisely so a media-capable channel cannot silently drop the key, and A2A landed in that set by default.

A2A cannot deliver media. extensions/a2a/src/channel.ts:24 declares durableFinal: { capabilities: { text: true } } and its send block exposes only text, with no sendMedia anywhere in the plugin. That is the same criterion already applied to Buzz and Raft, so I added it to NON_MEDIA_CHANNELS and extended the existing justification comment rather than loosening the assertion.

Verified: the contract file is 50/50 and the full src/plugins/contracts lane is 1113/1113 at the new head. I also checked the sibling parity branches for the same break, since they all regenerate the same metadata: responsePrefix 1088/1088, healthMonitor 1106/1106, contextVisibility 1067/1067, irc mentionPatterns 1063/1063. Only this contract derives its set from all channels, so only this one was affected.

Worth flagging separately: because #130008 added the plugin without regenerating the bundled channel metadata, the first PR to regenerate it carries A2A's entries into its diff. That is why the generated file in this PR moves more than the mediaMaxMb change alone would explain.

@steipete

Copy link
Copy Markdown
Contributor

Thanks @ayaangazali. I’m working on maintainer improvements to this PR so the accepted limits reach the native media loaders, preserve each transport’s existing ceilings, and reject oversized attachments before upload or delivery. I’m also adding real-flow regression coverage and running an isolated Gateway/QA Channel check. I’ve seen your latest updates and will preserve your contributor stack when integrating the improvements; no need to open a replacement PR.

@ayaangazali

Copy link
Copy Markdown
Contributor Author

Correction to my previous comment. Two claims in it were wrong, and both were unfair to #130008.

I said A2A was "not yet present in the committed src/config/bundled-channel-config-metadata.generated.ts on main", and that the first PR to regenerate carries A2A's entries into its diff. Both are false. #130008 regenerated the metadata itself, and "channelId":"a2a" is present on main in that generated file. My branch and main each contain exactly one A2A entry, so this PR adds nothing there.

The error was mine and it was a grep: I searched for channelId: "a2a" in TypeScript object spacing, but the metadata is a JSON string literal, so the actual text is "channelId":"a2a". The zero-match result led me to the wrong conclusion.

What actually happened is simpler. A2A joined the bundled metadata in #130008. Once this branch rebased past that commit, my contract picked A2A up, because the contract derives its expected set from every metadata entry minus an explicit non-media list. A2A landed in that set by default and correctly failed, since it does not offer the cap.

The fix in 3db8ef1a92f is unchanged and still right: A2A cannot deliver media (extensions/a2a/src/channel.ts:24 declares durableFinal: { capabilities: { text: true } }, the send block exposes only text, and there is no sendMedia in the plugin), so it belongs in NON_MEDIA_CHANNELS next to Buzz and Raft. Contract file 50/50, full src/plugins/contracts lane 1113/1113.

Sorry for the noise on the generated-metadata point.

@steipete

Copy link
Copy Markdown
Contributor

Thanks for keeping this branch current, @ayaangazali. I have finished the maintainer enforcement improvements and their review, including actual Gateway/QA-bus attachment and configuration-reload testing. I am integrating your latest rebased head while preserving your commits and credit, then running the final exact-head checks before updating this PR.

Could you please avoid further rebases or force-pushes on this branch until that integration is finished? No action is needed on the implementation; I will post the final change summary and proof here.

@ayaangazali

Copy link
Copy Markdown
Contributor Author

checks-node-changed-extensions-config-38 was a Control UI startup budget violation, not a test failure, and after measuring it locally I do not think it needs a code change. Rebased for a fresh run instead.

The job log has no failing test. The build succeeds (✓ built in 4.69s, 770 sidecars verified) and then the post-build budget check reports:

violations:
  - startup JS gzip: 335.4 KiB exceeds 335.4 KiB (343443 B vs 343442 B)

One byte over, against a limit of baseline 342930 plus 512 tolerance.

The premise was plausible. This PR adds mediaMaxMb to several channel schemas, that flows into src/config/bundled-channel-config-metadata.generated.ts, and that metadata ships to the Control UI config form, so the change does cost startup bytes. I was ready to raise the baseline through scripts/check-control-ui-performance.mts --update-baseline.

Building locally first said otherwise. At the rebased head 09ff44a7fef on current main:

startup JS gzip vs baseline: 343362 B (baseline 342930 B + tolerance 512 B, max committed baseline 358400 B)

That is 80 bytes under the limit, and the check exits 0 with no violations section. The CI number came from head 628516114e1 on an older main, so the 81 byte gap between the two measurements is build variance rather than anything this diff added.

Raising a committed performance budget to absorb an 81 byte measurement difference would be the wrong repair, so I have not touched config/control-ui-startup-budget-baseline.json. If a fresh run on the new head reports the violation again, that changes the picture and I will do the measured baseline bump with the reason written into the PR body.

New head 09ff44a7fef: contracts 1121/1121, both generator gates clean, UI startup budget passing locally.

steipete and others added 5 commits August 27, 2026 23:13
Resolve canonical account caps at native byte consumers, publish QA attachments durably, and refresh global media policy without resurrecting manually stopped accounts. Preserve existing local survivor warnings, remote batch atomicity, transport ceilings, and contributor schema work.

Co-authored-by: Ayaan Gazali <[email protected]>
Resolve disabled block delivery at message-end so suppressed text callbacks cannot strip the later attachment caption. Preserve enabled break modes and per-turn precedence using the existing boolean owner.
@steipete

Copy link
Copy Markdown
Contributor

The improved branch is now at a51d7e05ecb76540a5f48cc8ff0c3d186af8edb4, preserving Ayaan Gazali's contribution and credit. The native QA loader now enforces the cap before attachment publication; the same byte-owner audit repairs the affected sibling senders, account resolution, and global-limit reload. Both findings in the latest review—missing enforcement and incomplete real-behavior proof—are addressed.

Final isolated compiled-Gateway/HTTP QA-bus validation passed all 18 assigned probes and 18 recovery barriers. This includes exact 512/1024-byte streamed attachments with captions, captionless controls, global fallback and live tightening, inbound unavailable notices, manually stopped-account preservation, an independent named-account override, and post-restart controls. All six remote fixtures passed exact-byte HTTP 200 preflights. The Gateway process is gone, all three listeners are closed, and the runtime graph hash is unchanged. This is controlled-provider Gateway proof, not authenticated external-channel or real-model proof. Same-trace caption repetition and an exact 3072-byte remote fixture remain explicit live gaps; the distinct-trace repeated-caption case was directly verified.

The earlier live failures are retained in the PR's evidence narrative. They led to two additional owner fixes: serialize previews with durable delivery, and stop treating suppressed text callbacks as delivered captions when block streaming is off. The latter absorbs the fix into the existing option resolver with net four fewer production lines.

The final production build, changed gate, canonical generated-config checks, SDK API report and normal independent whole-branch Codex review pass. The final integration run passed 540 tests in seven files; earlier broader byte-owner coverage is recorded separately without double-counting. Exact-head hosted CI must still pass before native prepare/merge.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

Keep the existing 720-root ceiling and exact-once canonical coverage by moving media tests into the messaging shard. The plugin/platform shard reached 721 roots with the new media contract coverage; the new allocation is 682 and 526 roots. No runtime or test assertions change.
@steipete

steipete commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Final head: 9ef6fa11f222827028571ea49a9e1d4ae486a0a7. Exact-head CI 33149281077 completed successfully, including the required CI gate. There are no pending or failed product checks; the PR is mergeable. Proceeding through native prepare/merge.

The first hosted run found one real integration issue: 721 roots in the plugin/platform test-type shard, exceeding the existing 720-root ceiling. The fix moves all 39 media roots into the existing messaging shard, producing 682/526 roots while preserving exact-once coverage and the unchanged ceiling. The actual guard fails before and passes after. Both affected type-check shards, eight existing partition tests, the changed gate and fresh independent review pass. The first run's failure and later cancellation are preserved; they are not reported as green.

This last commit changes only two test-allocation JSON files. Production and dependencies are identical to live-tested a51d7e0: 18 assigned compiled-Gateway/QA-bus probes and 18 recoveries pass, including the formerly failing media-bearing captions, actual distinct tool traces, live global-limit reload, stopped-account preservation and post-restart controls. Process/listener cleanup and the unchanged runtime hash are verified. The PR body retains the two unexercised live subchecks and distinguishes controlled-provider evidence from authenticated external services.

Focused final commands, in addition to the broader runs recorded in the PR body:

OPENCLAW_BUILD_PRIVATE_QA=1 pnpm build
node scripts/run-vitest.mjs src/auto-reply/reply/get-reply-directive-aliases.test.ts extensions/qa-channel/src/inbound.test.ts extensions/qa-channel/src/outbound.test.ts extensions/qa-channel/src/channel.test.ts src/gateway/config-reload.test.ts src/gateway/server-reload-handlers.test.ts src/gateway/server-reload-channel-restart.test.ts
node --import ./scripts/tsx.mjs scripts/check-tsgo-core-boundary.mts
node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.plugins-platform.json
node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.messaging.json
node scripts/run-vitest.mjs test/scripts/tsgo-core-test-shards.test.ts
node scripts/check-changed.mjs -- test/tsconfig/tsconfig.core.test.plugins-platform.json test/tsconfig/tsconfig.core.test.messaging.json

The full build and 540-test integration run are at a51d7e0; the allocation checks are on the final test-only change. Whole-branch independent review and the final allocation review have no actionable findings. The latest published ClawSweeper requests for actual loader enforcement and completed build/Gateway proof are addressed; the requested fresh review may publish later. Contributor credit remains intact.

@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: imessage Channel integration: imessage channel: mattermost Channel integration: mattermost channel: msteams Channel integration: msteams channel: qa-channel Channel integration: qa-channel channel: signal Channel integration: signal channel: sms Channel integration: sms channel: tlon Channel integration: tlon channel: zalouser Channel integration: zalouser docs Improvements or additions to documentation extensions: clickclack extensions: qa-lab gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. scripts Repository scripts size: XL 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.

3 participants