Skip to content

Remove legacy optimizer decorator path - #6119

Open
kocaemre wants to merge 2 commits into
stacklok:mainfrom
kocaemre:chore/remove-legacy-optimizer-decorator
Open

Remove legacy optimizer decorator path#6119
kocaemre wants to merge 2 commits into
stacklok:mainfrom
kocaemre:chore/remove-legacy-optimizer-decorator

Conversation

@kocaemre

Copy link
Copy Markdown
Contributor

Summary

  • The optimizer-without-AdvertiseFromCore path is now rejected by sessionmanager.New, so the old factory-level optimizer decorator branch can no longer run.
  • Remove the unreachable legacy optimizer decorator path and its private tool-adaptation helper.
  • Wire the session manager directly to the undecorated base factory; the resolved optimizer factory continues to be surfaced to the Serve layer via Manager.OptimizerFactory().

Fixes #6103

Type of change

  • Bug fix
  • New feature
  • Refactoring (no behavior change)
  • Dependency update
  • Documentation
  • Other (describe):

Test plan

  • Unit tests (task test)
  • E2E tests (task test-e2e)
  • Linting (task lint-fix)
  • Manual testing (describe below)

Manual testing:

  • PATH=/usr/local/go/bin:/root/go/bin:$PATH go test ./pkg/vmcp/server/sessionmanager
  • PATH=/usr/local/go/bin:/root/go/bin:$PATH go test ./pkg/vmcp/server/sessionmanager ./pkg/vmcp/server
  • PATH=/usr/local/go/bin:/root/go/bin:$PATH go test -race ./pkg/vmcp/server/sessionmanager
  • PATH=/usr/local/go/bin:/root/go/bin:$PATH task lint
  • git diff --check

API Compatibility

  • This PR does not break the v1beta1 API, OR the api-break-allowed label is applied and the migration guidance is described above.

Does this introduce a user-facing change?

No.

Special notes for reviewers

This is intentionally a deletion-only follow-up to the constructor guard merged in #6033. The optimizer is still resolved, cleaned up by the manager, and consumed by the Serve layer when enabled; the removed path was unreachable because New rejects an optimizer unless AdvertiseFromCore is set.

@github-actions github-actions Bot added the size/S Small PR: 100-299 lines changed label Aug 7, 2026
@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 77.75%. Comparing base (8343851) to head (b908e1e).
⚠️ Report is 40 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #6119      +/-   ##
==========================================
+ Coverage   72.96%   77.75%   +4.78%     
==========================================
  Files         742      756      +14     
  Lines       78236    72727    -5509     
==========================================
- Hits        57085    56546     -539     
+ Misses      17172    16176     -996     
+ Partials     3979        5    -3974     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ChrisJBurns ChrisJBurns left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two stale doc comments elsewhere in this file describe the removed decorator path — not required for this PR, but worth a quick follow-up.

)

sm.factory = buildDecoratingFactory(cfg, optimizerFactory, sm.Terminate)
sm.factory = vmcpsession.NewDecoratingFactory(cfg.Base)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New()'s doc comment at lines 95-96 still says: "It builds the decorating session factory from cfg, wiring the optimizer and composite tool layers internally." That's no longer accurate — the factory is now just cfg.Base with no decorators, and the optimizer is surfaced solely via sm.optimizerFactory/OptimizerFactory() for the Serve layer to consume. Worth rewording.

)

sm.factory = buildDecoratingFactory(cfg, optimizerFactory, sm.Terminate)
sm.factory = vmcpsession.NewDecoratingFactory(cfg.Base)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment at lines 132-133 above sm := &Manager{...} says "Build the Manager first so we can reference sm.Terminate and sm.sessions directly in closures..." — with buildDecoratingFactory (and its sm.Terminate param) gone, nothing built in New() references sm.Terminate anymore, only sm.loadSession/sm.checkSession/sm.sessions. The comment should drop the sm.Terminate mention.

@github-actions github-actions Bot added size/S Small PR: 100-299 lines changed and removed size/S Small PR: 100-299 lines changed labels Aug 7, 2026
Signed-off-by: Emre K <110906681+kocaemre@users.noreply.github.com>
@kocaemre
kocaemre force-pushed the chore/remove-legacy-optimizer-decorator branch from eaad88c to 011003b Compare August 15, 2026 18:10
@kocaemre

Copy link
Copy Markdown
Contributor Author

Rebased this PR onto current main and resolved the stale conflict in pkg/vmcp/server/sessionmanager/factory.go.

Follow-up included:

  • preserved the current BackendHealth wiring from main;
  • kept the legacy optimizer decorator removal;
  • refreshed the stale FactoryConfig comments mentioned in review so they no longer describe the removed decorator path.

Local verification:

  • go test -ldflags=-extldflags=-Wl,-w -race ./pkg/vmcp/server/sessionmanager → passed
  • task lint → passed (golangci-lint + go vet, 0 issues)
  • git diff --check → passed

Signed-off-by: Emre K <110906681+kocaemre@users.noreply.github.com>
@kocaemre

Copy link
Copy Markdown
Contributor Author

Updated the two stale comments called out in review:

  • New() now describes wrapping cfg.Base and surfacing the optimizer factory to the Serve layer instead of saying the optimizer/composite layers are wired internally.
  • The constructor-local comment now refers to sm.loadSession, sm.checkSession, and sm.sessions, and no longer mentions sm.Terminate.

Verification after the comment-only follow-up:

  • go test -ldflags=-extldflags=-Wl,-w ./pkg/vmcp/server/sessionmanager — passed
  • git diff --check — clean

I also tried the repository-preferred broad lint command with Go 1.26.7:

  • task lint started golangci-lint run --allow-parallel-runners ./... but the local process was killed with exit status 137 in this container. The last full CI run on the previous commit was green, and this follow-up only changes comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S Small PR: 100-299 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Delete the unreachable legacy optimizer decorator path in sessionmanager

2 participants