Skip to content

fix(slack,mattermost): preserve thread participation expiry across restarts - #118630

Merged
steipete merged 1 commit into
mainfrom
codex/auto-qa-thread-participation-ttl-owner-c53
Aug 3, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/auto-qa-thread-participation-ttl-owner-c53

Conversation

@steipete

@steipete steipete commented Aug 3, 2026 •

Copy link
Copy Markdown
Contributor

What problem this solves

After a gateway restart, Mattermost and Slack restored a persisted thread-participation record using the restart time instead of the time when the bot actually last replied. A restart immediately before expiry therefore silently granted almost another seven days of Mattermost mention/onchar bypass or another 24 hours of Slack mention bypass.

Both defects are present in stable v2026.7.1 and v2026.7.2-beta.7. Mattermost explicitly documents that participation lasts seven days after the bot last replied and survives gateway restarts.

Why this change was made

Each plugin's participation owner now supplies its already-persisted repliedAt timestamp to the existing shared persistent-dedupe readTimestamp contract. This is the same contract already used by the Microsoft Teams sent-message owner; no shared SDK, storage schema, account policy, configuration, compatibility fallback, or dependency changes are needed.

SQLite already expires the durable row at the original deadline. Restoring process memory with the same original timestamp ensures its memory-first fast path cannot continue accepting an expired participation record after SQLite would reject it.

User impact

  • Mattermost thread participation expires seven days after the actual most recent visible reply, including across gateway restarts.
  • Slack thread participation expires 24 hours after the actual most recent reply, including across gateway restarts.
  • Existing account, channel, thread, enterprise-team, sender allowlist, control-command, and implicit-mention opt-out policies remain unchanged. Only mention/onchar activation timing changes.

Evidence

  • Exact candidate 85f74ae2ff237f268dd46cbed5fdf32012b8b7de; sole parent c53e594aae79690d7bc809157c904a5ecd745190; complete approved four-file binary diff SHA-256 622ca7b45cadc8cb05c04e9734a4d90432a2476d0bae30101359f0e0494d035c.
  • Tests first: the unchanged parent independently failed both actual-owner/shared-SQLite physical policy proofs and both committed focused owner regressions; Mattermost and Slack each incorrectly retained participation and implicit activation after the original deadline.
  • Exact candidate focused verification: 16/16 existing owner tests passed across both sequential plugin shards: 5 Mattermost and 11 Slack.
  • The complete unmodified exact-four changed-code gate, owner typechecks, formatting, lint, repository guards, and git diff --check passed on the immutable candidate.
  • Four independently authenticated hostile P0–P3 reviews reported zero findings across SDK/SQLite, Mattermost policy, Slack enterprise/account boundaries, and CI/release/current-main ownership.
  • One distinct genuine official Codex gpt-5.6-sol / high / P3 review reported zero findings and 0.96 confidence; checksum-authenticated native TruffleHog 3.96.0 passed.
  • Two additional fresh independent complete source-only reviews authenticated the final frozen external runner, physical-owner probe, lease freshness guards, RED/GREEN orchestration, exact focused routing, and complete changed-code gate; both reported zero P0–P3 findings before the root-owned remote execution passed.
  • Both defects and the existing shared timestamp contract are present in the stable and beta release trees; the unchanged Microsoft Teams sibling already consumes that contract correctly.
  • Latest root-refreshed canonical main and origin/main fe6fa891ea4ef3bb152d02df944a8def6518fdd1 leave all four changed files, all relevant scoped policies, all 31 authenticated owner/SDK/SQLite/docs/CI siblings, the frozen lockfile, and the Microsoft Teams sibling unchanged.
  • Production delta: +2 executable lines and +2 required owner-invariant comments; test delta +28 net lines.

Real behavior proof

