GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — feat(appwrite): secure mounted robot access by SloppyBobbert · Pull Request #70 · SloppyBobbert/Dosey Conversation
|
|
Warning Review limit reached
Next review available in: 33 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (12)
📝 WalkthroughWalkthroughThis PR adds secure anonymous mounted-robot lookup, transactional mounted-access persistence, pairing conflict handling, updated Team membership checks, backend CI, and documentation describing Function configuration and rollout behavior. ChangesMounted access and pairing
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Client
participant getMountedRobot
participant IdentityVerifier
participant MountedRobotService
participant TablesDB
Client->>getMountedRobot: POST anonymous request
getMountedRobot->>IdentityVerifier: verifyAnonymous(headers)
IdentityVerifier-->>getMountedRobot: account ID
getMountedRobot->>MountedRobotService: get(account ID)
MountedRobotService->>TablesDB: read mounted access
MountedRobotService->>TablesDB: read robot installation
TablesDB-->>MountedRobotService: access and installation data
MountedRobotService-->>Client: robot identity or null
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 9
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/appwrite-backend-ci.yml:
- Around line 30-39: Update the checkout and setup-node action references in the
workflow to the current v7 major releases, replacing their existing v4 SHA pins
with the corresponding v7 SHA-pinned versions. Preserve the existing action
inputs, including persist-credentials, node-version, cache, and
cache-dependency-path.
In `@backend/appwrite/src/application/mounted-robot-services.ts`:
- Around line 24-27: Update createGetMountedRobotHandler to return { robot: null
} when getRobotInstallation returns no installation or a non-active status,
including provisioning, instead of throwing. Keep exceptions reserved for
genuine invariant violations and preserve the existing service-result handling
for active installations.
In `@backend/appwrite/src/domain/household-invitation.ts`:
- Around line 37-40: Before adopting the new hash input in
householdInvitationId, verify the historical ID contract, including whether it
used unnormalized robotId plus invitedEmail separated by a newline. Preserve
compatibility by continuing to resolve existing invitation rows generated under
the legacy contract during replacesInvitation(previousId) and subsequent
replacements, or provide the required migration before switching formats.
In `@backend/appwrite/src/functions/get-mounted-robot.ts`:
- Around line 20-22: Update the request-body validation in get-mounted-robot so
undefined or null bodyJson values are treated as valid empty bodies, while still
returning invalid_request for non-empty objects. Guard the isEmptyObject check
with an explicit absent-body condition.
In `@backend/appwrite/src/infrastructure/appwrite-pairing-persistence.ts`:
- Around line 465-470: The duplicated isNotFound 404 predicate should be
centralized in a shared infrastructure helper to keep Appwrite error semantics
consistent. In
backend/appwrite/src/infrastructure/appwrite-pairing-persistence.ts#L465-L470,
move the predicate into the shared module and import it where used; in
backend/appwrite/src/infrastructure/appwrite-mounted-robot-access.ts#L97-L102,
remove the local copy and import the same helper, preserving the existing
AppwriteException and generic object checks.
In `@backend/appwrite/src/infrastructure/transactional-pairing-store.ts`:
- Around line 163-174: Guard the resolveClaimConflict flow in the surrounding
claim-conflict handler so it is only called when conflictRobotId is non-null and
represents the found claim robot; do not pass the fallback empty string.
Preserve the existing accepted, consumed, device_already_mounted, and
thrown-error handling for valid robot IDs, while allowing earlier conflicts
without a resolved robot ID to surface through the existing error path.
In `@backend/appwrite/src/runtime/mounted-robot-runtime.ts`:
- Around line 21-39: Extract the duplicated Appwrite account construction from
the identity verifier callbacks into a local JWT account factory, mirroring
createUserAccount in pairing-runtime.ts. Reuse the factory in both
getCurrentAccountId and getCurrentAnonymousAccount while preserving the existing
JWT validation and account/session behavior.
- Line 10: Update the mounted robot runtime’s reportError handling: either
remove the unused reportError parameter and update callers such as
get-mounted-robot.ts, or invoke it for identity/lookup failures instead of
retaining the dead-code marker. Ensure the runtime no longer silently accepts an
error reporter that is never used.
In `@backend/appwrite/test/transactional-pairing-store.test.ts`:
- Around line 218-231: Rename the test case title in the claimAtomically
rejection test to describe generic candidate membership validation via the
canClaim callback, removing the stale “Team-member” wording. Keep the test
setup, assertions, and behavior unchanged.
Fix all unresolved CodeRabbit comments on this PR:
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 1f1a1a12-f71e-4000-979a-34b9924e0918
.github/workflows/appwrite-backend-ci.ymlREADME.mdbackend/appwrite/README.mdbackend/appwrite/src/application/mounted-robot-services.tsbackend/appwrite/src/application/pairing-services.tsbackend/appwrite/src/domain/household-invitation.tsbackend/appwrite/src/domain/mounted-robot-access.tsbackend/appwrite/src/domain/pairing-claim.tsbackend/appwrite/src/entrypoints/claim-robot.tsbackend/appwrite/src/entrypoints/create-pairing-code.tsbackend/appwrite/src/entrypoints/get-mounted-robot.tsbackend/appwrite/src/functions/claim-robot.tsbackend/appwrite/src/functions/function-identity.tsbackend/appwrite/src/functions/get-mounted-robot.tsbackend/appwrite/src/infrastructure/appwrite-mounted-robot-access.tsbackend/appwrite/src/infrastructure/appwrite-pairing-persistence.tsbackend/appwrite/src/infrastructure/appwrite-robot-access-directory.tsbackend/appwrite/src/infrastructure/transactional-pairing-store.tsbackend/appwrite/src/runtime/mounted-robot-runtime.tsbackend/appwrite/src/runtime/pairing-runtime.tsbackend/appwrite/test/appwrite-mounted-robot-access.test.tsbackend/appwrite/test/appwrite-pairing-persistence.test.tsbackend/appwrite/test/appwrite-robot-access-directory.test.tsbackend/appwrite/test/claim-robot-handler.test.tsbackend/appwrite/test/function-identity.test.tsbackend/appwrite/test/get-mounted-robot.test.tsbackend/appwrite/test/household-entrypoints.test.tsbackend/appwrite/test/household-services.test.tsbackend/appwrite/test/mounted-robot-runtime.test.tsbackend/appwrite/test/pairing-runtime.test.tsbackend/appwrite/test/pairing-services.test.tsbackend/appwrite/test/transactional-pairing-store.test.tsmobile_app/README.mdmobile_app/dosey_app/README.md[warning] 26-26: Do not use variable for regular expressions
Context: new RegExp(variable)
Note: [CWE-1333] Inefficient Regular Expression Complexity. Security best practice.
(regexp-non-literal-typescript)
[warning] 26-26: Regular expression constructed from variable input detected. This can lead to Regular Expression Denial of Service (ReDoS) attacks if the variable contains malicious patterns. Use libraries like 'recheck' to validate regex safety or use static patterns.
Context: new RegExp(variable)
Note: [CWE-1333] Inefficient Regular Expression Complexity
(regexp-from-variable)
[style] ~18-~18: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...e-time checks, and schedule profiles. - Local household/profile metadata plus Appwrit...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
[style] ~35-~35: Three successive sentences begin with the same word. Consider rewording the sentence or use a thesaurus to find a synonym.
Context: ...us only, not provisioning. - appwrite for human identity, robot ownership, and cu...
(ENGLISH_WORD_REPEAT_BEGINNING_RULE)
backend/appwrite/src/infrastructure/appwrite-robot-access-directory.ts (2)
37-46: LGTM!
68-74: 🎯 Functional Correctness
Query.equal('userId', ...)is supported forlistMemberships.No change needed for this filter.
backend/appwrite/src/infrastructure/transactional-pairing-store.ts (1)
107-153: LGTM!backend/appwrite/src/infrastructure/appwrite-pairing-persistence.ts (1)
44-60: LGTM!Also applies to: 170-224, 253-292, 421-463
backend/appwrite/src/application/mounted-robot-services.ts (1)
17-22: LGTM!backend/appwrite/src/infrastructure/appwrite-mounted-robot-access.ts (1)
21-42: LGTM!Also applies to: 45-95
backend/appwrite/src/entrypoints/get-mounted-robot.ts (1)
4-13: LGTM!backend/appwrite/src/functions/get-mounted-robot.ts (1)
13-19: 🎯 Functional Correctness
verifyAnonymousnarrowing matches the declared shape.
AnonymousIdentityVerificationisstring | { readonly reason: 'provider' } | null, and theverifyAnonymousimplementation returns{ reason: 'provider' }only for non-anonymous provider accounts, so these narrowings are consistent.backend/appwrite/src/domain/mounted-robot-access.ts (1)
1-13: LGTM!backend/appwrite/src/domain/pairing-claim.ts (1)
16-17: LGTM!backend/appwrite/src/functions/function-identity.ts (1)
7-17: LGTM!Also applies to: 31-35, 45-48, 67-86
backend/appwrite/src/runtime/pairing-runtime.ts (1)
18-36: LGTM!Also applies to: 57-72, 85-92
backend/appwrite/src/entrypoints/create-pairing-code.ts (1)
11-12: LGTM!backend/appwrite/src/functions/claim-robot.ts (2)
6-6: LGTM!Also applies to: 77-77
34-46: 🗄️ Data Integrity & IntegrationKeep
claim-robotdeployed on separate secure and legacy paths.This repo source alone doesn’t define which Appwrite Function ID gets this anonymous-only handler or mounted-access runtime settings, so the Team-backed restoration path used by installed clients must remain on a separate legacy Function and this handler/source should not replace it.
.github/workflows/appwrite-backend-ci.yml (1)
1-52: LGTM!README.md (3)
51-51: 📐 Maintainability & Code Quality | ⚡ Quick winWording implies Functions, not Teams, own household authority.
This row states "App data | Drift/SQLite remains local-first; Appwrite provides human identity, while Functions provide household ownership and mounted-phone pairing foundations", but
backend/appwrite/README.mdexplicitly states that "Appwrite Teams remain the authority for robot ownership and human household membership" and TablesDB is the authority for pairing/mounted-device access. Consider rewording this row to keep the authority split intact (e.g. "Functions mediate access to Appwrite-Team-owned households and TablesDB-backed pairing") so the at-a-glance summary doesn't contradict the more precise backend contract described elsewhere in this PR.
84-88: LGTM!
165-165: LGTM!backend/appwrite/README.md (4)
3-25: LGTM!
35-116: LGTM!
135-138: 📐 Maintainability & Code Quality | ⚡ Quick win"above" should be "below."
Create a server-only database with no client row permissions. This contract has six TablesDB tables, including
mounted_robot_accessabove. Themounted_robot_accesscolumns are documented after this sentence (further down this section), not above it — the reference direction is backwards and will confuse readers scanning for it earlier in the file.📝 Proposed fix
-Create a server-only database with no client row permissions. This contract has -six TablesDB tables, including `mounted_robot_access` above. +Create a server-only database with no client row permissions. This contract has +six TablesDB tables, including `mounted_robot_access` below.
164-179: LGTM!backend/appwrite/test/appwrite-mounted-robot-access.test.ts (1)
1-93: LGTM!backend/appwrite/test/appwrite-pairing-persistence.test.ts (3)
13-81: LGTM!
84-221: LGTM!
83-83: 🎯 Functional Correctness
describeis already imported fromnode:test.backend/appwrite/test/appwrite-robot-access-directory.test.ts (1)
6-134: LGTM!backend/appwrite/test/mounted-robot-runtime.test.ts (1)
1-31: LGTM!mobile_app/dosey_app/README.md (1)
18-18: LGTM!Also applies to: 27-35, 44-55, 64-79, 100-100, 123-123
backend/appwrite/test/claim-robot-handler.test.ts (2)
42-43: LGTM!Also applies to: 89-89, 100-130, 179-179
189-189: 🎯 Functional Correctness
device_already_mountedalready maps to HTTP 409.backend/appwrite/test/function-identity.test.ts (1)
7-94: LGTM!backend/appwrite/test/get-mounted-robot.test.ts (1)
1-179: LGTM!backend/appwrite/test/household-entrypoints.test.ts (1)
8-16: LGTM!backend/appwrite/test/household-services.test.ts (1)
13-16: LGTM!Also applies to: 96-103
backend/appwrite/test/pairing-runtime.test.ts (1)
17-71: LGTM!backend/appwrite/test/pairing-services.test.ts (1)
21-25: LGTM!Also applies to: 52-61, 76-151
backend/appwrite/test/transactional-pairing-store.test.ts (1)
12-83: LGTM!Also applies to: 102-102, 114-139, 233-306
mobile_app/README.md (1)
14-14: LGTM!Also applies to: 29-32, 63-71
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| return createHash('sha256') | ||
| .update(`dosey:household-invitation:v1\0${robotId.length}:${robotId}\0${normalizedEmail.length}:${normalizedEmail}`, 'utf8') | ||
| .digest('hex') | ||
| .slice(0, 36); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win
🏁 Script executed:
#!/bin/bash set -euo pipefail echo "== locate file ==" git ls-files | rg '(^|/)household-invitation\.ts$|household-invitation' || true echo "== file outline ==" ast-grep outline backend/appwrite/src/domain/household.invitation.ts --view expanded 2>/dev/null || true ast-grep outline backend/appwrite/src/domain/household-invitation.ts --view expanded 2>/dev/null || true echo "== relevant household-invitation.ts ==" cat -n backend/appwrite/src/domain/household-invitation.ts echo "== search previous/current id/hash usage ==" rg -n "household-invitation|documentId|createHash|robotId|normalizedEmail|household-invitation" backend/appwrite/src -S || true echo "== appwrite invites files outline/list ==" rg -n "household.invitation|household-invitation|householdInvitation|household invitation" backend/appwrite/src tests . --glob '!*node_modules*' --glob '!*dist*' --glob '!*build*' || true
Repository: SloppyBobbert/Dosey
Length of output: 35028
🏁 Script executed:
#!/bin/bash set -euo pipefail echo "== git diff for household-invitation.ts ==" git diff -- backend/appwrite/src/domain/household-invitation.ts || true echo "== create household invitation code ==" cat -n backend/appwrite/src/functions/create-household-invitation.ts echo "== create household invitation implementation ==" cat -n backend/appwrite/src/application/household-services.ts | sed -n '115,175p' echo "== household persistence retrieval ==" cat -n backend/appwrite/src/infrastructure/appwrite-household-persistence.ts | sed -n '120,235p' echo "== appwrite transactional registry duplicate rejection ==" cat -n backend/appwrite/src/infrastructure/transactional-household-registry.ts | sed -n '170,210p' echo "== behavioral probe: old vs new householdInvitationId outputs ==" node - <<'JS' const crypto = require('node:crypto'); function old(robotId, normalizedEmail) { return crypto.createHash('sha256') .update(`${robotId}\n${normalizedEmail}`, 'utf8') .digest('hex') .slice(0, 36); } function current(robotId, normalizedEmail) { return crypto.createHash('sha256') .update(`dosey:household-invitation:v1\0${robotId.length}:${robotId}\0${normalizedEmail.length}:${normalizedEmail}`, 'utf8') .digest('hex') .slice(0, 36); } const samples = [ ['robot-1', '[email protected]'], ['robot-1', '[email protected]'], ['robot-1', 'a b [email protected]'], ]; for (const [robotId, email] of samples) { console.log({ robotId, email, old: old(robotId, email), current: current(robotId, email), oldEqualsCurrent: old(robotId, email) === current(robotId, email) }); } JS
Repository: SloppyBobbert/Dosey
Length of output: 333
🏁 Script executed:
#!/bin/bash set -euo pipefail echo "== changed files stat ==" git status --short echo "== household-invitation diff ==" git diff -- backend/appwrite/src/domain/household-invitation.ts backend/appwrite/src/domain/ | sed -n '1,220p' || true echo "== household invitation files ==" for f in backend/appwrite/src/functions/create-household-invitation.ts backend/appwrite/src/entrypoints/create-household-invitation.ts; do if [ -f "$f" ]; then echo "--- $f ---" cat -n "$f" fi done echo "== household services relevant lines ==" for f in backend/appwrite/src/application/household-services.ts backend/appwrite/src/infrastructure/appwrite-household-persistence.ts backend/appwrite/src/infrastructure/transactional-household-registry.ts; do if [ -f "$f" ]; then echo "--- $f ---" cat -n "$f" | sed -n '1,280p' fi done echo "== behavioral probe: old vs new householdInvitationId outputs ==" node - <<'JS' const crypto = require('node:crypto'); function old(robotId, normalizedEmail) { return crypto.createHash('sha256') .update(`${robotId}\n${normalizedEmail}`, 'utf8') .digest('_hex') .slice(0, 36); } function current(robotId, normalizedEmail) { return crypto.createHash('sha256') .update(`dosey:household-invitation:v1\0${robotId.length}:${robotId}\0${normalizedEmail.length}:${normalizedEmail}`, 'utf8') .digest('hex') .slice(0, 36); } const samples = [['robot-1', '[email protected]'], ['robot-1', '[email protected]'], ['robot-1', 'a b [email protected]']]; for (const [robotId, email] of samples) { const oldId = crypto .createHash('sha256') .update(`${robotId}\n${email}`, 'utf8') .digest('hex') .slice(0, 36); console.log({ robotId, email, old: oldId, current: current(robotId, email), oldEqualsCurrent: oldId === current(robotId, email) }); } console.log({ currentId: current('robot-1', '[email protected]'), currentEmptyEmail: current('robot-1', ''), currentSameRobotDifferentEmail: current('robot-1', '[email protected]'), }); JS
Repository: SloppyBobbert/Dosey
Length of output: 34770
Verify previous invitation IDs before switching the hash contract.
The changed householdInvitationId format makes every existing (robotId, normalizedEmail) pair generate a different Appwrite row ID, so legacy invitation rows will not be found via replacesInvitation(previousId) or subsequent replacements unless migrated. Also confirm whether the historical contract used unnormalized ${robotId}\n${invitedEmail} or normalized email.
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@backend/appwrite/src/domain/household-invitation.ts` around lines 37 - 40,
Before adopting the new hash input in householdInvitationId, verify the
historical ID contract, including whether it used unnormalized robotId plus
invitedEmail separated by a newline. Preserve compatibility by continuing to
resolve existing invitation rows generated under the legacy contract during
replacesInvitation(previousId) and subsequent replacements, or provide the
required migration before switching formats.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.