Skip to content

RFC-MACP-0006 passive-subscribe + observer-only hardening#20

Merged
ajit-zer07 merged 1 commit intomainfrom
subscribe-session
Apr 21, 2026
Merged

RFC-MACP-0006 passive-subscribe + observer-only hardening#20
ajit-zer07 merged 1 commit intomainfrom
subscribe-session

Conversation

@ajit-zer07
Copy link
Copy Markdown
Contributor

Summary

  • Wire the control-plane's observer stream to the new RFC-MACP-0006 §3.2 passive-subscribe handshake: subscribeSession() writes a single {subscribeSessionId, afterSequence} frame, half-closes, and lets the runtime replay accepted history from afterSequence (default 0 = full replay) before switching to live broadcast.
  • Finish pruning the write-path surface left over from the 2026-04-15 direct-agent-auth refactor: drop the unused RuntimeSessionOpenResult type and the write-only error
    codes (KICKOFF_FAILED, SIGNAL_DISPATCH_FAILED, CONTEXT_UPDATE_FAILED, MESSAGE_SEND_FAILED). The control-plane is observer-only — these were dead symbols.
  • Add a new conventions CI job that enforces the CLAUDE.md grep invariants (throw new Error, console.*, process.env, no observer-only write-path re-introduction);
    gated before build.
  • Bump @multiagentcoordinationprotocol/proto0.1.2.
  • Refresh docs/{API,INTEGRATION,TROUBLESHOOTING}.md to document the 410 Gone contract, the afterSequence handshake, and the current error-code set.

Tests added

  • src/runtime/rust-runtime.provider.spec.ts (new — 7 tests): single passive-subscribe write, afterSequence forwarding, envelope-free write, sync/async write-side
    failure paths, synthetic opened status frame, cross-session envelope filtering.
  • src/runs/session-discovery.service.spec.ts (new — 8 tests): created/resolved/expired lifecycle handling, dedup, terminal-state idempotency, disabled-flag
    short-circuit.
  • test/integration/removed-endpoints.integration.spec.ts (new): end-to-end 410 Gone contract for POST /runs/:id/{messages,signal,context}, including errorCode: ENDPOINT_REMOVED and ParseUUIDPipe precedence.

Test plan

  • npm run lint — clean (--max-warnings=0)
  • npx tsc --noEmit — clean (src + test/tsconfig.test.json)
  • npm run build (nest build) — clean
  • npm test — 46 suites / 593 tests passing (was 45 / 586)
  • All 4 CI conventions grep rules return 0 violations locally
  • npm run test:integration against Postgres :5433 — CI-only (local Docker unavailable)
  • CI conventions job green on push
  • NODE_AUTH_TOKEN secret still wired in workflow for the @multiagentcoordinationprotocol npm scope

  Wire the control-plane's observer stream to the new RFC-MACP-0006 §3.2
  handshake: subscribeSession() now writes a single {subscribeSessionId,
  afterSequence} frame before half-closing the write side so the runtime
  binds the bidi stream to the session broadcast channel and replays
  accepted history from afterSequence (default 0 = full replay). Prune
  dead write-path surface (RuntimeSessionOpenResult, KICKOFF_FAILED /
  SIGNAL_DISPATCH_FAILED / CONTEXT_UPDATE_FAILED / MESSAGE_SEND_FAILED
  error codes) left over from the 2026-04-15 direct-agent-auth refactor
  and refresh the docs/CI to match.

  - src/runtime/rust-runtime.provider.ts: write passive-subscribe frame
    with afterSequence, propagate write failures onto the iterator.
  - src/contracts/runtime.ts: add RuntimeSubscribeSessionRequest.afterSequence;
    drop unused RuntimeSessionOpenResult.
  - src/errors/error-codes.ts: remove write-path-only error codes.
  - src/metrics/metrics.service.ts: doc-only — tokenUsage now arrives via
    agent-emitted envelopes, not POST /runs/:id/messages.
  - .github/workflows/ci.yml: new `conventions` job enforcing the grep
    invariants from CLAUDE.md (throw new Error, console.*, process.env,
    observer-only write-path), gated before `build`.
  - docs/{API,INTEGRATION,TROUBLESHOOTING}.md: document 410 Gone behavior,
    afterSequence handshake, and remove stale write-path error codes.
  - package.json: bump @multiagentcoordinationprotocol/proto 0.1.0 → 0.1.2.

  Tests
  - src/runtime/rust-runtime.provider.spec.ts (new, 7 tests): passive-
    subscribe frame write, afterSequence forwarding, envelope-free write,
    write/end failure paths, opened status frame, cross-session filter.
  - src/runs/session-discovery.service.spec.ts (new, 8 tests): lifecycle
    event handling for created/resolved/expired, dedup, terminal-state
    idempotency, disabled flag.
  - test/integration/removed-endpoints.integration.spec.ts (new):
    end-to-end 410 Gone contract for POST /runs/:id/{messages,signal,context}.

  Verification
  - eslint --max-warnings=0 clean
  - tsc --noEmit clean (src + integration tsconfigs)
  - nest build clean
  - jest: 46 suites / 593 tests passing (+1 suite, +7 tests)
  - All 4 CI conventions greps return 0 violations locally
@ajit-zer07 ajit-zer07 merged commit 8313e5f into main Apr 21, 2026
8 checks passed
@ajit-zer07 ajit-zer07 deleted the subscribe-session branch April 21, 2026 22:52
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