Root-owned Blacksmith lease tbx_01kz3knq0ywxgdtje656h3mhz8 executed the hash-authenticated original-parent and immutable-candidate proofs against the actual production Slack and Mattermost plugin owners, canonical persistent-dedupe SDK, real plugin runtime, and real Kysely-backed shared state/openclaw.sqlite plugin-state database:

  1. Each actual plugin owner recorded its authoritative repliedAt; a real Kysely query authenticated the exact plugin/account/thread key and original SQLite expiry.
  2. The actual shared SQLite handle physically closed at one millisecond before expiry; owner process memory cleared, the database physically reopened, and the owner restored its still-live participation.
  3. At the exact original deadline, both unchanged parent owners incorrectly retained participation and both actual mention/ingress policy owners allowed the expired action: two physical RED proofs. Both committed focused owner regressions independently failed on the parent: two regression RED proofs.
  4. The exact candidate correctly expired participation for both plugins and both actual policy owners rejected expired implicit activation: two physical GREEN proofs. Account/channel/thread isolation, Slack enterprise-team isolation, Mattermost account-specific implicit-participation opt-out, and real Slack command ingress for allowed versus denied senders all remained intact; zero external network attempts.
  5. Both sequential focused owner shards passed: Mattermost 5/5, Slack 11/11, total 16/16. The complete unmodified exact-four changed-code gate also passed; the authenticated wrapper reported exit code 0 after 445,500 ms.
{"proof":"thread-participation-real-owner-sqlite-and-full-gate","candidate":"85f74ae2ff237f268dd46cbed5fdf32012b8b7de","parent":"c53e594aae79690d7bc809157c904a5ecd745190","changedPaths":4,"parentPhysicalRed":2,"parentCommittedRegressionsRed":2,"candidatePhysicalGreen":2,"focusedTests":16,"completeChangedGate":"PASS","externalNetworkAttempts":0}

Complete authenticated gate:

node scripts/check-changed.mjs --base c53e594aae79690d7bc809157c904a5ecd745190 --head 85f74ae2ff237f268dd46cbed5fdf32012b8b7de -- extensions/mattermost/src/mattermost/thread-participation.test.ts extensions/mattermost/src/mattermost/thread-participation.ts extensions/slack/src/sent-thread-cache.test.ts extensions/slack/src/sent-thread-cache.ts

Maintainer merge-risk decision

Maintainer decision: accept the documented seven-day Mattermost and 24-hour Slack expiry correction; exact head 85f74ae passed both channel-contract shards, all six changed-node shards, channel-runtime-boundary analysis, build artifacts, the complete exact-four changed gate, 16 owner tests, and real parent-RED/candidate-GREEN SQLite restart proofs.

Expired participation must not silently activate a thread after its documented deadline. This changes only activation after genuinely expired participation; account authorization, channel boundaries, the existing durable storage format, schema, and SDK remain unchanged. No database migration or schema-version change is involved.

@openclaw-barnacle openclaw-barnacle Bot added channel: mattermost Channel integration: mattermost channel: slack Channel integration: slack size: XS maintainer Maintainer-authored PR labels Aug 3, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P1 High-priority user-facing bug, regression, or broken workflow. merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. labels Aug 3, 2026
@clawsweeper

clawsweeper Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 3, 2026, 7:03 AM ET / 11:03 UTC.

ClawSweeper review

What this changes

The PR makes Slack and Mattermost restore thread-participation cache entries with their persisted reply timestamp so a gateway restart cannot extend implicit thread-reply eligibility.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep this PR open for maintainer landing: current main still re-primes the memory cache at restart time, while the branch restores the persisted reply time and thereby preserves the documented expiry boundary. The patch is narrow, matches the existing shared-cache contract, has focused regression coverage and credible real-owner proof; the protected maintainer label leaves the final merge decision to a human after exact merge-ref checks finish.

