Skip to content

refactor(controller): GetTargetGraph takes the entity request and the repository - #334

Merged
justinwon777 merged 1 commit into
justin.won/handler-metricsfrom
justin.won/handler-entity-targetgraph
Oct 15, 2026
Merged

justinwon777 merged 1 commit into
justin.won/handler-metricsfrom
justin.won/handler-entity-targetgraph

Conversation

@justinwon777

@justinwon777 justinwon777 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Stack (each PR is based on the one before it):

  1. refactor(handler): move the metrics lifecycle to the handler #333 Move the metrics lifecycle to the handler
  2. refactor(controller): GetTargetGraph takes the entity request and the repository #334 GetTargetGraph takes the entity request and the repository (this PR)
  3. refactor(controller): GetChangedTargets takes the entity request and the repository #335 GetChangedTargets takes the entity request and the repository
  4. refactor(controller): remove the repository resolver #336 Remove the repository resolver

Depends on #333. Review and merge in order.

What

The handler passes the entity request and the resolved config.RepositoryConfig to GetTargetGraph in the controller. The controller no longer maps the request or resolves the repository for this RPC. It uses the repository ID for cache keys and phase metrics. It still filters and sends to the stream.

The Controller interface no longer embeds the generated server, because its first method now takes entity types. It lists GetTargetGraph and GetChangedTargets.

The stub GetChangedTargetGraph leaves the controller. The handler serves it: it starts the metrics op, returns the Unimplemented infra error, and completes the op. It makes no controller call.

The controller keeps its resolver for GetChangedTargets only.

Test plan

  • make build, make test, make lint
  • Handler tests check the forwarded entity request, output config, stream, and repository.
  • Controller tests call GetTargetGraph with the entity request.

🤖 Generated with Claude Code

… repository

The handler already maps the GetTargetGraph request and resolves the repository. It now passes the entity request and the resolved config.RepositoryConfig to the controller, together with the output config and the response stream. The controller no longer maps the request or resolves the repository for this RPC. It uses the repository ID for its cache keys and its phase metrics. It still filters and sends to the stream. The handler no longer carries the comment that names its mapping as temporary for this RPC.

The Controller interface no longer embeds the generated server, because its first method now takes entity types. It lists GetTargetGraph and GetChangedTargets. The stub GetChangedTargetGraph leaves the controller. The handler serves the stub itself: it starts the metrics.Op, returns the Unimplemented infra error, and completes the op in the deferred block, without a controller call. The handler test of the stub no longer needs a controller mock. The mock is regenerated.

The controller keeps its resolver for GetChangedTargets only.

Test plan:
- make build, make test, make lint
- handler tests check the forwarded entity request, output config, stream, and repository
- controller tests call GetTargetGraph with the entity request

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@justinwon777
justinwon777 merged commit 5589d54 into main Oct 15, 2026
16 checks passed
justinwon777 added a commit that referenced this pull request Oct 15, 2026
**Stack** (each PR is based on the one before it):

1. #333 Move the metrics lifecycle to the handler (this PR)
2. #334 `GetTargetGraph` takes the entity request and the repository
3. #335 `GetChangedTargets` takes the entity request and the repository
4. #336 Remove the repository resolver

## What
- The handler maps the request, resolves the repository, and tags the
metrics with the repository ID. A bad request or an unconfigured remote
gets the tag `unknown` and never reaches the controller.
- The controller keeps its phase metrics (cache lookups, durations,
`target_count`) and `send_duration`.
- `start` and `finish` now publish under `handler.<operation>` instead
of `controller.<operation>`. Names, tags, and counts do not change.

## Temporary duplication

The handler and the controller both map the request and resolve the
repository. The controller needs the result for cache keys. A follow-up
change passes the entity request and the resolved repository to the
controller and removes the duplicate. The duplicate code has comments
that say so.

## Test plan:
- make build, make test, make lint
- handler tests cover the lifecycle metrics of each RPC with the repo
tag


## Issue
<!-- 
Link the issue here. 
- Use 'Closes #123' if this is the final fix. 
- Use 'Part of #123' or just '#123' if the feature is still in progress.
-->
#325

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
justinwon777 added a commit that referenced this pull request Oct 15, 2026
…the repository (#335)

**Stack** (each PR is based on the one before it):

1. #333 Move the metrics lifecycle to the handler
2. #334 `GetTargetGraph` takes the entity request and the repository
3. #335 `GetChangedTargets` takes the entity request and the repository
(this PR)
4. #336 Remove the repository resolver

Depends on #334. Review and merge in order.

## What

The handler passes the entity request and the resolved
`config.RepositoryConfig` to `GetChangedTargets` in the controller. The
controller no longer maps the request or resolves the repository for
this RPC. It uses the repository ID for cache keys and phase metrics,
and the repository configuration for seed attributes. It still filters
and sends to the stream.

The controller test `TestGetChangedTargets_ValidationError` goes. It
passed a nil proto request, so it tested the conversion that the handler
owns. The mapper tests cover that conversion.

The controller keeps its resolver, `controller.Params.RepoConfig`, and
their test in this PR. The next PR removes them.

## Test plan

- make build, make test, make lint
- Handler tests check the forwarded entity request, output config,
stream, and repository.
- Controller tests build the entity request and the repository at each
call site and call `GetChangedTargets` directly.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
justinwon777 added a commit that referenced this pull request Oct 15, 2026
**Stack** (each PR is based on the one before it):

1. #333 Move the metrics lifecycle to the handler
2. #334 `GetTargetGraph` takes the entity request and the repository
3. #335 `GetChangedTargets` takes the entity request and the repository
4. #336 Remove the repository resolver (this PR)

Depends on #335. Review and merge in order.

## What

The controller no longer uses its repository resolver, because both RPCs
take the resolved repository from the handler. This PR removes the dead
code:

- `resolveRequestRepository`, `unknownRepositoryMetricLabel`,
`controller.Params.RepoConfig`, and the `repoConfig` field of the
controller
- the controller test of the resolver (the handler has its own test of
the same function)
- the `RepoConfig` setting on `controller.Params` in tests, `example`,
and the integration test
- the handler comments that named its copies as temporary

## Breaking change for callers

Callers that build `controller.Params`, such as go-code, must stop
setting `RepoConfig`. They must set it on `handler.Params` instead.

## Test plan

- make build, make test, make lint

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-authored-by: Claude Sonnet 5.5 <noreply@anthropic.com>
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.

2 participants