# 검증기의 인접한 두 분기
    if (transactionsEnabled && !capabilities.isStable(MongoCapability.TRANSACTION)) {
      throw MongoOperationRejectedException.of(
          "startup.capability",
          "transactions are enabled but unavailable here: "
              + capabilities.require(MongoCapability.TRANSACTION).constraints()
              + "; a REPLICA_SET, SHARDED or ATLAS topology is required");
    }
    if (changeStreamsEnabled && !capabilities.isStable(MongoCapability.CHANGE_STREAM)) {
      throw MongoOperationRejectedException.of(
          "startup.capability",
          "change streams are enabled but unavailable here: "
              + capabilities.require(MongoCapability.CHANGE_STREAM).constraints()
              + "; a REPLICA_SET, SHARDED or ATLAS topology is required");
    }
  }

#   두 분기의 좌항이 오는 곳
              // configured — and then validated the topology against that invented answer.
              properties.transactions(),
              properties.changeStreams(),
              versions)

#   그 검사가 열리는 조건
   * <p>Conditional on a {@link MongoTopologyProbe} bean, because the check is about the server this
   * deployment actually talks to, and only a composition root knows how to reach it.
   */
  @Bean
  @ConditionalOnBean(MongoTopologyProbe.class)
  public InitializingBean mongoPlatformStartupCheck(
  ...
      if (security == null || admin == null || versions == null) {
        // Fail closed rather than validate a subset. A partial startup check reports success for
        // the parts nobody supplied, which is the shape the missing wiring already had.
        throw new IllegalStateException(
            "the Mongo platform is enabled and a topology probe is present, but the security"
                + " profile, admin credential reference or schema version range is not configured;"
                + " the startup validator cannot answer with only part of its inputs");

# changeStreams 는 컴팩트 생성자에서 고정된다
    // Experimental, and therefore not a switch (MNG-INT-003). The driver-side source — watch,
    // resumeAfter/startAfter, cursor lifetime, reconnection — is not shipped; what exists is policy
    // and value objects that do not add up to a running consumer. Accepting the flag and ignoring
    // it
    // would leave an operator believing it took effect, so the value is refused rather than stored:
    // zero beans, zero threads, and a `true` that cannot be honoured never becomes one that looks
    // honoured.
    changeStreams = false;
#   자동 구성 파일에서 changeStreams 가 나오는 줄 : 1

# 소비자 빈에 붙은 조건
    @Bean
    @ConditionalOnMissingBean
    @org.springframework.boot.autoconfigure.condition.ConditionalOnBean({
      dev.caskeleton.adapter.outbound.mongo.changestream.MongoChangeStreamSubscription.class,
      dev.caskeleton.adapter.outbound.mongo.changestream.MongoResumeCheckpointStore.class,
      dev.caskeleton.adapter.outbound.mongo.changestream.MongoResumeTokenCodec.class,
      dev.caskeleton.adapter.outbound.mongo.changestream.projector.MongoChangeProjector.class,
      dev.caskeleton.adapter.outbound.mongo.changestream.projector.MongoChangeDeduplicationStore
          .class
    })

# 스트림을 여는 시점의 실패를 복구 정책이 분류하는 방식
  /** Runbook for a subscription that failed for a non-resumable reason. */
  public static final String FAILURE_RUNBOOK = "docs/mongodb/runbooks/failover.md";
    if (failure.hasServerCode() && isHistoryLost(failure.serverCode())) {
      return MongoChangeStreamRecoveryDecision.halt(
          MongoChangeStreamState.HISTORY_LOST, HISTORY_LOST_RUNBOOK);
    }
    if (failure.hasLabel("ResumableChangeStreamError")) {
      return MongoChangeStreamRecoveryDecision.resume();
    }
    return MongoChangeStreamRecoveryDecision.halt(MongoChangeStreamState.FAILED, FAILURE_RUNBOOK);
  }
  private static boolean isHistoryLost(int serverCode) {
    return serverCode == 286 || serverCode == 280;

#   그 런북의 증상 절 전체
## Symptoms

- `MongoServerSelectionException` / `MongoConnectionException` spike, then recovery within seconds.
- `MongoSdamObservationListener` reports a topology change (primary removed, new primary elected).
- `MongoPoolObservationListener` shows checkout wait times rising while server-side command duration
  stays flat — the wait is topology, not query cost.
- Latency spike on writes with no corresponding rise in read latency.

A failover that resolves in under ~15 s and produces no `WRITE_RESULT_UNKNOWN` is normal replica-set
behaviour and needs no action beyond confirming it self-healed.

## Diagnosis
#   그 런북 전체에서 standalone·oplog·40573 이 나오는 줄 : 0