Priority: P1
Reviewed head: 85f74ae2ff237f268dd46cbed5fdf32012b8b7de
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Strong real-owner restart proof, focused regression tests, and a minimal owner-boundary patch support a high-confidence merge review.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body provides exact-candidate, after-fix terminal evidence from actual Slack and Mattermost owners backed by real SQLite state, including parent RED and candidate GREEN results; no additional contributor proof is needed.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body provides exact-candidate, after-fix terminal evidence from actual Slack and Mattermost owners backed by real SQLite state, including parent RED and candidate GREEN results; no additional contributor proof is needed.
Evidence reviewed 6 items Current-main root cause: The shared persistent dedupe cache re-primes memory with readTimestamp when supplied, but otherwise passes no timestamp to memory.check; the underlying cache records that call at current time. Neither current Slack nor Mattermost owner supplies readTimestamp, so a durable hit after restart receives a fresh TTL.
Shared-contract precedent and test: The existing SDK test explicitly verifies that a supplied persisted timestamp causes re-primed memory to expire at the original deadline rather than after a fresh TTL, which is exactly the contract this PR consumes.
Patch applies the owner-local repair: Both channel owners add only readTimestamp: ({ repliedAt }) => repliedAt to their existing persistent cache configuration; the change leaves storage, SDK, configuration, and account-routing keys untouched.
Findings None None.
Security None None.

How this fits together

Slack and Mattermost record that the bot visibly replied in a thread, then use that participation record to allow later thread follow-ups without a new mention. The record is kept both in process memory and in plugin SQLite state; on a restart, the persistent lookup re-primes the in-memory fast path that decides whether inbound messages activate the bot.

flowchart LR
  A[Bot sends visible thread reply] --> B[Plugin records reply timestamp]
  B --> C[Memory participation cache]
  B --> D[Plugin SQLite keyed state]
  E[Gateway restart] --> F[Persistent participation lookup]
  D --> F
  F --> C
  C --> G[Implicit thread-reply gate]
  G --> H[Reply allowed or mention required]
Loading

Decision needed

Question Recommendation
Should the repository owner accept this correction to post-restart implicit thread activation once the exact merge ref completes its required checks? Merge the expiry correction: Accept the existing shared-cache contract and land the owner-local fixes after exact merge-ref checks complete.

Why: The branch is a focused bug repair with strong evidence, but the protected maintainer label requires explicit human handling for the final landing decision.

Before merge

  • Resolve merge risk (P1) - This intentionally changes message activation after a restart: threads whose durable participation window has actually expired will no longer receive an implicit reply. That is the documented correction, but the exact merge ref should complete its channel checks before landing.
Agent review details

Security

None.

PR surface

Source +4, Tests +28. Total +32 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 2 4 0 +4
Tests 2 34 6 +28
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 38 6 +32

Review metrics

Metric Value Why it matters
Production versus regression coverage production +4/-0 (2 executable lines, 2 invariant comments); tests +34/-6 (net +28) The small production increase is justified by preserving the authoritative persisted expiry timestamp, with focused coverage for both channel owners.

Stored data model

Persistent data-model change detected: persistent cache schema: extensions/mattermost/src/mattermost/thread-participation.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Land after exact merge-ref validation (recommended)
    Merge once the current merge ref's channel checks pass, accepting that expired persisted participation will correctly stop triggering implicit replies after restart.
  2. Pause for a different activation policy
    Do not merge if maintainers want implicit thread participation to renew on restart, because that would require changing the documented expiry contract rather than this repair.

Technical review

Best possible solution:

Merge the two owner-local timestamp restorations after exact merge-ref checks are green, preserving one shared persistent-cache implementation and the established reply-time expiry invariant.

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

Yes. Current main lacks both owner timestamps, the shared cache defaults a persistent hit to the current time, and the PR provides exact-parent RED versus candidate GREEN restart proofs for both actual channel owners.

Is this the best way to solve the issue?

Yes. Supplying the already-persisted authoritative repliedAt at each plugin owner uses the existing shared contract and avoids an unnecessary SDK, schema, config, or fallback change.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P1: A gateway restart can cause Slack or Mattermost to keep implicitly activating expired thread conversations, affecting live channel behavior.
  • add merge-risk: 🚨 message-delivery: The patch deliberately changes whether a post-restart thread message triggers an automatic reply once its original participation deadline has passed.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides exact-candidate, after-fix terminal evidence from actual Slack and Mattermost owners backed by real SQLite state, including parent RED and candidate GREEN results; no additional contributor proof is needed.
  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body provides exact-candidate, after-fix terminal evidence from actual Slack and Mattermost owners backed by real SQLite state, including parent RED and candidate GREEN results; no additional contributor proof is needed.

