CL-6471: never leak a run id as a participant's name or greeting - #202
Merged
Merged
Conversation
deriveDisplayName/humanizeSlug (CL-6413) lived only in
@corbits/agent-directory, which already depends on @corbits/chat -- so
the chat participant invite/greeting path could never import them back
without a circular dependency. Move them here as the canonical
implementation; agent-directory re-exports them in the next commit.
id-leak-guard adds the systemic check CL-6471 calls for: no
user-visible string may carry an internal id (run_/wfd_/tnt_/prn_/ast_/
gtk_), in raw or humanized ("Run 737a058d...") form.
An invited agent's display name/mention handle came from the caller's pre-fetched listInvitableDefinitions() snapshot; when that snapshot missed the definition (a just-created or just-redeployed row it predates -- exactly the "fresh stack, instantiate a template" race the owner hit), launchAndJoinAgent silently fell back to the run's own address local part, and routes.ts's greeting resolution fell back to that same leaked handle. The result: a participant named "Run 737a058d48006e2bde12559576f422e0" and a greeting reading "I'm run_737a058d...". Both call sites now resolve through resolveInvitedDisplayName, which adds a live resolveDefinitionNameSource lookup as the platform-port fallback instead of ever degrading to a raw id, and derives the name via deriveDisplayName so the agent's own greeting states its real name. agent-directory/client.ts now re-exports deriveDisplayName/humanizeSlug from @corbits/chat/display-name rather than keeping its own copy.
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.
Root cause
Two symptoms, one source. Instantiating the code-review template on a fresh stack, the setup agent's participant record rendered as "Run 737a058d48006e2bde12559576f422e0" and its canned greeting read "I'm run_737a058d48006e2bde12559576f422e0. Three reviewers read every pull request..." (the template's own
promiseline,packages/workflow-catalog/src/templates.ts).Both trace to
packages/chat/src/workbench-service.ts'slaunchAndJoinAgent: the invited definition's display name came from the caller's pre-fetchedlistInvitableDefinitions()snapshot. When that snapshot missed the definition -- a just-created or just-redeployed row it predates, exactly the "fresh stack, instantiate a template" race -- the handle silently fell back tolocalPartOf(launched.address)(the run's own address).packages/chat/src/routes.ts's greeting resolution (agentDisplayName) had the identical fallback, feeding the same leaked value intocannedGreeting's"I'm ${agent}"template.Neither
deriveDisplayName/humanizeSlug(CL-6413, PR #158) reached this path because they lived in@corbits/agent-directory, which already depends on@corbits/chat-- a reverse import would have been circular.Fix
deriveDisplayName/humanizeSluginto@corbits/chat/display-name(the canonical home now);@corbits/agent-directory/client.tsre-exports them for its existing callers.WorkbenchLauncher.resolveDefinitionNameSource-- a live, authoritative lookupresolveInvitedDisplayNamefalls back to when theinvitablesnapshot misses, instead of ever degrading to a raw address/run id. BothlaunchAndJoinAgent's participant handle androutes.ts's greeting name now resolve through it (launchAndJoinAgentnow returnsdisplayNameso the greeting never re-derives it from a possibly-stale snapshot).packages/chat/src/id-leak-guard.ts):assertNoLeakedInternalIdmatchesrun_/wfd_/tnt_/prn_/ast_/gtk_in both raw and humanized ("Run 737a058d...") form, wired intoderiveDisplayNameandcannedGreetingso either throws loud rather than rendering a leaked id.Tests added
packages/chat/src/id-leak-guard.test.ts-- all six prefixes, raw and humanized forms, no false positives on ordinary prose ("Runner McRunface").packages/chat/src/display-name.test.ts--deriveDisplayNamethrows rather than humanizing a run id into a fake name.packages/chat/test/workbench-service.test.ts-- a definition missing from theinvitablesnapshot still resolves its real name via the live lookup (never"ins_invited1"); a definition unresolvable anywhere fails loud rather than leaking.packages/chat/test/routes.test.ts-- the exact CL-6471 scenario: definition missing from the snapshot still greets with its real name ("I'm Myra"), never the run's own address.Updated 7 pre-existing tests that had encoded the old fallback as expected behavior (a participant handle of
"ins_invited1", a greeting saying"I'm echo"instead of"I'm Echo").Scoped checks (green)
packages/chat:bun run typecheckclean,bun test-- 637 pass / 24 skip / 0 fail.packages/agent-directory:bun run typecheckclean,bun test-- 147 pass / 21 skip / 0 fail.prettier --check/eslintclean on every touched file.Live proof: PENDING
The machine hosting this session is memory-constrained (24GB, many concurrent lanes) and another lane currently holds the only available live-stack slot; the owner's own stack on
:3000was explicitly off-limits. Per the coordinator's instruction I verified statically (unit/component tests above) rather than booting a scratch stack, and did not merge this PR.To get live proof, on a machine with a free slot:
Then sign in with the seeded admin, create a workbench from the "Code review" template, and confirm: the three reviewer agents (and Myra) appear with their real names (never "Run ..."), and the opening greeting reads "I'm Myra. Three reviewers read every pull request..." (never "I'm run_...").
Fixes CL-6471.