Skip to content

Give api.NewHandler one explicit Dependencies value - #302

Merged
SaladDay merged 3 commits into
mainfrom
refactor/api-dependencies
Sep 30, 2026
Merged

SaladDay merged 3 commits into
mainfrom
refactor/api-dependencies

Conversation

@SaladDay

@SaladDay SaladDay commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Part of the Core layering plan (issue #1): api.NewHandler takes one explicit api.Dependencies value, so later domain cutovers can replace one area interface at a time.

What changes

  • api.NewHandler(Dependencies) (http.Handler, error) replaces the handler options. Each application area is a field typed as an interface declared in api, listing exactly the methods its handlers call. validate() rejects any missing required field at construction.
  • Two optional groups carry the only disabled states, and nil means disabled:
    • Execution{ExecutorURL, Admission, SessionArchive, Workspaces, NativeInstaller}
    • Sandboxes{Deployment, DeploymentChanges, ConfigurationDiscovery} (requires Execution)
  • No capability type assertions, optional function fields or fallback paths remain in api.
  • cmd/server composes Dependencies explicitly (executor_connections.go).
  • Deleted Authenticator and NewDatabaseAuthenticator. The key rules live in auth.go (projectBearerDigest, resolveCaller) and sandbox_manager_auth.go.

Removed

Error codes that only reported a missing optional dependency no longer exist, because every such dependency is now required: skill_storage_unavailable, file_storage_unavailable, diagnostics_unavailable, artifact_storage_unavailable, subagent_storage_unavailable, stream_unavailable, execution_configuration_unavailable. Web and packages/agents-client drop them too, and CoreErrorBoolean is deleted.

Tests

  • api/fakes_test.go: one strict fake<Area> per interface. An unset func fails the test with "unexpected call to ".
  • store/public_handler_fixture_test.go builds the full router for the store-backed integration tests.

Checks

  • go build ./..., go vet (api, store, cmd/server, execution) clean
  • go test: api 310, cmd/server 33, sandbox/providers 36, execution 92 passed
  • Full store package against PostgreSQL: 529 passed, 33 skipped for environment only; the 20 official-SDK tests were then run against the pinned SDK and passed
  • python3 scripts/check-names.py, make openapi (no diff), Web typecheck and affected tests

View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

NewHandler(ResourceStore, auth, engine, options...) and its 26 With*
options become NewHandler(Dependencies). Each application area is one
interface field declared beside its handlers, and NewHandler rejects a
missing required field. Execution (the Worker, its executor URL and the
optional native installer) and Sandboxes (the managed deployment, which
requires Execution) are the only optional groups; nil means disabled.

The handler no longer discovers capabilities through type assertions and
no longer falls back to GetAgent when a store lacks GetAgentForSession.
The 503 and 409 answers that only a partially wired test handler could
produce are gone. cmd/server builds the one Dependencies value.

API tests use strict per-area fakes that fail on any unexpected call.
Core no longer emits skill_storage_unavailable, file_storage_unavailable
or diagnostics_unavailable, so Web and the agents-client tests stop
handling them. cmd/server drops a managed-node check that is always true
and the unreachable type-asserted observation source behind it, plus a
repeated installation ID check. CoreErrorBoolean had no caller, so Core
error details no longer list booleans.
@SaladDay
SaladDay merged commit 474ece4 into main Sep 30, 2026
8 of 9 checks passed
@SaladDay
SaladDay deleted the refactor/api-dependencies branch September 30, 2026 15:42
unexpectedCall now records the failure with t.Errorf and panics. net/http
recovers the panic on an httptest server goroutine, where t.Fatalf cannot
stop the test, and a direct ServeHTTP call fails loudly. The routing
fixture's trapTB overrides Errorf, so a trapped call still reports
"handler reached" without failing the test.

newTestAuthenticator takes the test and fails it on an invalid fixture
key instead of returning an error every caller only passed to t.Fatal.
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.

1 participant