Skip to content

fix(nextcloud-talk): scope room cache to lookup credentials - #178227

Merged
steipete merged 1 commit into
mainfrom
deslop/z41-8-credential-cache-scope-20261015
Oct 20, 2026
Merged

steipete merged 1 commit into
mainfrom
deslop/z41-8-credential-cache-scope-20261015

Conversation

@steipete

@steipete steipete commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes Nextcloud Talk room-kind lookups reusing a cached direct/group result from a different server or API credential context with the same account ID and room token. A cached network-policy rejection also incorrectly suppresses a lookup under a different policy.

User Impact

Room classification now follows the actual server and API identity used for the lookup. Missing credentials no longer reuse a previously authenticated result. Same-context lookups still share the existing bounded cache. No configuration, protocol, storage, dependency, or migration change.

Why This Change Was Made

The room-info owner resolves its existing credentials before cache access and includes server URL, API user, a SHA-256 password digest, and the private-network policy choice in the key, alongside account and room. The digest uses the existing public Plugin SDK helper; raw passwords are not stored in cache keys.

Inbound handling consumes this classification for direct-versus-group routing and policy. This repair does not change those policies, guarded HTTP, response decoding/release, transient-error propagation to durable ingress, TTLs, or capacity limits.

Best-effort tradeoffs accepted

None removed. This is a bounded cache-identity bug fix, not a LARGE cleanup PR. Same-context remote room-kind changes retain the existing five-minute best-effort TTL; permanent-error fallback retains its existing thirty-second TTL. No generation counters, invalidation fences, or new cache owner were introduced.

Evidence

Acceptance rule: same account/token with interleaved contexts A/B/A must return the independently supplied kinds for A and B with exactly two physical lookup calls; removing credentials must return no authoritative classification without another request. A cached policy rejection must not suppress another policy's successful lookup, while returning to the first policy reuses its own rejection.

  • Base 28a0b5808ba7cd091e3013343be7dfa7968ef732, unchanged production: four added regression cases failed for the intended stale-classification/rejection reason; eight existing cases passed. Command: node scripts/run-vitest.mjs extensions/nextcloud-talk/src/room-info.test.ts --maxWorkers=1. File duration 25.86 seconds, wrapper wall 56.14 seconds on the shared loaded host.
  • Candidate: all 34 cases across five files passed (12 room-kind/cache cases, four credential-reader cases, three worker-backed durable-retry/fallback cases, one real hanging-HTTP timeout case, 14 suppression-audit cases). Command: node scripts/run-vitest.mjs extensions/nextcloud-talk/src/room-info.test.ts extensions/nextcloud-talk/src/room-info.fetch-timeout.test.ts extensions/nextcloud-talk/src/inbound.room-info-retry.test.ts extensions/nextcloud-talk/src/api-credentials.test.ts test/scripts/lint-suppressions.test.ts --maxWorkers=1. Wrapper wall 548.68 seconds on the shared loaded host, dominated by compiler preparation/imports; the real HTTP timeout case took 562 ms. CI seconds pending.
  • This is CI-safe boundary proof with synthetic HTTP responses, not live Nextcloud message-flow proof. No live credentials or operator state were accessed; HOME/OpenClaw/XDG state is task-isolated.
  • Exact-head hosted CI run 39386756484 completed successfully at 1b2ac83bb9cf6abe44fd52acbe70f99f9636efcd, supplying broad/type-aware proof. No whole-graph local build/typecheck or broad suite.
  • Both changed files pass formatting, focused root-config syntax lint, and git diff --check. Scoped cycles cover 46 production files: zero runtime cycles and no new static components against the pinned base.
  • Independent P0–P2 review completed scoped-clean with final source verification. The credential-reader implementation was not supplied because the review helper refused that optional sensitive filename; the lead inspected it directly, but that behavior is not independently source-reviewed.
  • Targeted local type proof remains unavailable because generated public Plugin SDK declarations are absent; no stubs, casts, broad generation or passing-typecheck claim. Exact-head CI remains the type gate.

Production delta: 8 net lines added (+15/-7); tests add 51 lines. This is a discovered routing/cache-identity bug fix, not a LARGE cleanup or residue.

Merged through the native workflow as e8df190f4617c9e0e5f6adff4ed2ec8aacc6d710; ancestry verified against fetched main and origin/main at 6088df9dbf4f8e61c9f09f7e6258bf1a5884e0e5. No CI rerun, repair push, or inherited-failure exception.

@clawsweeper

clawsweeper Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@steipete
steipete marked this pull request as ready for review October 20, 2026 07:28
@openclaw-barnacle openclaw-barnacle Bot added channel: nextcloud-talk Channel integration: nextcloud-talk size: S labels Oct 20, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T07:31:50.945321Z 1b2ac83 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. 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. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 20, 2026
@clawsweeper

