---
id: WF-ACC-BAT-009
title: Sweep batches awaiting posting attention
trigger: An hourly rule invokes the attention-maintenance function.
product_area: accounting
module: batches
revision: 1
status: draft
design_intent: confirmed
origin: >-
  The Work Coordinator's deploy-order rule (Andrew, 2026-10-18: a service
  references a Platform module only behind a switch that is off until it is
  live), recorded at services-accounting:lib/attention.ts (header); Platform's
  attention provider contract §3.3 and §5.1 as cited in
  modules/batches/attention/batches-awaiting-posting.attention.ts
implementation_evidence: observed
inference: []
source_sha:
  services-accounting: f47cb263875bbc0c5640fba7dae6785ec32695f8
implements:
  - CAP-ACC-BAT-008
crosses:
  - SVC-ACC-BAT-batches
idempotency: >-
  Batch identity refreshes the existing item. A successful pass resolves items
  not refreshed since its start; reserved concurrency one avoids overlapping
  invocations of this function.
concurrency: >-
  Each page commits its own attention transaction. Ordinary batch writes can
  independently publish or resolve their items during the pass.
hops:
  - 'n': 1
    actor_or_service: Scheduled rule and sweep function
    action: >-
      Visit active workspaces and traverse each business unit waiting
      collections in pages.
    anchor: >-
      services-accounting:modules/batches/services/attention/batches-awaiting-posting-sweep.ts:sweepBatchesAwaitingPosting
    seam: schedule
    on_failure: >-
      A failed invocation is monitored; the next scheduled pass attempts repair
      again.
    left_inconsistent: Unvisited collections retain prior attention state.
    observer: Error and missing-pass alarms
    provenance: observed
    source: >-
      services-accounting:modules/batches/aws/logic/batches-attention-sweep.lambda.ts
      (header)
  - 'n': 2
    actor_or_service: Batch attention items
    action: >-
      Publish or refresh current waiting items, with posting allowance and due
      information.
    anchor: >-
      services-accounting:modules/batches/services/persistence/batch-attention-items.ts:publishBatchAttentionPage
    seam: sync
    on_failure: >-
      A rejected page aborts the workspace pass; earlier page commits remain and
      final resolution and completion stamping are not reached.
    left_inconsistent: The failed and unvisited pages can remain stale.
    observer: Platform attention and sweep monitoring
    provenance: observed
    source: >-
      services-accounting:modules/batches/services/attention/batches-awaiting-posting-sweep.ts:sweepBatchesAwaitingPosting
  - 'n': 3
    actor_or_service: Batch attention items
    action: >-
      After all pages succeed, clear unrefreshed open items; the outer runner
      subsequently records successful completion.
    anchor: >-
      services-accounting:modules/batches/services/persistence/batch-attention-items.ts:resolveUnconfirmedBatchAttention
    seam: sync
    on_failure: Resolution or completion failure leaves the pass unsuccessful.
    left_inconsistent: Stale open items or a missing completion stamp can remain.
    observer: Platform attention and sweep monitoring
    provenance: observed
    source: >-
      services-accounting:modules/batches/services/persistence/batch-attention-items.ts:resolveUnconfirmedBatchAttention
branches:
  - >-
    With publishing disabled, Accounting records are still traversed but the
    gated publisher does not write or resolve Platform items.
waits:
  - The rule runs hourly and the function timeout is five minutes.
evidence:
  - >-
    services-accounting at f47cb263:
    modules/batches/services/attention/batches-awaiting-posting-sweep.ts;
    services/persistence/batch-attention-items.ts;
    services/rules/batch-attention-rules.ts;
    aws/logic/batches-attention-sweep.lambda.ts; lib/attention.ts; aws/cdk.json
controls: [TC-IAM-001, TC-IAM-005, TC-IAM-006, TC-AZ-001, TC-AZ-002, TC-AZ-003, TC-AZ-004, TC-TEN-001, TC-TEN-002, TC-TEN-003, TC-TEN-004, TC-DAT-001, TC-LOG-005, TC-AVL-001, TC-AVL-004, TC-MON-001, TC-MON-002, TC-MON-004, TC-PI-002, TC-PI-003, TC-PI-004, TC-PI-005]
---

# Sweep batches awaiting posting attention

## What It Does

The sweep repairs enabled attention after missed writes or changed posting allowances. It refreshes waiting work and clears obsolete items only after a complete workspace traversal. Page commits mean this is not one all-or-nothing pass.

## The Flow

```mermaid
flowchart LR
  H[Hourly invocation] --> W[Workspace and unit traversal]
  W --> P[Publish page and commit]
  P --> N{More pages}
  N -->|yes| P
  N -->|no| R[Resolve unrefreshed items]
  R --> S[Outer runner stamps completion]
```

## When Something Fails

A failed page stops that workspace pass while preserving earlier page commits. Later scheduled repair is expected; no continuation past the rejected page is implemented inside the sweep. Disabled publishing suppresses Platform writes but does not eliminate Accounting reads.

## Open Design Questions

Production publishing is off in the pinned configuration, and the declared bulk action still lacks proved console execution.
