Skip to content

feat(dropbox): export relayfile adapter surfaces, webhook normalizer, and digests#118

Merged
khaliqgant merged 6 commits into
mainfrom
feat/dropbox-relayfile-exports-digests
May 26, 2026
Merged

feat(dropbox): export relayfile adapter surfaces, webhook normalizer, and digests#118
khaliqgant merged 6 commits into
mainfrom
feat/dropbox-relayfile-exports-digests

Conversation

@khaliqgant
Copy link
Copy Markdown
Member

Summary

  • add Dropbox adapter exports required by cloud ADAPTERS wiring: layoutPromptFile, resources, emitDropboxAuxiliaryFiles, and webhook-normalizer
  • add discovery schemas/create examples for files, folders, shared-folders, and shared-links
  • expand path mapping + auxiliary emitters to include _index.json and by-id aliases for all Dropbox resources
  • add extensive digest handling/tests including terminal verb coverage (archived, completed) and shared-folder/shared-link bullets

Validation

  • npm test
  • npm run build

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 25, 2026

Review Change Stack

Warning

Review limit reached

@khaliqgant, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 52 minutes and 52 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 004c38d1-2995-483d-b7d2-1e4671a87627

📥 Commits

Reviewing files that changed from the base of the PR and between 42407fc and 0f8f3c7.

📒 Files selected for processing (1)
  • packages/dropbox/src/emit-auxiliary-files.ts
📝 Walkthrough

Walkthrough

This PR extends the Dropbox adapter to support folders, shared-folders, and shared-links as discoverable resource types. It refactors path mapping to use uniform, resource-type-aware builders, updates discovery configuration and digest event handling, adds auxiliary file emission for indices and aliases, introduces layout documentation and webhook normalization, and exports the new modules via updated package exports.

Changes

Dropbox Resource Type Expansion

