def evaluate(c):
    required=['assignment_id','work_item_id','assignee_id','assignee_role','plan_id','plan_version','scope_version','audit_event_id','evidence_ref']
    evidence_complete=all(str(c.get(k,'')).strip() for k in required)
    authority=bool(c.get('assignment_authority_valid',False))
    accepted=c.get('acceptance_state')=='ACCEPTED'
    declined=c.get('acceptance_state')=='DECLINED'
    scope_current=not bool(c.get('scope_changed')) or bool(c.get('scope_reacknowledged'))
    reassigned=bool(c.get('reassigned'))
    handoff_traceable=(not reassigned) or bool(c.get('handoff_id') and c.get('prior_evidence_preserved'))
    new_accepted=(not reassigned) or bool(c.get('new_assignee_accepted'))
    approval_transferred=bool(c.get('approval_transferred',False))
    if not evidence_complete:
        state='HOLD'
    elif not authority:
        state='BLOCKED'
    elif declined:
        state='DECLINED'
    elif not accepted:
        state='HOLD'
    elif not scope_current:
        state='HOLD'
    elif reassigned and not handoff_traceable:
        state='DISPUTED'
    elif reassigned and not new_accepted:
        state='HANDOFF'
    elif reassigned:
        state='REASSIGNED'
    elif c.get('workflow_state')=='SUBMITTED':
        state='SUBMITTED' if str(c.get('output_ref','')).strip() else 'HOLD'
    elif c.get('workflow_state')=='IN_PROGRESS':
        state='IN_PROGRESS'
    else:
        state='ACCEPTED'
    responsibility_active=state in {'ACCEPTED','IN_PROGRESS','REASSIGNED','SUBMITTED'}
    if approval_transferred:
        responsibility_active=False
        if state in {'REASSIGNED','SUBMITTED','IN_PROGRESS','ACCEPTED'}: state='BLOCKED'
    return {
      'state':state,
      'responsibility_active':responsibility_active,
      'handoff_traceable':handoff_traceable,
      'approval_transferred':approval_transferred,
      'scope_current':scope_current,
      'evidence_complete':evidence_complete
    }