clawsweeper Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR scopes Nextcloud Talk room classifications to the server, resolved API credentials, and network policy used for each lookup.

Example: Account default looks up shared-room on nc.example.com and then other.example.com, where the room types differ.

  • Before: The second server can reuse the first server's cached direct classification.
  • After: Each server receives its own lookup and cached classification.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The focused implementation and useful regressions support correctness, but authorization effects remain unproven beyond mocked classification tests.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Messages can receive another server or credential context's room classification and therefore follow the wrong DM or group handling.
Reason: This maintainer-authored repair restores context-correct classification without adding configuration, public APIs, persisted state, or a competing owner.

Merge readiness

⛔ Blocked before merge - 2 items remain

Keep open: this PR fixes a source-confirmed cache-identity bug still present on current main, and no introduced code defect was found.

Priority: P2
Reviewed head: 1b2ac83bb9cf6abe44fd52acbe70f99f9636efcd

Before merge

  • Add real behavior proof - Authority-chain proof required: the changed room-info cache feeds DM/group authorization, but supplied context-isolation tests mock guarded HTTP and stop at the returned classification; existing real-HTTP retry tests exercise a different scenario and mock dispatch. Provide redacted logs or terminal output from the production message flow showing allowed processing and rejection of the nearest forbidden group sender after interleaved server or credential contexts and credential removal or reassignment, before agent dispatch and reply I/O. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Resolve merge risk - Before merge, demonstrate that interleaved lookup contexts cannot carry a DM classification into a group context that forbids the sender, including after credential removal or reassignment, through final dispatch and reply boundaries.

Findings

None.

Tests

  • Missing end-to-end proof: Supply redacted production-flow evidence for interleaved lookup contexts, an allowed sender, and a group-forbidden sender after credential change or removal, showing correct classification and rejection before dispatch or reply.
Agent review details

How this fits together

The Nextcloud Talk plugin resolves room metadata before inbound authorization; account credentials and a room token enter the lookup, and a direct, group, or unknown classification selects downstream routing and access rules.

flowchart TD
  A[Inbound Talk message] --> B[Room lookup owner]
  C[Resolved credentials and network policy] --> B
  B --> D[Scoped bounded cache]
  B --> E[Guarded Nextcloud HTTP request]
  D --> F[DM or group access policy]
  E --> F
  F --> G[Agent dispatch and reply]
Loading

Technical review

Best possible solution:

Retain this focused repair in the existing room-info owner and verify its authorization effects through the production message flow.

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

Current-main source deterministically permits cross-context cache reuse before credential checks; the PR reports four intended baseline failures, but this review executed no target code.

Is this the best way to solve the issue?

The patch addresses the root cause with the smallest complete change: resolve existing credentials first and include every classification-affecting lookup context in the existing cache key.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 4601114c7fbd.

Merge-risk options

Maintainer options:

  1. Verify context isolation through authorization (recommended)
    Record allowed and forbidden sender flows with the same account and room token across distinct lookup contexts, showing that credential changes or removal cannot reuse another context's authority before dispatch or reply.

Provenance checked

  • Bounded room metadata cache keeps the original intent (936136a: Prevent long-lived metadata caches from growing without bound while preserving TTL and request behavior.)
  • Lookup failure handling and cache entries keeps the original intent (39dfbc8: Propagate transient room lookup failures to durable ingress retries while preserving permanent-error and unconfigured fallbacks.)

Testing

Proof path: unit tests only.

Security

None.

Evidence

What I checked:

PR surface

Source +8, Tests +51. Total +59 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 15 7 +8
Tests 1 51 0 +51
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 66 7 +59

Labels

Label changes:

  • add P2: A focused cache-identity defect can misclassify rooms when lookup contexts share an account ID and room token; no ongoing widespread outage is established.
  • add merge-risk: 🚨 security-boundary: Cached room classification selects DM versus group access rules, so context isolation needs final-effect authorization proof.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Label justifications:

  • P2: A focused cache-identity defect can misclassify rooms when lookup contexts share an account ID and room token; no ongoing widespread outage is established.
  • merge-risk: 🚨 security-boundary: Cached room classification selects DM versus group access rules, so context isolation needs final-effect authorization proof.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Add final-effect proof for a sender allowed in the direct context but forbidden in the group context, and show credential removal or reassignment prevents stale classification from authorizing dispatch or reply.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

Reviewed October 20, 2026, 3:44 AM ET / 07:44 UTC.

@steipete
steipete merged commit e8df190 into main Oct 20, 2026
188 of 189 checks passed
@steipete
steipete deleted the deslop/z41-8-credential-cache-scope-20261015 branch October 20, 2026 08:15
@steipete

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: nextcloud-talk Channel integration: nextcloud-talk merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. 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.

1 participant