---
id: STATE-CRM-ACT-004
title: Task overdue standing
object: DOM-CRM-ACT-003
product_area: crm
module: activities-tasks
revision: 1
status: draft
design_intent: proposed
implementation_evidence: partially-observed
source_sha:
  services-crm: a8d1364f1dd44b723bb5f9acba12f983e9ec8d69
states:
  - name: not_overdue
    meaning: >-
      The task currently fails the overdue test; an older attention item may nevertheless
      remain after disabled publishing or a reconciliation race.
    provenance: observed
    source: 'services-crm:modules/tasks/services/persistence/task-attention-items.ts'
  - name: overdue_published
    meaning: >-
      Overdue work has a published attention item whose details represent the latest
      successful publication rather than a guaranteed current view.
    provenance: observed
    source: 'services-crm:modules/tasks/services/persistence/task-attention-items.ts'
  - name: overdue_unpublished
    meaning: >-
      The task qualifies as overdue but has no published item, for example before
      reconciliation or while publication is disabled.
    provenance: observed
    source: 'services-crm:modules/tasks/services/persistence/task-attention-items.ts'
transitions:
  - from: not_overdue
    to: overdue_published
    trigger: A persistence write leaves unfinished work past its due day.
    guard: The function has attention publishing enabled.
    side_effects:
      - >-
        Publish title, due day, priority and available contact context inside the task
        transaction.
    who: The tasks service handling the write.
    provenance: test
    source: >-
      services-crm:modules/tasks/tests/integration/services/persistence/task-attention-items.integration.spec.js#moves
      the item to the new holder when an overdue task is assigned, in the same generation
  - from: not_overdue
    to: overdue_unpublished
    trigger: The due day ends without a task write.
    guard: Elapsed calendar time requires no write guard.
    side_effects: []
    who: The workspace calendar.
    provenance: documented
    source: 'services-crm:docs/attention.md#5. The sweeps'
  - from: overdue_unpublished
    to: overdue_published
    trigger: A reconciliation pass or later persistence write reaches overdue work.
    guard: >-
      Publishing is enabled; reconciliation must reach the workspace before stopping
      between workspaces.
    side_effects:
      - >-
        Publish qualifying work; reconciliation processes pages from separately read task
        data.
    who: The attention sweep or tasks service.
    provenance: test
    source: >-
      services-crm:modules/tasks/tests/integration/services/persistence/task-attention-items.integration.spec.js#publishes
      the overdue task no write had published, with no contact
  - from: overdue_published
    to: overdue_published
    trigger: A persistence write changes the routing or details of overdue work.
    guard: Publishing is enabled.
    side_effects:
      - Refresh audience and item details within the task transaction.
    who: The tasks service handling the change.
    provenance: test
    source: >-
      services-crm:modules/tasks/tests/integration/services/persistence/task-attention-items.integration.spec.js#moves
      the item to the new holder when an overdue task is assigned, in the same generation
  - from: overdue_published
    to: not_overdue
    trigger: 'A task is closed, deleted or changed so it no longer qualifies as overdue.'
    guard: Publishing is enabled.
    side_effects:
      - >-
        Resolve the item within the task transaction with the corresponding closure,
        deletion or date-change reason.
    who: The tasks service handling the change.
    provenance: test
    source: >-
      services-crm:modules/tasks/tests/integration/services/persistence/task-attention-items.integration.spec.js#resolves
      the item completed when the overdue task is completed
  - from: overdue_published
    to: not_overdue
    trigger: Reconciliation ends with an older open item outside its current generation.
    guard: Publishing is enabled and that workspace pass reaches its resolving step.
    side_effects:
      - >-
        Resolve unseen items as no longer overdue; concurrent changes can still defeat the
        apparent repair.
    who: The attention sweep.
    provenance: observed
    source: >-
      services-crm:modules/tasks/services/persistence/task-attention-items.ts:sweepOverdueTasks
invalid:
  - from: not_overdue
    to: overdue_published
    why: >-
      Disabled publication cannot create an item. The sweep returns skipped before reading
      work; ordinary task synchronization may still read context before its publisher does
      nothing.
    provenance: observed
    source: 'services-crm:modules/tasks/services/persistence/task-attention-items.ts'
  - from: overdue_published
    to: not_overdue
    why: >-
      A rolled-back task transaction cannot retain its own attention change because both
      writes share that transaction.
    provenance: observed
    source: 'services-crm:modules/tasks/services/persistence/task-attention-items.ts'
concurrency: >-
  Task persistence and its attention update commit together. Reconciliation reads task
  pages separately from publication, without a task lock or a current-row check, so it can
  publish superseded details. A later write or successful sweep can repair them, but the
  local implementation establishes no repair deadline.
invariants:
  - INV-DOM-CRM-ACT-003-10
evidence:
  - >-
    services-crm at a8d1364f: modules/tasks/services/persistence/task-attention-items.ts
    (isOverdueTask, overdueTaskAudience, syncTaskOverdueAttention, sweepOverdueTasks);
    attention/tasks-overdue.attention.ts; lib/attention.ts (the switch);
    aws/crm.attention-sweeps.ts; docs/attention.md (§2 to §5).
---

# Task Overdue Standing

## The Lifecycle

```mermaid
stateDiagram-v2
  not_overdue --> overdue_published: persist work
  not_overdue --> overdue_unpublished: deadline passes
  overdue_unpublished --> overdue_published: publish overdue work
  overdue_published --> overdue_published: persist work
  overdue_published --> not_overdue: persist work
```

Overdue is a calculated condition, and publication is a separate condition. The labels summarize both rather than asserting an exact correspondence between task and attention records. Work due today remains on time until that day ends in the workspace calendar.

## Transitions Explained

Enabled persistence writes publish, refresh or resolve attention within their task transaction. A daily pass supplies publication after a deadline passes without a write and resolves older unseen items after completing a workspace. Its separately read pages can race task changes.

## What Cannot Happen

The default-off publication switch suppresses attention writes. It does not erase existing items. A task transaction that rolls back also rolls back its own attention changes. Attention supplies discovery rather than authorization to read the underlying task.

## Concurrency and Timing

A task can become overdue before its next write or daily pass. A skipped or unsuccessful pass can extend this gap. Reconciliation has a workspace-boundary time budget and no per-task concurrency safeguard, leaving eventual repair without a bounded guarantee.
