The sender knows the next segment number it will send, so when the receiver sends an ACK it sends an acknowledgement number of the next expected segment number. If the sender's next segment number is the same as the acknowledgement number, then everything is up to date.
Remember that the receiver may receive segments that are out of order. The sender can send until the receive window is exhausted before it needs to receive an ACK, and the acknowledgement number means the receiver has received all segments prior to the acknowledgement number.
It is defined in RFC 793, transmission Control Protocol:
Acknowledgment Number: 32 bits
If the ACK control bit is set this field contains the value of the
next sequence number the sender of the segment is expecting to
receive. Once a connection is established this is always sent.
3.7. Data Communication
Once the connection is established data is communicated by the
exchange of segments. Because segments may be lost due to errors
(checksum test failure), or network congestion, TCP uses
retransmission (after a timeout) to ensure delivery of every segment.
Duplicate segments may arrive due to network or TCP retransmission. As
discussed in the section on sequence numbers the TCP performs certain
tests on the sequence and acknowledgment numbers in the segments to
verify their acceptability.
The sender of data keeps track of the next sequence number to use in
the variable SND.NXT. The receiver of data keeps track of the next
sequence number to expect in the variable RCV.NXT. The sender of data
keeps track of the oldest unacknowledged sequence number in the
variable SND.UNA. If the data flow is momentarily idle and all data
sent has been acknowledged then the three variables will be equal.
When the sender creates a segment and transmits it the sender advances
SND.NXT. When the receiver accepts a segment it advances RCV.NXT and
sends an acknowledgment. When the data sender receives an
acknowledgment it advances SND.UNA. The extent to which the values of
these variables differ is a measure of the delay in the communication.
The amount by which the variables are advanced is the length of the
data in the segment. Note that once in the ESTABLISHED state all
segments must carry current acknowledgment information.