Skip to content

fix(github,linear): emit comments as directory records to prevent file/dir collisions - #165

Merged
khaliqgant merged 5 commits into
mainfrom
fix/comment-dir-records-github-linear
Jun 10, 2026
Merged

fix(github,linear): emit comments as directory records to prevent file/dir collisions#165
khaliqgant merged 5 commits into
mainfrom
fix/comment-dir-records-github-linear

Conversation

@khaliqgant

Copy link
Copy Markdown
Member

Summary

Backports the Slack thread-reply collision fix (dea03fc / f5ca1ce, PR #162) to the two adapters with the same latent pattern. Both emit comments as flat comments/{id}.json leaves; any future child resources nesting under comments/{id}/ (GitHub exposes per-comment reactions as a child collection; Linear has per-comment emoji reactions and threaded replies) would collide on POSIX mounts — the exact failure that broke Slack mirrors.

  • GitHub: canonical record is now issues/<n>__<slug>/comments/<id>/meta.json (githubIssueCommentPath + legacy/read-candidate helpers); ISSUE_COMMENT_WRITEBACK_PATH accepts both new and legacy forms so patches route for either mirror generation.
  • Linear: linearCommentPath/linear/comments/<name>__<id>/meta.json with legacy read candidates; delete tombstones target both forms. Writeback routes unchanged (create drafts live in the separate per-issue tree).
  • Legacy compat follows the exact Slack convention: read candidates return [current, legacy].
  • Discovery/catalog regenerated for the changed patterns; out-of-scope generator clobbers (dropbox/hubspot resources, linear agent-activities) reverted.
  • New docs/architecture/writeback-resource-patterns.md documents the collision risk + 7-step directory-record migration recipe for future adapter authors.

Tests

Collision regression tests in both adapters (directory-record path, child-nesting invariant, read-candidate fallback) + directory-record writeback patch test. Full repo green: 85 turbo test tasks (github 286, linear 131, slack 93), discovery verification, digest contracts, typecheck.

⚠️ Merge-order note: conflicts expected with #164 in scripts/writeback-discovery-data.mjs — merge one, regenerate, then merge the other.

🤖 Generated with Claude Code

…file/dir collision

A GitHub issue comment and a Linear comment were emitted as flat leaf files
(`issues/<n>__<slug>/comments/<id>.json`, `/linear/comments/<name>__<id>.json`)
— the same latent shape that wedged Slack mounts (dea03fc, f5ca1ce, PR #162):
once any child resource nests under the comment id (GitHub exposes per-comment
reactions at /repos/{o}/{r}/issues/comments/{id}/reactions; Linear has
per-comment emoji reactions — the webhook normalizer already recognizes
'reaction' payloads — and threaded replies), one name must be both a file and
a directory, which cannot be materialized on a POSIX mount
(`mkdir ... : not a directory`) and wedges the whole mirror.

Apply the Slack directory-record pattern to both adapters:

GitHub:
- `githubIssueCommentPath` → `comments/<id>/meta.json`; add
  `githubIssueCommentLegacyPath` + `githubIssueCommentReadCandidatePaths`
  (mirrors slack threadReplyPath / threadReplyLegacyPath /
  slackThreadReplyReadCandidatePaths).
- `mapIssueComment` and `computeScopedPath('issue_comment')` emit the
  directory record.
- `ISSUE_COMMENT_WRITEBACK_PATH` accepts both `<id>/meta.json` and the
  legacy `<id>.json`, so patches against either mirror generation route.
- Regenerated `resources.ts` / discovery `.adapter.md`: issue-comments
  pathPattern matches `/meta.json`, idPattern accepts the `meta` stem
  (handler re-derives the numeric id from the full path, like slack messages).
- LAYOUT.md prompt documents the comment directory record.

Linear:
- `linearCommentPath` → `/linear/comments/<name>__<id>/meta.json`; add
  `linearCommentLegacyPath` + `linearCommentReadCandidatePaths`.
- Comment delete tombstones target both the directory record and the legacy
  flat leaf so pre-migration mirrors are cleaned.
- Linear writeback needs no route change: comment create drafts live in the
  separate `/linear/issues/{issueId}/comments/` tree.
- LAYOUT.md prompt + discovery read-path docs updated.

Both: regression tests pinning the directory-record path, the child-nesting
invariant, and the read-candidate fallback order, mirroring the slack
collision tests. New docs/architecture/writeback-resource-patterns.md explains
the collision and the migration recipe so future adapters don't reintroduce
the flat-leaf shape.

Writeback-paths catalog: no regeneration needed — resource path templates are
unchanged (`writeback-paths check` clean).

Full repo suite green (85 turbo tasks); writeback discovery (82 endpoints),
digest contracts, and internal-dependency checks clean.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Jun 10, 2026

Copy link
Copy Markdown

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 54 minutes and 6 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: 985e6abd-3824-4c81-bdb3-0afad0b278cf

📥 Commits

Reviewing files that changed from the base of the PR and between 6bb9a5c and 1ece60b.

📒 Files selected for processing (46)
  • docs/PATH_SLUGIFICATION_SPEC.md
  • docs/architecture/writeback-resource-patterns.md
  • packages/core/src/runtime/file-native-router.test.ts
  • packages/core/src/writeback-paths/catalog.generated.json
  • packages/core/src/writeback-paths/catalog.generated.ts
  • packages/dropbox/discovery/dropbox/.adapter.md
  • 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/src/layout-prompt.ts
  • packages/dropbox/src/resources.ts
  • packages/github/discovery/github/.adapter.md
  • packages/github/docs/adapter-spec.md
  • packages/github/github.mapping.yaml
  • packages/github/src/__tests__/e2e-issue-ingest.test.ts
  • packages/github/src/__tests__/path-mapper.test.ts
  • packages/github/src/index.ts
  • packages/github/src/issues/__tests__/issue-mapping.test.ts
  • packages/github/src/issues/comment-mapper.test.ts
  • packages/github/src/issues/comment-mapper.ts
  • packages/github/src/layout-prompt.ts
  • packages/github/src/path-mapper.ts
  • packages/github/src/resources.ts
  • packages/github/src/webhook/__tests__/webhook-router.test.ts
  • packages/github/src/webhook/router.test.ts
  • packages/github/src/writeback.test.ts
  • packages/github/src/writeback.ts
  • packages/github/workflows/026-github-issue-mapping.ts
  • packages/hubspot/discovery/hubspot/.adapter.md
  • packages/hubspot/src/resources.ts
  • packages/linear/discovery/linear/.adapter.md
  • packages/linear/discovery/linear/agent-sessions/{sessionId}/activities/.create.example.json
  • packages/linear/discovery/linear/agent-sessions/{sessionId}/activities/.schema.json
  • packages/linear/src/__tests__/index-emission.test.ts
  • packages/linear/src/__tests__/linear-adapter.test.ts
  • packages/linear/src/__tests__/name-id-convention.test.ts
  • packages/linear/src/__tests__/path-mapper.test.ts
  • packages/linear/src/emit-auxiliary-files.ts
  • packages/linear/src/layout-prompt.ts
  • packages/linear/src/path-mapper.ts
  • scripts/writeback-discovery-data.mjs
  • scripts/writeback-discovery-normalizer.mjs
  • scripts/writeback-discovery-normalizer.test.mjs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/comment-dir-records-github-linear

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.

@agent-relay-code

Copy link
Copy Markdown
Contributor

Implemented fixes for the PR and downstream breakage I found.

Key fixes:

Addressed comments

  • gemini-code-assist[bot]: quota/status notice only; no actionable code finding to validate or change.
  • coderabbitai[bot]: review-limit/status notice only; no actionable code finding to validate or change.

Advisory Notes

None.

Verification

Local verification passed on the current working tree:

  • npx turbo build --concurrency=1
  • npx turbo typecheck --concurrency=1
  • npm run test:publish-targets
  • npm run test:internal-dependencies
  • npm run test:writeback-discovery
  • npm run test:digest-contracts
  • npx turbo test --concurrency=1

I’m not printing READY because external required checks after these edits are not observable from this harness.

@agent-relay-code

Copy link
Copy Markdown
Contributor

Implemented the scoped PR fixes I found.

Changes made:

Addressed comments

  • No bot/reviewer comment files or review-thread metadata were present in .workforce; only pr.diff, changed-files.txt, and context.json were available. I validated the current checkout directly and fixed the stale in-scope path-contract issues above.

Advisory Notes

None.

Local validation:

  • npm ci --prefer-offline --no-audit --no-fund passed after clearing npm cache from an initial ENOSPC failure.
  • Focused GitHub/Linear/core tests passed.
  • npm run test:writeback-discovery passed.
  • npm test passed end to end.
  • npx turbo build --concurrency=1 passed.
  • npx turbo typecheck --concurrency=1 passed.
  • The default parallel npm run build and npm run typecheck were killed with exit 137 in this sandbox; the constrained reruns completed successfully.
  • Conflict-marker scan found no <<<<<<<, =======, or >>>>>>> markers.

@agent-relay-code

Copy link
Copy Markdown
Contributor

Implemented fixes from the PR review and verified them locally.

Key fixes:

Addressed comments

  • No external bot/reviewer comments were present in .workforce/context.json; it only contained PR metadata. I validated the current checkout and fixed the demonstrated local failures instead.

Advisory Notes

  • Remote GitHub check status and mergeability were not available from the checked-out repo, and I did not use gh per instruction, so I am not printing READY.
  • The sandbox killed unconstrained parallel turbo runs with exit 137 earlier; the full repo build/typecheck/test tasks passed with --concurrency=1.

Verification passed:

  • npm run test:writeback-discovery
  • node packages/core/dist/src/cli.js writeback-paths check
  • npx turbo build --concurrency=1
  • npx turbo typecheck --concurrency=1
  • npx turbo test --concurrency=1 (85 successful, 85 total)

Hubspot Adapter Bot and others added 2 commits June 10, 2026 21:30
Incorporates dropbox folders/shared-folders/shared-links resources added
upstream plus updated github/linear comment dir-record path patterns.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@khaliqgant
khaliqgant merged commit cd542e4 into main Jun 10, 2026
3 checks passed
@khaliqgant
khaliqgant deleted the fix/comment-dir-records-github-linear branch June 10, 2026 19:49
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