Repository navigation
refactor: read the profile a commit is from, for timelines, blocks and mutes - #1349
Conversation
|
No actionable comments were generated in the recent review.
|
| Layer / File(s) | Summary |
|---|---|
Backfill authors and update indexes database/migrations/* |
The migration fills missing author_id values from user_id in batches. It replaces user-based indexes with author-based indexes using concurrent index operations. |
Commit writes and author relationships app/Actions/CreateCommit.php, app/Actions/CreateTomFriendship.php, app/Actions/CreateWorldReply.php, app/Models/Commit.php, app/Models/User.php, tests/Unit/Actions/UpdateOrCreateUserTest.php |
Commit creation sets user_id for the posting account. The commit model and user relationship use author_id to identify the author. The bot-post test now supplies the bot’s user_id. |
Author-based visibility and thread queries app/Actions/DeleteUser.php, app/Http/Controllers/Api/CommitController.php, app/Queries/CommitBuilder.php, app/Queries/CommitContinuationQuery.php, app/Queries/LogQueries/FollowingLogQuery.php, app/Queries/MentionSuggestionsQuery.php, app/Queries/PinnedCommitQuery.php, app/Queries/UserCommitsQuery.php, tests/Unit/Queries/CommitBuilderTest.php, tests/Unit/Queries/UserCommitsQueryTest.php |
Visibility, thread continuation, participant suggestions, and user commit queries compare commit authors through author_id. Tests cover organization-authored commits. |
Engagement and recommendation queries app/Actions/UpdateCommitHotScores.php, app/Queries/SuggestedCommitsQuery.php, app/Queries/SuggestedUsersQuery.php, app/Queries/UserAchievementsQuery.php, app/Services/TheAlgorithm.php |
Engagement counts, ranking, and commit and user suggestions use author_id for commit authors. Star queries retain user_id and alias it as profile_id in hot-score calculations. |
Author-based profile outputs app/Actions/CreateExport.php, app/Actions/CreateFirstCommitNotifications.php, app/Queries/ActivityBreakdownsQuery.php, app/Queries/OperationsEventsQuery.php, app/Queries/SitemapQuery.php |
Export, first-commit notification, activity, operations event, and sitemap queries resolve commit authors through author_id. |
Estimated code review effort: 3 (Moderate) | ~25 minutes
Change: Feature
Possibly related issues
- [RFC] Orgs #938: The issue describes organization profiles and organization-authored commits. This PR updates commit author queries and indexes, including tests for organization-authored commits.
Suggested reviewers: xheaven, nunomaduro, mrpunyapal
Merge Risk: 
Minimal · up to 3b19d
-
Author-based reads are ready to merge. Deploy the preceding writer change to all servers and workers before running the backfill.
Security architecture risk: 
Moderate · up to 3b19d
-
Separating the public author from the posting account affects blocking and data ownership. Current writers preserve both identities, but safe deployment also depends on completing the backfill before the new readers serve traffic. That ordering is not established here.
Retained concerns
- Medium · security · inferred: If author-based readers serve before the backfill finishes, approved legacy commits with author_id null and user_id populated bypass the new block and mute predicates. Authenticated search can return their bodies without a subsequent model visibility check. The base excludes these rows using the poster identity. This is a conditional rollout concern, not verified production exposure; completing the backfill before reader activation prevents it.
Security review details
-
Security Blast Radius
- inferred — The conditional exposure spans approved, searchable legacy commits still awaiting attribution in the shared commits table and authenticated viewers whose block or mute would previously exclude their posters. The inspected path does not expose another account's pending commits or grant administrative authority.
Security Findings and Attack Paths
- inferred — During an unsafe reader-before-backfill rollout, an authenticated viewer can submit a relevant search term and receive a qualifying blocked or muted poster's approved commit. Search relies on the changed query predicates, and the API resource emits the body without reapplying model visibility. No evidence establishes that this rollout state occurred in production.
Trust Boundaries and Controls
- observed — Direct single-commit API authorization still invokes Commit::isVisibleTo, which checks posting-account ownership and poster-based blocks. This is counterevidence against a universal direct-object bypass, but that control is not reapplied by the inspected search collection response.
Resilience and Maintainability Implications
- inferred — For attributed commits, account deletion erases or anonymizes author-owned content within a transaction before deleting the user and profile. Retained tombstones have user_id cleared, and profile deletion clears author_id through the foreign key, so the backfill's non-null user_id condition does not reattribute those ordinary tombstones.
Hardening Proposals
- proposed — Make reader activation conditional on successful completion of the author backfill, in addition to requiring all prior-version servers and workers to write author_id. An interrupted migration should leave the prior readers active until recovery completes.
Pre-merge checks: 
5
-
Full details: Title check
-
Explanation
The title names the main change: commit reads now use author_id to find the profile a commit is from, for timelines, blocks and mutes. The raw summary shows that these reads (CommitBuilder visibleTo and withoutMutedAuthorsFor, UserCommitsQuery, FollowingLogQuery, the timeline indexes in the migration) changed from user_id to author_id, while poster-based behavior stayed on user_id. The title is a conventional refactor prefix with a specific, accurate description. It does not cover the migration, the thread scoring, or the API changes, which is expected for a title of this length.
Full details: Docstring Coverage
-
Explanation
Docstring coverage is 86.96% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 23 functions across 27 files.
-
Finishing Touches
-
Generate docstrings
-
- Commit to this branch
- Create a new PR
Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
d6decf6 to
9d2b7ed
Compare
9d2b7ed to
3b19dba
Compare
Summary
Important
Merge this only once #1346 is deployed, with every server and queue worker running it. Its migration fills
author_idagain for commits the older code posted, and that only catches them all if nothing posts without an author afterwards. Merged together, commits posted during the deploy would stay without one, and would skip blocks and their author's profile.Third layer of letting organizations post commits (#938), on top of #1346, which records each commit's author. Now everything about whose commit it is reads
author_id, the profile it's from, while what concerns who posted it keeps readinguser_id. Everyone still posts as themselves, so nothing changes for people.Changes
author_idagain, for the commits the old code posted during refactor: record the profile each commit is from, before anything reads it #1346's deploy. Every server running by then writes it, so afterwards only tombstones have none.author_idindexes behind a profile's timelines and threads,concurrently, and drops theuser_idones they replace.(user_id, created_at)stays for lookups by poster.User::commits(), so profile tabs, the pinned commit, counts, levels, streaks, achievements, the export and deletion all count what the user posted as themselves;Validation
All local, on Postgres 18 with pgvector (as CI):
php -d memory_limit=-1 vendor/bin/pest --parallel --ci --coverage --exactly=100.0 --passthru-php="'-d' 'memory_limit=-1'": 5198 passed, coverage 100.0%.composer test:lint,composer test:types(PHPStan 0 errors),composer test:type-coverage(100%),bun run test:unit(791 passed).No UI change, so no device check or screenshots.
Independent review
CODE: PASS from a separate read-only review on
d6decf67(base2c513900). Its queries are the ones the reviewer passed earlier, when they were part of #1346, apart fromDeleteUser: its tombstones keep their author until the account's profile is deleted later in the same transaction, which clears it.The reviewer checked every
user_id/author_idchoice against "the author is the public identity, the user is who posted". It also checked that this layer is safe while #1346's code still serves: that code writesauthor_id, and the refill catches anything older.Limitations
user_idindexes this drops, for those few seconds.Decisions for organization commits (#938), made before building
author_idpoints to the profile it's from, a person or an organization, anduser_idstays the account that posted it. Each person's profile takes their user's id, as organizations already share theirs, so profile ids cover everyone. A column that should later accept organizations, like who starred or whom someone follows, then only repoints its foreign key without rewriting data. We rejected two columns (user_id+organization_id, one moreorganization_*column per feature) and a polymorphic author (no foreign key).author_id+user_id, likestars.user_idandscheduled_commits.user_idfor the account that did it.Settled while planning, and accepted:
/@laravel/commits/{id}, and the org page gets a Commits tab, first and the default, before Mentions.Summary by CodeRabbit