---
id: WF-ACC-BAT-004
title: Open a recurring stream's first batch on create or reactivation
trigger: An administrator saves a new active stream or reactivates an inactive stream.
product_area: accounting
module: batches
revision: 1
status: draft
design_intent: proposed
implementation_evidence: observed
inference: []
source_sha:
  services-accounting: f47cb263875bbc0c5640fba7dae6785ec32695f8
  react-console: baf6dae382d6f41dce976c7f848667ccc37e076f
implements:
  - CAP-ACC-BAT-009
moves:
  - STATE-ACC-BAT-002
  - STATE-ACC-BAT-001
crosses:
  - SVC-ACC-BAT-batches
idempotency: >-
  The saving instant supplies the first occurrence key. This is not request-key
  deduplication; repeated creation and stale replacement remain subject to
  identity and version checks.
concurrency: >-
  First-batch work shares the configuration transaction and locks the stream
  through the roller, serializing it with scheduled rolling.
hops:
  - 'n': 1
    actor_or_service: Recurring batches persistence
    action: >-
      Validate configuration and schedule frequency, save the stream and owned
      schedule, and check the replacement version.
    anchor: >-
      services-accounting:modules/batches/services/roll/first-batch.ts:createRecurringBatchWithFirstBatch
    seam: sync
    on_failure: Invalid configuration aborts saving.
    left_inconsistent: No configuration write commits.
    observer: The save response
    provenance: test
    source: >-
      services-accounting:modules/batches/tests/e2e/recurring-batches.e2e.spec.js#answers
      400 to a schedule that would run more often than once a day
  - 'n': 2
    actor_or_service: First batch
    action: >-
      Within a savepoint, plan and open the first intake collection and retire
      any eligible retained predecessor.
    anchor: >-
      services-accounting:modules/batches/services/roll/first-batch.ts:openFirstBatch
    seam: sync
    on_failure: >-
      A recognized planning refusal rolls back the savepoint and returns a
      response-only explanation while configuration is retained.
    left_inconsistent: An active stream can still lack a current intake collection.
    observer: The API save response; the editor does not render this refusal
    provenance: test
    source: >-
      services-accounting:modules/batches/tests/integration/services/roll/batch-roller.integration.spec.js#saves
      a recurring batch whose first batch is refused, with the refusal and no
      batch
  - 'n': 3
    actor_or_service: Database
    action: >-
      Commit saved configuration and any successfully generated first collection
      together.
    anchor: >-
      services-accounting:modules/batches/services/roll/first-batch.ts:updateRecurringBatchWithFirstBatch
    seam: sync
    on_failure: Failure of the outer transaction prevents saving.
    left_inconsistent: Neither configuration nor first collection commits.
    observer: The save response
    provenance: observed
    source: >-
      services-accounting:modules/batches/services/roll/first-batch.ts:updateRecurringBatchWithFirstBatch
branches:
  - >-
    Inactive creation or a save remaining inactive does not attempt a first
    collection.
  - >-
    Reactivation can retire the retained collection but does not submit it for
    posting.
waits: []
evidence:
  - >-
    services-accounting at f47cb263:
    modules/batches/services/roll/first-batch.ts, batch-roller.ts;
    services/persistence/recurring-batches.ts;
    docs/accounting/recurring-batches.md
  - >-
    react-console at baf6dae3:
    components/configuration/recurring-batches/recurring-batch-editor.tsx
controls: [TC-IAM-001, TC-IAM-002, TC-IAM-004, TC-IAM-005, TC-IAM-006, TC-AZ-001, TC-AZ-002, TC-AZ-003, TC-AZ-004, TC-AZ-005, TC-AZ-006, TC-TEN-001, TC-TEN-002, TC-TEN-003, TC-DAT-001, TC-LOG-001, TC-LOG-002, TC-LOG-003, TC-LOG-004, TC-LOG-005, TC-AVL-001, TC-AVL-004, TC-MON-001, TC-MON-002, TC-MON-004, TC-PI-001, TC-PI-002, TC-PI-003, TC-PI-004, TC-PI-005]
---

# Open a recurring stream's first batch on create or reactivation

## What It Does

First-batch work makes intake available immediately on activation rather than waiting for a future occurrence. Configuration saving is allowed to succeed when first-batch planning is refused, and the refusal belongs only to that response.

## The Flow

```mermaid
flowchart LR
  S[Save enabled stream] --> V[Validate and persist configuration]
  V --> F[Attempt first roll in savepoint]
  F --> A[Open and repoint if possible]
  F --> R[Return planning refusal if refused]
  A --> D[Commit save]
  R --> D
```

## When Something Fails

Only recognized planning refusal is isolated by the savepoint. Other failure can abort saving. The editor omits the refusal field, so the current interface can report saved configuration without explaining absent intake.

## Open Design Questions

Product needs visible first-batch recovery and a decision on posting any predecessor retired by reactivation.
