Skip to content

refactor: read the profile a commit is from, for timelines, blocks and mutes - #1349

Merged
mnapoli merged 1 commit into
productionfrom
feat/commit-author-reads
Oct 31, 2026
Merged

mnapoli merged 1 commit into
productionfrom
feat/commit-author-reads

Conversation

@mnapoli

@mnapoli mnapoli commented Oct 31, 2026 •

Copy link
Copy Markdown
Member

Summary

Important

Merge this only once #1346 is deployed, with every server and queue worker running it. Its migration fills author_id again 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 reading user_id. Everyone still posts as themselves, so nothing changes for people.

Changes

  • Migration, outside a transaction:
    • It fills author_id again, 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.
    • It then builds the author_id indexes behind a profile's timelines and threads, concurrently, and drops the user_id ones they replace.
    • Each index is dropped first if it exists, so the migration can run again if a deploy stops halfway. (user_id, created_at) stays for lookups by poster.
  • What reads the author:
    • User::commits(), so profile tabs, the pinned commit, counts, levels, streaks, achievements, the export and deletion all count what the user posted as themselves;
    • the Following log and Trending (author diversity, network boost);
    • blocks and mutes;
    • a thread's continuation and its hot score;
    • follow and mention suggestions;
    • the sitemap, first-commit notifications, "addressed to" and the API's reply participants;
    • the operations breakdowns by author.
  • What keeps reading the poster:
    • seeing your own pending commits;
    • moderation verdicts;
    • the "new commits" pill;
    • translations of your own commits;
    • the people metrics (active users, retention, volumes).

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).
  • New tests where a commit's author isn't who posted it, an organization: blocks and mutes act on the author, the poster still sees their pending commit, and a user's profile lists only what they posted as themselves.
  • The migration on a database recreating today's state: the indexes swapped with none left invalid, and running it again over a migrated database works.

No UI change, so no device check or screenshots.

Independent review

CODE: PASS from a separate read-only review on d6decf67 (base 2c513900). Its queries are the ones the reviewer passed earlier, when they were part of #1346, apart from DeleteUser: 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_id choice 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 writes author_id, and the refill catches anything older.

Limitations

  • While the old code serves during the deploy, it reads timelines through the user_id indexes this drops, for those few seconds.
Decisions for organization commits (#938), made before building
  • Who can post as an organization? Admins and members: anyone listed on the org's dev/null page. The list admins manage is the permission, with no new setting.
  • What do readers see? Only the organization, like a brand account. The person who posted is recorded for moderation and accountability.
  • What can an organization do? Post top-level commits, reply, quote and schedule commits as the org. Starring as the org comes later (below).
  • How does a member post as the org? With a "Post as" picker in the composer (themselves, or each org they can post for), defaulting to themselves.
  • Who is notified of replies, stars, quotes and mentions of the org and its commits? All its admins and members, in their own notifications.
  • Who can delete an org commit? Any admin or member.
  • Where do members see who posted an org commit? Nowhere in v1: it's stored, not shown.
  • What does moderation act on? The poster's account: timeouts and bans hit the person, which also stops them posting as the org. No org-level ban in v1.
  • Starring as the org? Later: members star as themselves for now. Stars are keyed on users and feed levels, pasteis and notifications, so it's a project of its own.
  • Do blocks and mutes apply to org commits? No: blocking or muting the person who posted doesn't hide the org's commits, as that would reveal who posted. Orgs can't be muted in v1; you unfollow them.
  • API? It follows the internal model, built for the long term: breaking changes are fine.
  • How is the author stored? Each commit's author_id points to the profile it's from, a person or an organization, and user_id stays 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 more organization_* column per feature) and a polymorphic author (no foreign key).
  • Naming? author_id + user_id, like stars.user_id and scheduled_commits.user_id for the account that did it.
  • What does the picker look like? The composer's avatar becomes the switcher for members of an org; picking the org swaps in its square avatar. Nothing changes for people in no org.
  • Does it remember the last choice? No: every commit and reply starts as yourself, so posting as the org is always deliberate.
  • How is it split? Stacked PRs, each reviewable and deployable on its own.

Settled while planning, and accepted:

  • Org commits live at /@laravel/commits/{id}, and the org page gets a Commits tab, first and the default, before Mentions.
  • Approval follows the poster's reputation, as for their own commits.
  • A scheduled org commit is canceled if its poster has left the org by then.
  • For the org's members, an org commit counts as their own: they can delete it, and can't star, report, vote in or give pasteis to it.
  • Org commits have no pasteis, and don't count toward the poster's levels, streaks or achievements.
  • When GitHub deletes an org, its commits are erased like a deleted account's. A poster who deletes their account only unlinks from the org commits they posted.
  • No first-commit notification for orgs, no posting as an org from the CLI, no RSS feed for orgs yet.
  • The stack has four layers, so each stays reviewable: profile ids, commit authors, the author in the props and the API, then posting as an org.

Summary by CodeRabbit

  • Bug Fixes
    • Commit timelines, profiles, feeds, suggestions, and activity summaries now reflect who authored a commit, including commits posted on behalf of someone else.
    • Blocking, muting, reply participation, engagement counts, and commit visibility now distinguish the author from the account that posted a commit.
    • Commit notifications, exports, pinned commits, and achievement checks now use the author when determining eligibility.

@mnapoli
mnapoli added this pull request to stack #1350 October 31, 2026 17:50
@coderabbitai

coderabbitai Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review.

Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2dedea06-c096-4f39-bc57-712a718675bf
Commits

Reviewing files that changed from the base of the PR and between 90bafd6 and 3b19dba.

Files selected for processing: 27
  • app/Actions/CreateCommit.php
  • app/Actions/CreateExport.php
  • app/Actions/CreateFirstCommitNotifications.php
  • app/Actions/CreateTomFriendship.php
  • app/Actions/CreateWorldReply.php
  • app/Actions/DeleteUser.php
  • app/Actions/UpdateCommitHotScores.php
  • app/Http/Controllers/Api/CommitController.php
  • app/Models/Commit.php
  • app/Models/User.php
  • app/Queries/ActivityBreakdownsQuery.php
  • app/Queries/CommitBuilder.php
  • app/Queries/CommitContinuationQuery.php
  • app/Queries/LogQueries/FollowingLogQuery.php
  • app/Queries/MentionSuggestionsQuery.php
  • app/Queries/OperationsEventsQuery.php
  • app/Queries/PinnedCommitQuery.php
  • app/Queries/SitemapQuery.php
  • app/Queries/SuggestedCommitsQuery.php
  • app/Queries/SuggestedUsersQuery.php
  • app/Queries/UserAchievementsQuery.php
  • app/Queries/UserCommitsQuery.php
  • app/Services/TheAlgorithm.php
  • database/migrations/2026_10_31_165000_move_commit_timelines_to_author_id.php
  • tests/Unit/Actions/UpdateOrCreateUserTest.php
  • tests/Unit/Queries/CommitBuilderTest.php
  • tests/Unit/Queries/UserCommitsQueryTest.php

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

Walkthrough

The PR migrates commit author-related reads from user_id to author_id and adds a migration that backfills missing author IDs and updates indexes. Commit creation continues to set user_id for the posting account.

Changes: Commit author identity

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: Passed 5
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed 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 a…
Docstring Coverage Passed 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. Documentati…
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.
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

@mnapoli
mnapoli force-pushed the feat/commit-author-reads branch from 9d2b7ed to 3b19dba Compare October 31, 2026 19:54
@mnapoli
mnapoli marked this pull request as ready for review October 31, 2026 20:03
@mnapoli
mnapoli merged commit e98fc28 into production Oct 31, 2026
10 checks passed
@xHeaven xHeaven mentioned this pull request Oct 31, 2026
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