Observer-only control-plane + quality cleanup + session discovery sup…#19
Merged
ajit-zer07 merged 1 commit intomainfrom Apr 18, 2026
Merged
Observer-only control-plane + quality cleanup + session discovery sup…#19ajit-zer07 merged 1 commit intomainfrom
ajit-zer07 merged 1 commit intomainfrom
Conversation
…port
Transform the control-plane into a scenario-agnostic observer per the
direct-agent-auth plan (CP-1..CP-13). Agents authenticate to the runtime
directly (RFC-MACP-0004 §4); the control-plane never calls Send.
Followed by a four-phase quality cleanup (plans/quality-cleanup.md):
dead code removal, test-suite hygiene (sleep→polling), convention
documentation, and gRPC helper extraction.
Behavioral changes:
- POST /runs accepts RunDescriptor only (forbidNonWhitelisted); returns
{runId, sessionId, status, traceId}. sessionId allocated via UUID v4.
- POST /runs/:id/{messages,signal,context} → 410 Gone (ENDPOINT_REMOVED).
- POST /runs/:id/cancel: Option A proxies to metadata.cancelCallback.url;
Option B calls runtime.CancelSession when cancellationDelegated=true.
- New observer execute flow: initialize → pollForOpenSession (100ms→1s
backoff, 60s timeout) → bindSession → subscribeSession (read-only) →
stream consumer.
- Session discovery: SessionDiscoveryService subscribes to WatchSessions
and auto-creates runs for externally-started sessions.
Internal changes:
- RuntimeProvider narrowed: subscribeSession() replaces openSession/send/
startSession/streamSession. Added listSessions/watchSessions.
- Extracted grpc-helpers.ts (fromEnvelope, fromAck, fromSessionMetadata,
buildMetadata, getClientMethod) — provider 553→459 lines.
- RuntimeCredentialResolverService reverted to single-bearer (CP-9).
- ProtoRegistryService.decodeKnown falls back to JSON on proto failure.
- Deleted: MockRuntimeProvider, encode methods + types, ExecutionRequest
alias, test-agents/ harness, 5 mode-specific integration specs,
runs-messaging spec, 3 write-path DTOs, ts-agent.ts helper.
Quality:
- waitFor() polling replaces 17 hardcoded sleep() calls in integration
tests (~80s→~5s conditional polling).
- Two invariant tests: observer-invariant.spec.ts (no provider.send),
projection-coverage.spec.ts (every canonical event has a reducer).
- Conventions documented in CLAUDE.md §Conventions with grep rules.
- forbidNonWhitelisted applied to all class-DTO @Body endpoints.
- THROTTLE_TTL_MS/THROTTLE_LIMIT migrated to AppConfigService.
- npm run lint upgraded to --max-warnings=0.
Verification:
- lint clean, build clean
- 577/577 unit tests (44 suites)
- 59/59 integration tests (14 suites)
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
POST /runsaccepts scenario-agnosticRunDescriptor, returns{runId, sessionId}. Control-plane pollsGetSessionuntil the initiator agent opens the session, then subscribes read-only viaStreamSession. Write endpoints (/messages,/signal,/context) return 410Gone. Agents use
macp-sdk-python/macp-sdk-typescriptdirectly.SessionDiscoveryServicesubscribes toWatchSessionsand auto-creates run records for sessions started by external launchers.sleep()→waitFor()polling, instrumentation assertions tightened, conventions documented, gRPC helpers extracted,--max-warnings=0enforced.Behavioral changes
POST /runsExecutionRequestwithkickoff[],participants[].role, etc.RunDescriptoronly (forbidNonWhitelisted); returnssessionIdPOST /runs/:id/messagesPOST /runs/:id/signalPOST /runs/:id/contextPOST /runs/:id/cancelruntime.CancelSessioncancelCallback.url. Option B:CancelSessionwhencancellationDelegated=trueNew features
WatchSessionsgRPC stream (SESSION_DISCOVERY_ENABLED=truedefault). Auto-creates runs for externally-started sessions.listSessions()/watchSessions()onRuntimeProviderinterface.New env vars
SESSION_POLL_BASE_MS100SESSION_POLL_MAX_MS1000SESSION_POLL_TIMEOUT_MS60000CANCEL_CALLBACK_TIMEOUT_MS5000SESSION_DISCOVERY_ENABLEDtrueTHROTTLE_TTL_MS/THROTTLE_LIMIT60000/100AppConfigServiceRemoved
RUNTIME_AGENT_TOKENS_JSON,KICKOFF_MAX_RETRIESenv varsMockRuntimeProvider, encode methods + types (PayloadEnvelopeInput,ProtoPayload)ExecutionRequesttype alias (useRunDescriptor)test-agents/Python harness,scripts/run-e2e.shsend-run-message.dto.ts,send-signal.dto.ts,update-context.dto.tsruns-messaging(replaced byobserver-mode.integration.spec.ts)TestClient.sendMessage/sendSignal/updateContext,ts-agent.tsInvariant tests (CI gates)
observer-invariant.spec.ts— fails on anyprovider.send(,openSession(,chooseInitiator(,retryKickoff(insrc/projection-coverage.spec.ts— everyCANONICAL_EVENT_TYPESentry must have a reducer branchTest plan
npm run lint --max-warnings=0— cleannpm run build— cleannpm test— 577/577 (44 suites)npm run test:integration— 59/59 (14 suites)npm run format— appliedRUNTIME_BEARER_TOKEN(observer,can_start_sessions: false), removeRUNTIME_AGENT_TOKENS_JSONNet diff
93 files changed, 1,767 insertions, 1,636 deletions — net +131 LoC (includes new session discovery service, invariant tests, waitFor helper, and gRPC helpers; offset by
deleted dead code).