---
id: WF-ACC-BAT-005
title: Submit and run a posting job
trigger: >-
  A direct posting request, permitted Post action or scheduled retirement
  submits accounting work; attention also declares a bulk action whose console
  execution remains unproved.
product_area: accounting
module: batches
revision: 1
status: draft
design_intent: confirmed
origin: >-
  D-03 (Andrew, 2026-10-15 and 2026-10-17, batch post kept) and A-1 (Andrew,
  2026-10-18, accounts resolved and frozen at batch posting), recorded at
  services-accounting:docs/architecture/accounting-2.0/02-decisions.md §1 and
  §2.8; DESIGN D6 and Andrew D7 of 2026-10-15 (one transaction, a refused write
  fails the job), recorded at docs/migrations/batch-posting/DESIGN.md#D6
implementation_evidence: observed
inference: []
source_sha:
  services-accounting: f47cb263875bbc0c5640fba7dae6785ec32695f8
  react-console: baf6dae382d6f41dce976c7f848667ccc37e076f
implements:
  - CAP-ACC-BAT-013
  - CAP-ACC-BAT-014
  - CAP-ACC-BAT-015
  - CAP-ACC-BAT-019
  - CAP-ACC-BAT-004
moves:
  - STATE-ACC-BAT-001
  - STATE-ACC-BAT-003
  - STATE-ACC-BAT-004
  - STATE-ACC-BAT-005
crosses:
  - SVC-ACC-BAT-batches
idempotency: >-
  Workspace, job kind, unit, sorted batch set and request key determine job
  identity. Equivalent in-flight or still-posted completed sets reuse a job;
  generation uniqueness independently rejects duplicate current postings.
concurrency: >-
  Submission and execution acquire requested batch locks in identity order.
  Shared fiscal-period locks coordinate accounting with fiscal close; dependent
  reads are a separate, less-proved boundary.
