refactor: keep ConnectionManager internal, preserve public API @W-22389160@#285
Open
shetzel wants to merge 1 commit into
Open
refactor: keep ConnectionManager internal, preserve public API @W-22389160@#285shetzel wants to merge 1 commit into
shetzel wants to merge 1 commit into
Conversation
…89160@ - ConnectionManager is no longer referenced in any exported type (BaseAgentConfig, ScriptAgentOptions, ProductionAgentOptions all revert to their main-branch shape). - ConnectionManager.create() builds two fresh Connections from the username (via AuthInfo.create) instead of mutating the caller's Connection. The supplied connection is read-only. - AgentBase keeps its protected readonly connection: Connection property and restoreConnection() signature. An optional connectionManager is held internally and supplies the JWT connection via a new protected getJwtConnection() helper. - ScriptAgent / ProductionAgent / ScriptAgentPublisher constructors accept an optional internal-only connectionManager as a second positional parameter; direct instantiation without Agent.init continues to work as it did on main. - Add test/connectionManager.test.ts (8 tests) covering: no-mutation contract, distinct JWT/standard connections, missing username, malformed/expired JWT, inspectJwt claims, and refreshStandardConnection. - Replace the four it.skip tests: the two utils.test.ts tests expected an unimplemented JWT guard and are deleted; the two agentPublisher.test.ts tests verified the old finally-block refresh and are replaced by a single test asserting the new no-mutation contract during publish. Co-Authored-By: Claude Opus 4.7 <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
Refactor of #278 that keeps the connection-isolation fix but eliminates the breaking changes to the public API.
ConnectionManageris internal — never exported, never appears in any public type (BaseAgentConfig,ScriptAgentOptions,ProductionAgentOptionsrevert to theirmain-branch shape).ConnectionManager.create()builds two freshConnectionobjects from the username viaAuthInfo.create()instead of mutating the caller'sConnection. The supplied connection is read-only.AgentBasekeeps itsprotected readonly connection: Connectionproperty andrestoreConnection()signature. JWT access goes through a newprotected getJwtConnection()helper.ScriptAgent,ProductionAgent, andScriptAgentPublisherconstructors accept an optional internal-onlyconnectionManageras a second positional parameter; direct instantiation (e.g.,new ProductionAgent({ connection, ... })) continues to work as onmain.The library-internal clobbering scenario remains fixed:
getStandardConnection()returns a fresh connection that never holds a JWT, so SOQL/tooling auto-refresh cannot overwrite the JWT used for SFAP requests.Test plan
yarn lint— 0 errors (warnings are pre-existing onmain)yarn compile— cleanyarn test— 300 passing, 1 pending (pre-existing skip unrelated to this work)test/connectionManager.test.ts— 8 tests covering: missing-username error, no-mutation guarantee, distinct JWT/standard connection objects, malformed token, expired token,inspectJwtclaim parsing,refreshStandardConnectiononly touches the standard sideit.skiptests from fix: add connectionManager @W-22389160@ #278: the two intest/utils.test.tstested an unimplemented JWT guard and are deleted (the new architecture doesn't need a guard); the two intest/agentPublisher.test.tstested the oldtry/finallyrefreshAuthand are replaced by a new test asserting the no-mutation contract during publishgit diff main -- src/types.ts src/index.ts— empty (public type surface matchesmain)🤖 Generated with Claude Code