feat(d1): github org claim and repo-topic link repositories (2/5) - #13
Merged
Merged
Conversation
D1 adapters for GithubOrgClaimRepo and RepoTopicLinkRepo with tenant-scoped, parameterized SQL. upsert treats its teamId argument as authoritative and rejects a mismatched link with TenantMismatchError before writing. The in-memory fakes now match the adapters (case-insensitive org matching, same mismatch check).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Second PR of the
github-alertschain. It adds the D1 adapters behind the PR 1 ports. They are not wired into the composition root yet (that is PR 4), so there is no user-visible change.createD1GithubOrgClaimRepo:findTeamByOrgis the only intentional cross-team lookup.isClaimedByis tenant-scoped.createD1RepoTopicLinkRepo:get,upsert,removeandlistare all scoped byteam_id.upsertis a single atomicINSERT ... ON CONFLICT DO UPDATE, so re-linking moves a repo to the new topic.Size exception: about 920 lines. Production code is about 130 of them; the rest is tests, the updated fakes and the apply-progress notes.
Review
Full review with four lenses, since the diff is over 400 lines and concerns tenant isolation. No blockers. One critical finding was confirmed and fixed:
upsertignored its tenant-scopingteamIdargument and wrote underlink.teamId. This broke the "TeamId first" isolation rule the ports are built around, and the in-memory fake did the opposite, so domain tests could not catch it. Now the argument is authoritative, and a mismatch throwsTenantMismatchErrorbefore any write. Because this error is not listed in any command'serrorReplies, it surfaces as a 500 rather than a friendly reply.Warnings were also fixed:
remove.isClaimedBywas case-sensitive while D1 was not. A test now pins the D1 behavior.A scoped fix-delta validator approved the correction.
Test plan
npx vitest run: 260/260 passnpx tsc --noEmit: no errorsOperator
The org claim (
tasks.md6.3) is already done in production. The next operator step is the webhook secret, after PR 3.