Layer / File(s) Summary
Discovery schemas and examples for new resource types
packages/dropbox/discovery/dropbox/folders/.schema.json, .create.example.json, packages/dropbox/discovery/dropbox/shared-folders/.schema.json, .create.example.json, packages/dropbox/discovery/dropbox/shared-links/.schema.json, .create.example.json
JSON Schema contracts and example payloads define the metadata shape for folders (path_display, name, path_lower, parent_shared_folder_id), shared-folders (shared_folder_id, shared_folder_name, is_team_folder, parent_shared_folder_id), and shared-links (url, name, path_lower, type, expires).
Path mapper refactoring for unified resource routing
packages/dropbox/src/path-mapper.ts
Path constants simplified by removing {accountId} placeholders. New path-builder exports for files/folders/shared-folders/shared-links and index/alias paths replace provider-based switching. encodePathSegment reworked to normalize and validate slash-separated segments. toObjectRelayfilePath simplified to route via computeDropboxPath. parseRelayfilePath updated to detect paths via exact segment matching against LIFECYCLE_RESOURCE_PATH and DROPBOX_PATH_ROOT.
Resource discovery configuration
packages/dropbox/src/resources.ts
Resource registry expanded from files and cursors to files, folders, shared-folders, and shared-links; cursors removed. New sampleIndexPath field added to resource config interface. findResourceByPath simplified to test paths directly without normalization.
Digest handler configuration and identifier computation
packages/dropbox/src/digest.ts
createDigestHandler configuration replaces custom acceptEvent/classify with static alias (mode: 'any') and new actionRules mapping actions (create/update/move/share/archive/delete/close) to past-tense text. dropboxIdentifier rewritten to derive labels from canonical path segments (files/folders/shared-folders/shared-links) instead of provider/account-based skipping.
Auxiliary file emission and indexing
packages/dropbox/src/emit-auxiliary-files.ts
New emitDropboxAuxiliaryFiles function orchestrates writing per-type indices and alias payloads. Per-resource emitter functions (emitFiles, emitFolders, emitSharedFolders, emitSharedLinks) read existing indices, compute canonical paths and alias destinations, handle deletes by removing entries/aliases, upsert records with timestamps, and persist sorted indices. Helper functions safely read/write indices and manage write/delete counts and errors.
Layout prompt and webhook normalization utilities
packages/dropbox/src/layout-prompt.ts, packages/dropbox/src/webhook-normalizer.ts
layout-prompt.ts exports DropboxVfsFile interface and dropboxLayoutPromptFile() function providing Markdown documentation of the /dropbox/ mount layout. webhook-normalizer.ts exports NormalizedDropboxWebhook interface and normalizeDropboxWebhook() function extracting provider, eventType, accountIds, deliveryId, and headers from Dropbox webhook payloads.
Digest behavior tests for new resource types
packages/dropbox/src/digest.test.ts
New test cases validate that file.archived and file.completed events render terminal-state bullets with .json suffixes removed from display text, and that file.updated (shared-folders) and file.shared (shared-links) events render type-specific bullets with identifiers derived from canonical paths.
Emit/path-mapper/resources/layout tests
packages/dropbox/src/__tests__/*
New unit tests for emitDropboxAuxiliaryFiles (CapturingClient), path-mapper canonicalization/routing, resources path matching, and layout prompt content coverage.
Package integration: exports
packages/dropbox/package.json, packages/dropbox/src/index.ts
Package exports field extended with subpath entries for ./layout-prompt, ./emit-auxiliary-files, and ./webhook-normalizer; main index.ts re-exports the new modules.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • AgentWorkforce/relayfile-adapters#49: Both PRs update path/filename naming to use the canonical <name>__<id> convention—Dropbox’s path-mapper and tests now format/parse Dropbox VFS paths with <slug>__<id>.json, matching the mount name/id convention introduced in the retrieved PR.
  • AgentWorkforce/relayfile-adapters#99: The main PR’s DropBox changes (removing/rewiring the provider-specific digest handler behavior in src/digest.ts and adding .schema.json/.create.example.json discovery files) align with adapter-slice contract updates in PR #99.
  • AgentWorkforce/relayfile-adapters#78: Implements auxiliary-files emission orchestration similar to patterns introduced in that PR; relevant to emitDropboxAuxiliaryFiles design and tests.

Poem

🐰 I hopped through paths both new and neat,
Folders and links now march in fleet.
Indices write and webhooks sing,
Layouts point where schemas cling.
Cheers from a rabbit—hops and a treat!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title accurately summarizes the primary changes: exporting Dropbox relayfile adapter surfaces, webhook normalizer, and digest handling.
Description check ✅ Passed The PR description clearly relates to the changeset, detailing exports, schemas, path mapping, auxiliary emitters, digest handling, and validation steps.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/dropbox-relayfile-exports-digests

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 7

🤖 Prompt for all review comments with AI agents
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 `@packages/dropbox/src/emit-auxiliary-files.ts`:
- Around line 72-76: Replace the hard-coded literal "/dropbox/_index.json" with
the typed path helper by importing dropboxRootIndexPath from the adapter's
path-mapper and passing input.workspaceId (and any required args) to it; update
the safeWrite call (the one that currently passes "/dropbox/_index.json") to use
dropboxRootIndexPath(...) instead so path construction is centralized and
consistent with the path-mapper contract.
- Around line 120-155: When upserting aliases in the records loop, detect and
remove stale by-path aliases when an item's path_lower changes (and also handle
deletes that lack path_lower) by: before setting rows.set(id,...), look up the
existing entry for this id (rows.get(id)) to obtain the previous
path_lower/canonicalPath; if the previous path_lower exists and is different
from the new path_lower, call safeDelete(client, workspaceId,
dropboxFileByPathAliasPath(previousPathLower), aggregate) (use the same
dropboxFileByPathAliasPath helper and by-path alias logic used for writes);
apply the same change for the folder-handling block (lines ~173-205) so
moves/renames remove the old by-path alias and for delete records fallback to
the stored previous path_lower when record.path_lower is missing.

In `@packages/dropbox/src/path-mapper.ts`:
- Around line 55-69: dropboxFilePath and dropboxFolderPath (and the
computeDropboxPath logic handling file/folder types) currently emit path-derived
filenames; change them to emit canonical flat-record filenames in the form
<slug>__<id>.json under the respective resource directory (e.g.,
`${DROPBOX_PATH_ROOT}/files/` and `${DROPBOX_PATH_ROOT}/folders/`). Use the
existing slug utilities (slugifyAlias and aliasCollisionSuffix from
packages/core/src/alias-slug.ts) to produce the slug and append the collision
suffix when needed, then concatenate as `${slug}__${id}.json`; remove reliance
on encodedPathOrId for these flat records. Update computeDropboxPath branches
for file and folder to call the new dropboxFilePath/dropboxFolderPath behavior
so canonical paths are stable on rename/move.
- Around line 153-160: parseRelayfilePath is stripping ".json" from every path
segment and treating any path that starts with LIFECYCLE_RESOURCE_PATH as a
lifecycle record even when there is no trailing id; change the segmentation so
decodeURIComponent is applied to all segments but the ".json" suffix is only
removed from the terminal segment (use normalized.split('/').filter(Boolean) ->
map decode then for last segment strip /\.json$/u), and change the lifecycle
detection (where lifecycleSegments and the every(...) comparison is used) to
require an extra segment (e.g., segments.length > lifecycleSegments.length)
before returning a lifecycle resource with id = last segment; update references
in parseRelayfilePath, segments, LIFECYCLE_RESOURCE_PATH, lifecycleSegments
accordingly.

In `@packages/dropbox/src/resources.ts`:
- Around line 15-24: The pathPattern regexes for the 'files' and 'folders'
resources are too broad and match auxiliary paths like _index.json and by-id/*;
update the pathPattern entries (for the resources defined alongside name:
'files' and name: 'folders') to only match a single filename segment ending in
.json (or explicitly exclude auxiliary prefixes) so they don't capture nested
paths or reserved filenames, and keep findResourceByPath behavior correct;
adjust the patterns accordingly (e.g., require no additional slashes after
/dropbox/files/ or use a negative lookahead to exclude _index.json, by-id/,
by-path/) and verify the idPattern use remains unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c3508453-e150-4253-bf14-acc3f6c9946f

📥 Commits

Reviewing files that changed from the base of the PR and between 6603718 and a6d0fa5.

📒 Files selected for processing (15)
  • packages/dropbox/discovery/dropbox/folders/.create.example.json
  • packages/dropbox/discovery/dropbox/folders/.schema.json
  • packages/dropbox/discovery/dropbox/shared-folders/.create.example.json
  • packages/dropbox/discovery/dropbox/shared-folders/.schema.json
  • packages/dropbox/discovery/dropbox/shared-links/.create.example.json
  • packages/dropbox/discovery/dropbox/shared-links/.schema.json
  • packages/dropbox/package.json
  • packages/dropbox/src/digest.test.ts
  • packages/dropbox/src/digest.ts
  • packages/dropbox/src/emit-auxiliary-files.ts
  • packages/dropbox/src/index.ts
  • packages/dropbox/src/layout-prompt.ts
  • packages/dropbox/src/path-mapper.ts
  • packages/dropbox/src/resources.ts
  • packages/dropbox/src/webhook-normalizer.ts

Comment thread packages/dropbox/src/emit-auxiliary-files.ts
Comment thread packages/dropbox/src/emit-auxiliary-files.ts
Comment thread packages/dropbox/src/emit-auxiliary-files.ts
Comment thread packages/dropbox/src/layout-prompt.ts
Comment thread packages/dropbox/src/path-mapper.ts Outdated
Comment thread packages/dropbox/src/path-mapper.ts Outdated
Comment thread packages/dropbox/src/resources.ts Outdated
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

13 issues found across 15 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="packages/dropbox/src/path-mapper.ts">

<violation number="1" location="packages/dropbox/src/path-mapper.ts:4">
P1: This changes object path shape in a breaking way (removes account scope) without a compatibility path.</violation>
</file>

<file name="packages/dropbox/package.json">

<violation number="1" location="packages/dropbox/package.json:3">
P2: Do not bump the package version in this feature PR; versioning is handled by the publish workflow.</violation>
</file>

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread packages/dropbox/src/path-mapper.ts
Comment thread packages/dropbox/src/path-mapper.ts Outdated
Comment thread packages/dropbox/src/emit-auxiliary-files.ts
Comment thread packages/dropbox/src/resources.ts Outdated
Comment thread packages/dropbox/src/resources.ts Outdated
Comment thread packages/dropbox/src/emit-auxiliary-files.ts
Comment thread packages/dropbox/src/emit-auxiliary-files.ts
Comment thread packages/dropbox/src/path-mapper.ts Outdated
Comment thread packages/dropbox/src/path-mapper.ts Outdated
Comment thread packages/dropbox/src/resources.ts Outdated
@khaliqgant
Copy link
Copy Markdown
Member Author

Addressed review feedback in commit a23e857:

  • Replaced hardcoded "/dropbox/_index.json" with dropboxRootIndexPath() helper.
  • Added stale alias cleanup for file/folder by-path aliases on rename/move and delete fallback using prior indexed pathLower.
  • Hardened index reads: read/parse failures now surface an error and skip index rewrite (prevents destructive overwrite from empty fallback).
  • Updated canonical file/folder paths to flat <slug>__<id>.json leaves and routed computeDropboxPath through these helpers.
  • Fixed parseRelayfilePath to strip .json only from the terminal segment and to require an extra trailing segment for lifecycle IDs.
  • Tightened resources file/folder regexes to exclude auxiliary paths and added explicit shared by-id matching.
  • Added shared-folder (shared_folder_id) and shared-link (url hash fallback) id handling in auxiliary emission.
  • Reverted manual package version bump (0.2.4 -> 0.2.3) per publish workflow policy.
  • Added focused tests for path mapping, auxiliary emission regressions, layout prompt coverage, and resource path matching.

Validation run in this branch:

  • npm test --workspace=packages/dropbox
  • npm run typecheck --workspace=packages/dropbox
  • npm run build --workspace=packages/dropbox

All passing locally.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

♻️ Duplicate comments (2)
packages/dropbox/src/path-mapper.ts (1)

92-98: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Keep shared-folder and shared-link records on the canonical flat-record format.

These helpers still emit <id>.json, while the rest of the Dropbox flat records now use <slug>__<id>.json. That leaves shared-folders and shared-links outside the repository path contract. Thread name through here and reuse stableLeafName(...) for both resource types.

As per coding guidelines, Flat records (entities with no sub-artifacts) must use <slug>__<id>.json at a canonical resource directory.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/dropbox/src/path-mapper.ts` around lines 92 - 98, The
dropboxSharedFolderPath and dropboxSharedLinkPath helpers must produce canonical
flat-record filenames using stableLeafName, so update both functions to accept
the resource name (thread/name) in addition to the id (e.g.,
dropboxSharedFolderPath(name: string, sharedFolderId: string) and
dropboxSharedLinkPath(name: string, sharedLinkId: string)), call
stableLeafName(name, id) to build the filename (instead of `<id>.json`), and
return `${DROPBOX_PATH_ROOT}/shared-folders/${stableLeafName(...)}.json` and
`${DROPBOX_PATH_ROOT}/shared-links/${stableLeafName(...)}.json`; remove or stop
relying on encodePathSegment for the final leaf since stableLeafName handles
canonicalization.
packages/dropbox/src/resources.ts (1)

31-39: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Exclude shared _index.json files from canonical resource matching.

The direct-segment arm still matches _index.json, so findResourceByPath('/dropbox/shared-folders/_index.json') and the shared-links equivalent resolve as writeback resources instead of auxiliary indices.

Suggested regex tightening
-    pathPattern: /^\/dropbox\/shared-folders\/(?:[^/]+|by-id\/[^/]+)\.json$/,
+    pathPattern: /^\/dropbox\/shared-folders\/(?:(?!_index\.json$)[^/]+|by-id\/[^/]+)\.json$/,
@@
-    pathPattern: /^\/dropbox\/shared-links\/(?:[^/]+|by-id\/[^/]+)\.json$/,
+    pathPattern: /^\/dropbox\/shared-links\/(?:(?!_index\.json$)[^/]+|by-id\/[^/]+)\.json$/,

Also applies to: 46-47

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/dropbox/src/resources.ts` around lines 31 - 39, The pathPattern for
shared-folders and shared-links currently matches `_index.json`; update those
regexes (the pathPattern entries for the resources named 'shared-folders' and
'shared-links') to exclude `_index.json` by adding a negative lookahead for the
direct segment (and the by-id segment) — e.g. replace the `[^/]+` segments with
`(?!_index)[^/]+` (and the `by-id\/[^/]+` with `by-id\/(?!_index)[^/]+`) so
`findResourceByPath('/dropbox/.../_index.json')` no longer resolves as a
writeback resource.
🤖 Prompt for all review comments with AI agents
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 `@packages/dropbox/src/__tests__/emit-auxiliary-files.test.ts`:
- Around line 59-178: Add deterministic collision tests for both alias subtrees:
one test that verifies emitDropboxAuxiliaryFiles handles a by-id collision
(e.g., when a new write would overwrite an existing by-id alias path) and one
for a by-path collision (e.g., conflicting pathLower alias); use createClient to
seed the index and existing alias writes/deletes, call emitDropboxAuxiliaryFiles
with the conflicting input, and assert errors include the specific alias path
and that no unsafe overwrite occurred. Reference emitDropboxAuxiliaryFiles and
the alias helpers dropboxFileByIdAliasPath, dropboxFolderByIdAliasPath,
dropboxFileByPathAliasPath, and dropboxFolderByPathAliasPath to locate where to
assert collision behavior. Ensure each alias subtree (by-id and by-path) has at
least one deterministic test in this file following the existing test patterns.

In `@packages/dropbox/src/__tests__/path-mapper.test.ts`:
- Around line 13-67: The tests currently assert individual outputs but must also
verify full compose->parse->equality round-trips for each mapper helper; add
tests that call each composer (dropboxFilePath, dropboxFolderPath,
computeDropboxPath, toObjectRelayfilePath) to produce a path, then feed that
path into parseRelayfilePath and assert the parsed result reconstructs the
original identifying pieces (resource, id, objectType/name/path segments as
applicable) so the composed path round-trips back to the same logical identity;
ensure you add cases for files, folders, shared-folders, lifecycle entries, and
the computeDropboxPath stability case so each helper has a corresponding
compose→parse→equality assertion.

In `@packages/dropbox/src/path-mapper.ts`:
- Around line 171-188: The branch logic uses objectType checks that only match
hyphenated forms, causing values like "DropboxSharedFolder", "sharedfolder",
"sharedlink" to fall through; normalize objectType before routing (reuse the
same normalization used by toObjectRelayfilePath or add a small helper) so that
variants become the hyphenated canonical forms ("shared-folder", "shared-link")
or pass the already-normalized value from toObjectRelayfilePath into this
switch; update the checks around the objectType variable and calls to
computeDropboxPath to use the normalized value (refer to objectType,
computeDropboxPath and toObjectRelayfilePath in the diff).

---

Duplicate comments:
In `@packages/dropbox/src/path-mapper.ts`:
- Around line 92-98: The dropboxSharedFolderPath and dropboxSharedLinkPath
helpers must produce canonical flat-record filenames using stableLeafName, so
update both functions to accept the resource name (thread/name) in addition to
the id (e.g., dropboxSharedFolderPath(name: string, sharedFolderId: string) and
dropboxSharedLinkPath(name: string, sharedLinkId: string)), call
stableLeafName(name, id) to build the filename (instead of `<id>.json`), and
return `${DROPBOX_PATH_ROOT}/shared-folders/${stableLeafName(...)}.json` and
`${DROPBOX_PATH_ROOT}/shared-links/${stableLeafName(...)}.json`; remove or stop
relying on encodePathSegment for the final leaf since stableLeafName handles
canonicalization.

In `@packages/dropbox/src/resources.ts`:
- Around line 31-39: The pathPattern for shared-folders and shared-links
currently matches `_index.json`; update those regexes (the pathPattern entries
for the resources named 'shared-folders' and 'shared-links') to exclude
`_index.json` by adding a negative lookahead for the direct segment (and the
by-id segment) — e.g. replace the `[^/]+` segments with `(?!_index)[^/]+` (and
the `by-id\/[^/]+` with `by-id\/(?!_index)[^/]+`) so
`findResourceByPath('/dropbox/.../_index.json')` no longer resolves as a
writeback resource.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: a90f2a09-5df9-425f-b131-3548695eb390

📥 Commits

Reviewing files that changed from the base of the PR and between a6d0fa5 and a23e857.

📒 Files selected for processing (9)
  • packages/dropbox/package.json
  • packages/dropbox/src/__tests__/emit-auxiliary-files.test.ts
  • packages/dropbox/src/__tests__/layout-prompt.test.ts
  • packages/dropbox/src/__tests__/path-mapper.test.ts
  • packages/dropbox/src/__tests__/resources.test.ts
  • packages/dropbox/src/emit-auxiliary-files.ts
  • packages/dropbox/src/layout-prompt.ts
  • packages/dropbox/src/path-mapper.ts
  • packages/dropbox/src/resources.ts
✅ Files skipped from review due to trivial changes (1)
  • packages/dropbox/src/layout-prompt.ts

Comment thread packages/dropbox/src/__tests__/emit-auxiliary-files.test.ts
Comment thread packages/dropbox/src/__tests__/path-mapper.test.ts
Comment thread packages/dropbox/src/path-mapper.ts Outdated
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

2 issues found across 9 files (changes from recent commits).

Reply with feedback, questions, or to request a fix.

Re-trigger cubic

Comment thread packages/dropbox/src/path-mapper.ts
Comment thread packages/dropbox/src/path-mapper.ts Outdated
@khaliqgant
Copy link
Copy Markdown
Member Author

Addressed the newly raised feedback in commit be673ad:\n\n- Normalized Dropbox object type routing in / so non-hyphen forms like and map correctly.\n- Added explicit compose→parse round-trip assertions for mapper helpers (, , , ) including shared-folder/shared-link and lifecycle cases.\n- Added deterministic alias collision tests in for both and write-failure paths, asserting error surfacing and no unsafe overwrite.\n- Added backward-compat coverage for legacy path-like helper inputs.\n\nValidation rerun:\n- \n- \n- \n\nAll passed locally.

@khaliqgant
Copy link
Copy Markdown
Member Author

Addressed the newly raised feedback in commit be673ad:

  • Normalized Dropbox object type routing in toObjectRelayfilePath/computeDropboxPath so non-hyphen forms like DropboxSharedFolder and sharedlink map correctly.
  • Added explicit compose→parse round-trip assertions for mapper helpers (dropboxFilePath, dropboxFolderPath, computeDropboxPath, toObjectRelayfilePath) including shared-folder/shared-link and lifecycle cases.
  • Added deterministic alias collision tests in emit-auxiliary-files.test.ts for both by-id and by-path write-failure paths, asserting error surfacing and no unsafe overwrite.
  • Added backward-compat coverage for legacy path-like helper inputs.

Validation rerun:

  • npm test --workspace=packages/dropbox
  • npm run typecheck --workspace=packages/dropbox
  • npm run build --workspace=packages/dropbox

All passed locally.

@khaliqgant
Copy link
Copy Markdown
Member Author

Follow-up pass for remaining unresolved feedback landed in commit 755e51a:

  • Added a compatibility path for account-scoped legacy object mapping in toObjectRelayfilePath when callers still pass accountId/account with path-like inputs and no explicit objectType/model.
  • Added LEGACY_OBJECT_RESOURCE_PATH export constant to preserve the historical account-scoped contract surface for external callers.
  • Tightened shared resource regexes to exclude _index.json from writeback resource matching.
  • Extended tests for legacy account-scoped path behavior and shared-resource _index exclusions.

Validation rerun:

  • npm test --workspace=packages/dropbox
  • npm run typecheck --workspace=packages/dropbox
  • npm run build --workspace=packages/dropbox

All passed locally.

Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 5 files (changes from recent commits).

Tip: Review your code locally with the cubic CLI to iterate faster.

Re-trigger cubic

Comment thread packages/dropbox/src/path-mapper.ts Outdated
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
packages/dropbox/src/__tests__/resources.test.ts (1)

16-27: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Update shared canonical-path assertions to the slug+id format.

This test still treats /dropbox/shared-folders/<id>.json as canonical. Given the canonical filename contract is <slug>__<id>.json, this can preserve/validate the wrong behavior and miss regressions on current path mapping.

Suggested test adjustment
 test('dropbox shared resources match canonical and by-id alias paths', () => {
-  assert.equal(findResourceByPath('/dropbox/shared-folders/845281924.json')?.name, 'shared-folders');
+  assert.equal(
+    findResourceByPath('/dropbox/shared-folders/finance-team__845281924.json')?.name,
+    'shared-folders',
+  );
+  assert.equal(
+    findResourceByPath('/dropbox/shared-links/project-plan__url_1234567890abcdef.json')?.name,
+    'shared-links',
+  );
   assert.equal(
     findResourceByPath('/dropbox/shared-folders/by-id/845281924.json')?.name,
     'shared-folders',
   );

As per coding guidelines, “Flat records (entities with no sub-artifacts) must use <slug>__<id>.json at a canonical resource directory.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/dropbox/src/__tests__/resources.test.ts` around lines 16 - 27, The
test "dropbox shared resources match canonical and by-id alias paths" wrongly
assumes canonical filenames like '/dropbox/shared-folders/845281924.json';
update assertions to use the slug__id canonical format (e.g.
'/dropbox/shared-folders/shared-folders__845281924.json') and similarly for
shared-links (e.g. 'shared-links__url_1234567890abcdef.json'), while still
checking the by-id alias paths with '/by-id/<id>.json' via findResourceByPath;
modify the expectations in the test block that calls findResourceByPath (and
keep the checks for _index.json returning undefined) so they validate canonical
slug__id filenames instead of bare id filenames, referencing the existing
findResourceByPath helper and the test name to locate the changes.
🧹 Nitpick comments (3)
packages/dropbox/src/path-mapper.ts (2)

198-204: 💤 Low value

Redundant branching—all paths call the same function with identical arguments.

Lines 198-204 have three conditional branches that all call computeDropboxPath(objectType, objectId, { path, name }). Since computeDropboxPath already handles type routing internally, the branching here adds no value and can be collapsed.

Suggested simplification
-  if (objectType === 'folder') {
-    return computeDropboxPath(objectType, objectId, { path, name });
-  }
-  if (objectType === 'shared-folder' || objectType === 'shared-link') {
-    return computeDropboxPath(objectType, objectId, { path, name });
-  }
-  return computeDropboxPath(objectType, objectId, { path, name });
+  return computeDropboxPath(objectType, objectId, { path, name });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/dropbox/src/path-mapper.ts` around lines 198 - 204, The three
conditional branches that call computeDropboxPath(objectType, objectId, { path,
name }) are redundant; remove the if/else blocks and replace them with a single
direct call to computeDropboxPath using the existing variables (objectType,
objectId, path, name), since computeDropboxPath already handles routing by type
and the extra branching adds no value.

254-269: ⚡ Quick win

Overly permissive fallback matching in type normalization.

The conditions normalized.includes('shared') && normalized.includes('folder') and normalized.includes('shared') && normalized.includes('link') are very loose. Strings like "unshared-folder-info", "shared-not-a-link", or "folder-shared-with" would incorrectly match. Consider restricting to known variations or removing the catch-all fallbacks.

Suggested tightening
   if (
     normalized === 'shared-folder' ||
     normalized === 'sharedfolder' ||
-    normalized === 'dropboxsharedfolder' ||
-    (normalized.includes('shared') && normalized.includes('folder'))
+    normalized === 'dropboxsharedfolder'
   ) {
     return 'shared-folder';
   }
   if (
     normalized === 'shared-link' ||
     normalized === 'sharedlink' ||
-    normalized === 'dropboxsharedlink' ||
-    (normalized.includes('shared') && normalized.includes('link'))
+    normalized === 'dropboxsharedlink'
   ) {
     return 'shared-link';
   }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/dropbox/src/path-mapper.ts` around lines 254 - 269, The loose
fallback checks using normalized.includes('shared') &&
normalized.includes('folder') (and similarly for 'link') will mis-classify many
strings; replace those broad includes with a whitelist or precise word-boundary
regexes that only match intended variants. Update the conditional blocks that
inspect the normalized variable (the two if blocks returning 'shared-folder' and
'shared-link') to either check against an explicit array of allowed alternatives
(e.g.,
['shared-folder','sharedfolder','dropboxsharedfolder','dropbox-shared-folder'])
or use /\b(shared|dropboxshared|sharedfolder)([-_]?(folder))\b/ and a
corresponding regex for link so only legitimate forms match. Ensure you apply
the same tightening to both the folder and link branches and remove the generic
includes-based fallback.
packages/dropbox/src/resources.ts (1)

31-31: ⚡ Quick win

Inconsistent by-id alias handling between resource types.

The files and folders patterns (Lines 15, 23) use [^/]+ which correctly excludes by-id/ and by-path/ alias paths from matching as writeback resources. However, shared-folders and shared-links explicitly include by-id\/... as an alternative, meaning /dropbox/shared-folders/by-id/foo.json will match as a valid writeback resource.

If auxiliary alias paths should not be writeback targets (consistent with the fix applied to files/folders), align the shared resource patterns:

Suggested fix to exclude by-id aliases
   {
     name: 'shared-folders',
     path: '/dropbox/shared-folders',
-    pathPattern: /^\/dropbox\/shared-folders\/(?:(?!_index\.json$)[^/]+|by-id\/(?!_index\.json$)[^/]+)\.json$/,
+    pathPattern: /^\/dropbox\/shared-folders\/(?!_index\.json$)[^/]+\.json$/,
     idPattern: /^[A-Za-z0-9_.:`@-`]+$/,
     schema: 'discovery/dropbox/shared-folders/.schema.json',
     createExample: 'discovery/dropbox/shared-folders/.create.example.json',
   },
   {
     name: 'shared-links',
     path: '/dropbox/shared-links',
-    pathPattern: /^\/dropbox\/shared-links\/(?:(?!_index\.json$)[^/]+|by-id\/(?!_index\.json$)[^/]+)\.json$/,
+    pathPattern: /^\/dropbox\/shared-links\/(?!_index\.json$)[^/]+\.json$/,
     idPattern: /^[A-Za-z0-9_.:`@-`]+$/,
     schema: 'discovery/dropbox/shared-links/.schema.json',
     createExample: 'discovery/dropbox/shared-links/.create.example.json',
   },

Also applies to: 39-39

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/dropbox/src/resources.ts` at line 31, The shared resource
pathPattern for shared-folders/shared-links currently allows the explicit
"by-id/..." alternative so paths like /dropbox/shared-folders/by-id/foo.json
match; change the regex to match the same style as files/folders by removing the
"by-id\/(?!_index\.json$)[^/]+" alternative (or otherwise ensure the segment
rejects "by-id" and "by-path" prefixes) so that shared-folders and shared-links
use the same exclusion logic as files and folders; update the pathPattern for
shared-folders and shared-links to use the single-segment form (e.g., the same
(?:(?!_index\.json$)[^/]+) approach) so alias paths are not treated as writeback
targets.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@packages/dropbox/src/__tests__/resources.test.ts`:
- Around line 16-27: The test "dropbox shared resources match canonical and
by-id alias paths" wrongly assumes canonical filenames like
'/dropbox/shared-folders/845281924.json'; update assertions to use the slug__id
canonical format (e.g. '/dropbox/shared-folders/shared-folders__845281924.json')
and similarly for shared-links (e.g. 'shared-links__url_1234567890abcdef.json'),
while still checking the by-id alias paths with '/by-id/<id>.json' via
findResourceByPath; modify the expectations in the test block that calls
findResourceByPath (and keep the checks for _index.json returning undefined) so
they validate canonical slug__id filenames instead of bare id filenames,
referencing the existing findResourceByPath helper and the test name to locate
the changes.

---

Nitpick comments:
In `@packages/dropbox/src/path-mapper.ts`:
- Around line 198-204: The three conditional branches that call
computeDropboxPath(objectType, objectId, { path, name }) are redundant; remove
the if/else blocks and replace them with a single direct call to
computeDropboxPath using the existing variables (objectType, objectId, path,
name), since computeDropboxPath already handles routing by type and the extra
branching adds no value.
- Around line 254-269: The loose fallback checks using
normalized.includes('shared') && normalized.includes('folder') (and similarly
for 'link') will mis-classify many strings; replace those broad includes with a
whitelist or precise word-boundary regexes that only match intended variants.
Update the conditional blocks that inspect the normalized variable (the two if
blocks returning 'shared-folder' and 'shared-link') to either check against an
explicit array of allowed alternatives (e.g.,
['shared-folder','sharedfolder','dropboxsharedfolder','dropbox-shared-folder'])
or use /\b(shared|dropboxshared|sharedfolder)([-_]?(folder))\b/ and a
corresponding regex for link so only legitimate forms match. Ensure you apply
the same tightening to both the folder and link branches and remove the generic
includes-based fallback.

In `@packages/dropbox/src/resources.ts`:
- Line 31: The shared resource pathPattern for shared-folders/shared-links
currently allows the explicit "by-id/..." alternative so paths like
/dropbox/shared-folders/by-id/foo.json match; change the regex to match the same
style as files/folders by removing the "by-id\/(?!_index\.json$)[^/]+"
alternative (or otherwise ensure the segment rejects "by-id" and "by-path"
prefixes) so that shared-folders and shared-links use the same exclusion logic
as files and folders; update the pathPattern for shared-folders and shared-links
to use the single-segment form (e.g., the same (?:(?!_index\.json$)[^/]+)
approach) so alias paths are not treated as writeback targets.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 95f1dc45-98ab-416a-a071-2ce460b71625

📥 Commits

Reviewing files that changed from the base of the PR and between a23e857 and 42407fc.

📒 Files selected for processing (7)
  • packages/dropbox/src/__tests__/emit-auxiliary-files.test.ts
  • packages/dropbox/src/__tests__/path-mapper.test.ts
  • packages/dropbox/src/__tests__/resources.test.ts
  • packages/dropbox/src/emit-auxiliary-files.ts
  • packages/dropbox/src/layout-prompt.ts
  • packages/dropbox/src/path-mapper.ts
  • packages/dropbox/src/resources.ts

@khaliqgant khaliqgant merged commit d8438ab into main May 26, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant