Skip to content

fix(agents): carry live speaker roles per turn; stop scaffolding stale USER.md role - #3995

Merged
chubes4 merged 1 commit into
mainfrom
fix/issue-3994-live-speaker-roles
Nov 18, 2026
Merged

chubes4 merged 1 commit into
mainfrom
fix/issue-3994-live-speaker-roles

Conversation

@chubes4

@chubes4 chubes4 commented Nov 18, 2026

Copy link
Copy Markdown
Member

Fixes #3994

Summary

In a production chat, the agent called a promoted team member a "Contributor". The cause was a role snapshot written into USER.md at scaffold time that was never updated.

  • Live roles in the current-speaker section. ChatPersonResolver now resolves the speaker's roles on the current blog at turn time and adds their display names. It reads wp_roles()->role_names and passes each through translate_user_role(); an unregistered role slug falls back to the slug. Example: The current speaker is WordPress user ID 38 (roles on this site: Extra Chill Team, Editor). When the user has no roles on the site, the parenthetical is left out and the line stays The current speaker is WordPress user ID 38. The lookup is one get_userdata() call (object-cached) plus an in-memory roles table.
  • No more Role line in scaffolded USER.md.
    • datamachine_scaffold_user_content() (per-user scaffold) no longer writes - **Role:** <Ucfirst slug>.
    • datamachine_get_scaffold_defaults() (default scaffold) no longer writes - **Role:** Site Administrator. This line is a hardcoded role claim about whoever owns admin_email, and it goes stale the same way: the admin email can change, the user can be demoted, and the file can be read by an agent talking to someone else. Live roles now come from the speaker section, so this line was removed too.

Existing files

Existing USER.md files are user-owned memory, so they are not migrated. A stale - **Role:** … line in an existing file stays there, but the live speaker line now sits next to it and corrects it. To remove a stale line, delete the - **Role:** line from the user's USER.md. You can do this by editing the file in the agent memory directory, or through the memory CLI/abilities (wp datamachine memory --help).

Verification

  • php -l passes on all changed files.
  • homeboy review lint data-machine --placement local --changed-since origin/main: overall status passed (phpcs and eslint clean). PHPStan reported one finding, on the wp_date() line in scaffolding.php. That line is unchanged by this PR and its fingerprint is already in the component baseline.
  • homeboy review test data-machine --placement local --skip-lint -- --filter 'ChatPersonResolverTest|DefaultAgentBootstrapTest|ScaffoldAbilitiesTest' (WP Codebox, SQLite): PHPUnit OK (44 tests, 191 assertions), including the 3 new tests:
    • test_current_speaker_section_carries_live_role_display_names: checks the line shows Subscriber, then changes the user to editor + author and checks the next turn shows Editor, Author without any file edit.
    • test_current_speaker_section_omits_roles_when_user_has_none
    • test_scaffolded_user_md_has_no_role_snapshot: covers both the per-user and default scaffolds.
  • In the same run, one standalone smoke test failed: email-multi-inbox-forward-smoke.php, because it needs WordPress core for PHPMailer, which this environment doesn't provide. This PR doesn't touch that code.

AI-generated (Claude, Pi subagent). Finalized outside Homeboy by operator authorization: the lab runner was unavailable.

…e USER.md role

USER.md scaffolds wrote a one-time role snapshot (ucfirst slug) that went
stale when users were promoted. Drop the Role line from both the per-user
and default USER.md scaffolds, and have ChatPersonResolver append the
speaker's current role display names on the current site to the
current-speaker runtime section.

Fixes #3994
@chubes4
chubes4 merged commit 1d622e6 into main Nov 18, 2026
38 checks passed
@chubes4
chubes4 deleted the fix/issue-3994-live-speaker-roles branch November 18, 2026 04:53
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.

Agent identity: USER.md scaffolds a stale role snapshot; current-speaker context should carry live roles

1 participant