Repository navigation
fix(agents): carry live speaker roles per turn; stop scaffolding stale USER.md role - #3995
Merged
Merged
Conversation
…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
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.
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.
ChatPersonResolvernow resolves the speaker's roles on the current blog at turn time and adds their display names. It readswp_roles()->role_namesand passes each throughtranslate_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 staysThe current speaker is WordPress user ID 38.The lookup is oneget_userdata()call (object-cached) plus an in-memory roles table.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 ownsadmin_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 -lpasses 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 thewp_date()line inscaffolding.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): PHPUnitOK (44 tests, 191 assertions), including the 3 new tests:test_current_speaker_section_carries_live_role_display_names: checks the line showsSubscriber, then changes the user to editor + author and checks the next turn showsEditor, Authorwithout any file edit.test_current_speaker_section_omits_roles_when_user_has_nonetest_scaffolded_user_md_has_no_role_snapshot: covers both the per-user and default scaffolds.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.