hops:
  - 'n': 1
    actor_or_service: 'Batches API (or the action, or automatic posting)'
    action: >-
      Accept up to one hundred batch identifiers over HTTP or two hundred
      internally, lock request rows and find or create the submission. Execution
      checks their unit; the Post action checks admission before submission.
    anchor: >-
      services-accounting:modules/batches/services/jobs/batch-posting-jobs.ts:createBatchPostingJob
    seam: sync
    on_failure: 'Invalid identifiers, count or action admission reject submission.'
    left_inconsistent: No new job is retained by the rejected transaction.
    observer: The submitting caller
    provenance: observed
    source: >-
      services-accounting:modules/batches/aws/api/batch-postings.schemas.ts:MAX_BATCHES_PER_REQUEST;
      services-accounting:modules/batches/services/jobs/batch-posting-jobs.ts:createBatchPostingJob
  - 'n': 2
    actor_or_service: Batches API
    action: >-
      Attempt workflow start only after the submission commits, then return the
      job identity.
    anchor: >-
      services-accounting:modules/batches/services/jobs/batch-posting-jobs.ts:startBatchJob
    seam: state_machine
    on_failure: Start failure is logged without a registered reconciler.
    left_inconsistent: A Pending job may never execute while accounting remains unchanged.
    observer: Platform job monitoring
    provenance: observed
    source: >-
      services-accounting:modules/batches/services/jobs/batch-posting-jobs.ts
      (ensureBatchPostingJobTypesRegistered, EX-BP-005)
  - 'n': 3
    actor_or_service: Posting state machine
    action: >-
      Publish the phase definition and invoke the working task through the state
      machine.
    anchor: >-
      services-accounting:modules/batches/aws/logic/batch-posting.step-functions.ts
    seam: state_machine
    on_failure: >-
      The workflow applies its configured retry policy; BatchRefused follows
      failure handling without retry.
    left_inconsistent: >-
      Workflow failure may leave only operational job records before accounting
      begins.
    observer: Execution history and alarms
    provenance: observed
    source: >-
      services-accounting:modules/batches/services/jobs/batch-posting-jobs.ts:batchPostingWorkflow
  - 'n': 4
    actor_or_service: 'Posting task, posting engine'
    action: >-
      Run admission, document loading, account resolution and generation inside
      one batch-locked, period-protected transaction.
    anchor: >-
      services-accounting:modules/batches/services/engine/post-batches.ts:postBatches
    seam: sync
    on_failure: >-
      Document failures produce Error batches and dependency failures;
      whole-request refusal aborts the transaction.
    left_inconsistent: No accounting outcome has committed yet.
    observer: Batch errors and job checking phase
    provenance: test
    source: >-
      services-accounting:modules/batches/tests/integration/services/posting/rebuilt-posting-edges.integration.spec.js#posts
      January, puts April in error naming the application whose credit's batch
      is not posted, and May in error as April's dependent
  - 'n': 5
    actor_or_service: Posting engine
    action: >-
      Write successful generation records, ledger lines, schedules, snapshots
      and final batch outcomes; remove eligible empty collections and commit.
    anchor: 'services-accounting:modules/batches/services/engine/posted-accounting.ts'
    seam: sync
    on_failure: >-
      A refused transactional write rolls back the request accounting and is
      reported on the failed job phase without retry.
    left_inconsistent: Prior accounting survives unchanged after rollback.
    observer: Job failure summary and collection state
    provenance: test
    source: >-
      services-accounting:modules/batches/tests/integration/services/jobs/deployed-task-handler.integration.spec.js#fails
      the job on a step the database refuses: refused once, recorded by the
      failure task, the batch open and nothing written
  - 'n': 6
    actor_or_service: Posting task
    action: >-
      After accounting commit, settle checking and writing phases, emit
      collected progress and retain batch outcomes.
    anchor: >-
      services-accounting:modules/batches/services/jobs/batch-posting-job-tasks.ts:postBatchesOperation
    seam: sync
    on_failure: >-
      Progress emission is advisory and failures are logged. Settlement failure
      propagates after commit, allowing recovery or recorded failure without
      undoing accounting.
    left_inconsistent: Completed accounting can coexist with an unsuccessful job record.
    observer: The job panel and the collection result
    provenance: inferred
    source: >-
      services-accounting:modules/batches/services/jobs/batch-posting-job-tasks.ts:postBatchesOperation;
      aws/logic/batch-posting.step-functions.ts (header, retry on transient
      errors); FND-ACC-BAT-039
branches:
  - >-
    The named Post action checks admission before submission; direct submission
    defers relevant checks to execution.
  - >-
    Generation removes empty collections regardless of the retained delete-empty
    option.
  - >-
    Carried environment switches can force cash accounting, bypass service
    account checks or widen admitted statuses.
waits:
  - >-
    The console polls the durable job and reloads batch state after phase
    settlement.
evidence:
  - >-
    services-accounting at f47cb263: modules/batches/services/jobs/**;
    services/engine/post-batches.ts, posting-documents.ts, posted-accounting.ts,
    engine-scope.ts; services/rules/batch-posting-rules.ts,
    posting-generation.ts; services/actions/batch-actions.ts;
    aws/logic/batch-posting.step-functions.ts;
    docs/architecture/accounting-2.0/08-batch-posting.md
  - >-
    react-console at baf6dae3:
    components/accounting/batches/batch-posting-panel.tsx,
    batch-detail-screen.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-CRY-004, TC-DAT-001, TC-DAT-004, 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]
---

# Submit and run a posting job

## What It Does

Posting turns the reviewed collection into ledger results using account configuration resolved at execution. Its accounting transaction includes all batch outcomes, while job phase settlement follows that commit and can fail independently.

## The Flow

```mermaid
flowchart LR
  S[Submit and lock] --> J[Commit job]
  J --> W[Start workflow]
  W --> G[Check and generate]
  G --> A[Commit accounting]
  A --> R[Settle phases and progress]
```

## When Something Fails

A refused accounting write rolls back the accounting transaction. A document-level generation failure can instead commit an Error batch alongside successful siblings. Post-commit settlement is neither rollback nor compensation; staff may need to reconcile the job with the batch result.

## Open Design Questions

Product must resolve posting-date policy, carried bypass switches and post-commit recovery. Attention bulk-action execution also lacks direct console proof.