Label justifications:

  • P1: A gateway restart can cause Slack or Mattermost to keep implicitly activating expired thread conversations, affecting live channel behavior.
  • merge-risk: 🚨 message-delivery: The patch deliberately changes whether a post-restart thread message triggers an automatic reply once its original participation deadline has passed.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body provides exact-candidate, after-fix terminal evidence from actual Slack and Mattermost owners backed by real SQLite state, including parent RED and candidate GREEN results; no additional contributor proof is needed.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides exact-candidate, after-fix terminal evidence from actual Slack and Mattermost owners backed by real SQLite state, including parent RED and candidate GREEN results; no additional contributor proof is needed.

Evidence

What I checked:

  • Current-main root cause: The shared persistent dedupe cache re-primes memory with readTimestamp when supplied, but otherwise passes no timestamp to memory.check; the underlying cache records that call at current time. Neither current Slack nor Mattermost owner supplies readTimestamp, so a durable hit after restart receives a fresh TTL. (src/plugin-sdk/dedupe-runtime.ts:99, fe6fa891ea4e)
  • Shared-contract precedent and test: The existing SDK test explicitly verifies that a supplied persisted timestamp causes re-primed memory to expire at the original deadline rather than after a fresh TTL, which is exactly the contract this PR consumes. (src/plugin-sdk/dedupe-runtime.test.ts:63, fe6fa891ea4e)
  • Patch applies the owner-local repair: Both channel owners add only readTimestamp: ({ repliedAt }) => repliedAt to their existing persistent cache configuration; the change leaves storage, SDK, configuration, and account-routing keys untouched. (extensions/mattermost/src/mattermost/thread-participation.ts:40, 85f74ae2ff23)
  • Documented Mattermost behavior: Mattermost documentation states that thread participation persists across gateway restarts but lasts seven days after the bot last replied, establishing the expected expiry invariant. Public docs: docs/channels/mattermost.md. (docs/channels/mattermost.md:171, fe6fa891ea4e)
  • Current-main and provenance check: The PR parent is an ancestor of the candidate, and current main has not changed any of the four touched files since that parent; the candidate is not contained in current main. File blame attributes the present owner setup to Peter Steinberger, while history also shows his earlier shared plugin-state consolidation work. (extensions/slack/src/sent-thread-cache.ts:31, 8edfa5ee5250)
  • Exact branch validation evidence: The PR body supplies an after-fix, real-owner SQLite restart proof on the exact candidate: parent RED and candidate GREEN behavior for both owners, plus focused 16/16 owner tests and a changed-path gate. The candidate diff is whitespace-clean on local inspection. (extensions/slack/src/sent-thread-cache.test.ts:93, 85f74ae2ff23)

Likely related people:

  • steipete: Current owner lines in both affected caches blame to Peter Steinberger, and the available history identifies his prior plugin-state consolidation as related to the shared persistence boundary. (role: recent channel-cache and shared-state contributor; confidence: high; commits: 8edfa5ee5250, eafe2a8d0bb6; files: extensions/mattermost/src/mattermost/thread-participation.ts, extensions/slack/src/sent-thread-cache.ts, src/plugin-sdk/dedupe-runtime.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.

@steipete
steipete merged commit e87fb68 into main Aug 3, 2026
110 of 123 checks passed
@steipete
steipete deleted the codex/auto-qa-thread-participation-ttl-owner-c53 branch August 3, 2026 11:12
@steipete

steipete commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

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

Labels

channel: mattermost Channel integration: mattermost channel: slack Channel integration: slack maintainer Maintainer-authored PR merge-risk: 🚨 message-delivery 🚨 May drop, duplicate, misroute, suppress, or wrongly target messages. P1 High-priority user-facing bug, regression, or broken workflow. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant