Repository navigation
refactor(translate): register translators per agent - #139
Merged
Merged
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
This was referenced Oct 6, 2026
Stephen Belanger (Qard)
force-pushed
the
refactor/register-managed-run
branch
from
October 6, 2026 13:24
40a95f7 to
f264028
Compare
Stephen Belanger (Qard)
force-pushed
the
refactor/register-translators
branch
from
October 6, 2026 13:24
caadc9e to
4a46d82
Compare
Abhijeet Prasad (AbhiPrasad)
approved these changes
Oct 6, 2026
Stephen Belanger (Qard)
force-pushed
the
refactor/register-managed-run
branch
from
October 6, 2026 14:04
f264028 to
cd40bdb
Compare
Stephen Belanger (Qard)
force-pushed
the
refactor/register-translators
branch
from
October 6, 2026 14:04
4a46d82 to
6184632
Compare
Stephen Belanger (Qard)
force-pushed
the
refactor/register-managed-run
branch
from
October 6, 2026 14:48
cd40bdb to
2e38e1a
Compare
Stephen Belanger (Qard)
force-pushed
the
refactor/register-translators
branch
from
October 6, 2026 14:48
6184632 to
86eb942
Compare
Stephen Belanger (Qard)
force-pushed
the
refactor/register-managed-run
branch
from
October 6, 2026 15:03
2e38e1a to
f20a120
Compare
Stephen Belanger (Qard)
force-pushed
the
refactor/register-translators
branch
from
October 6, 2026 15:03
86eb942 to
b6fe0b1
Compare
Registry::default_agents constructed each agent's translator factory by hand, and source aliases were resolved through a separate hardcoded alias table and allowlist. Each agent type now implements `Translate` in its translator module and registers it with the others. The registry builds one factory per registered agent around the shared Git metadata cache, and alias resolution uses the agents' identities. The accepted hook sources and aliases are unchanged. A test pins them. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Stephen Belanger (Qard)
force-pushed
the
refactor/register-translators
branch
from
October 6, 2026 16:59
b6fe0b1 to
ed5dc88
Compare
`Translate` existed only to inject the shared Git metadata cache into a per-agent factory struct. Each agent type now implements the public `TranslatorFactory` directly, and the cache is process-wide. That is safe because repository entries are revalidated against the git directory before reuse and negative results expire. The seven factory structs and their `Translate` impls are gone. `Translate` remains only as an empty marker joining `Agent` and `TranslatorFactory`, implemented for every such type, so the registry can find agents by name. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
`TranslatorFactory::source` restated what each agent's identity already says. The trait now takes `Agent` as its supertrait, and the registry keys factories by `identity().source`. That makes the `Translate` marker unnecessary, so it is removed and the agent registry holds `dyn TranslatorFactory` directly. The debug translator gets its own `debug` identity but stays out of the agent registry. `Agent` is crate-private, so `TranslatorFactory` is too. It and the unused `Registry::register` leave the public API. Nothing outside the crate implemented the trait or registered factories. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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.
Summary
Based on
mainnow that #138 has merged.Registry::default_agents()built each translator factory by hand. Source aliases went throughcanonical_source_nameplus a second hardcoded allowlist inRegistry::canonical_source, which duplicated the agent identities. With this PR:Agents are their own factories.
TranslatorFactorynow hasAgentas its supertrait and nosourcemethod. Each agent type implements it directly in its translator module and registers itself alongside its other capabilities, and the registry keys factories byidentity().source. The seven per-agent*TranslatorFactorystructs are gone, and so is the intermediateTranslatetrait:Registry construction.
Registry::default_agents()registers every agent that registered a translator, plus the debug translator, as before. The debug translator has its owndebugidentity but isn't in the agent registry, since it isn't a coding agent.Public API.
Agentis crate-private, soTranslatorFactoryis too. It and the unusedRegistry::registerare no longer exported. Nothing outside the crate implemented the trait or registered factories; thebtCLI doesn't use either.Shared Git metadata cache. The cache is now process-wide instead of one per registry. That's safe because repository entries are revalidated against the git directory before reuse and "not a repository" results expire. A daemon already uses a single registry, so in practice only tests and imports in the same process now share it.
Alias resolution.
canonical_source_nameandRegistry::canonical_sourcenow resolve names through the agents' identities. Accepted names are each agent's id, its hook source, and its aliases, plusdebug. Factories that a host registers under any other name are still rejected, as before.Behaviour
None. The registered sources, the accepted aliases (
claude→claude-code,open-code→opencode) and the rejection of unknown sources are unchanged. Two new tests pin them.Testing
cargo clippy --all-features --all-targets -D warningsis clean.cargo test --all-features --no-fail-fast: everything passes excepttrace_runtime::tests::doctor_reports_a_daemon_that_{cannot_authenticate_the_route,resolves_other_credentials}, which fail the same way onmainin my local environment.🤖 Generated with Claude Code