Ayyoub Amjahed

A termination announced in advance kept its access past the date

Ingestion only recomputed when the payload fingerprint changed. A termination announced in advance asserts the same thing every night, so on the day its date arrives there is nothing the fingerprint can see. Eighteen tests green and no symptom.

4 min read Project: Lineward architecturesynchronisationLineward

Every night Lineward reads the population the HR system asserts and, by comparing that read with the previous one, decides whether somebody is a joiner, a mover or a leaver. To avoid rewriting five thousand rows every night, it stores a fingerprint of each person’s payload and only recomputes when that fingerprint changes.

That is correct, it is a legitimate optimization and it is well tested. If the source has said nothing new, there is nothing to recompute.

Except that sometimes there is.

The case that slips through

A termination announced in advance arrives like this: on 2 October, HR asserts that this person leaves on the 31st. And it keeps asserting the same thing on the 3rd, the 15th and the 30th. On the morning of the 31st, the extract says exactly the same thing it said the day before.

The fingerprint has not changed, so ingestion takes the “unchanged” branch and recomputes nothing. Whoever was leaving kept their access until HR touched their record for some other reason, which may never happen.

A joiner with a future start date has exactly the same shape, with the sign flipped.

The symptom

None, and that is what this note is about.

The state derived from the dates was computed correctly on every read. The problem is that it was computed and thrown away, because the “unchanged” branch did not store it. All eighteen ingestion tests passed, and they passed for good reason: not one of them ran two reads with different clocks. They all read, asserted and finished inside the same instant.

Two questions that are not the same

The fingerprint answers “has the source said something new?”. I was using it as though it answered “has anything changed?”.

They are the same question as long as all of your state comes from the input. They stop being the same the moment part of your state is derived by comparing a value against today, because today moves on its own and sends no notice.

And the confusion is comfortable. The fingerprint is a good, legitimate optimization with its own green tests, which makes it the last place you think to look for a gap.

What fixed it

Measuring the lifecycle against the stored state rather than against the fingerprint, in all three branches of ingestion. And two new tests that run the same read twice with different clocks, which was the missing case.

With the negative proof done: remove that comparison and both fail. That part is not optional in this project, and it comes from an earlier failure. Nine integration tests had passed green on their first run a few days before, and green on the first run is the symptom that does not look like a symptom: a test you have never seen fail does not prove it catches the failure, only that it is not complaining.

Before any of that, the test had already warned me

The best part of the week happened earlier, writing the tests for the classification. I gave them the signature that seemed obvious: compare the source’s previous assertion with the new one.

Writing the case “the start date arrives today” I had to pass the same record as both previous and current, and the result was “no event” by construction, not because of an implementation bug. Fifteen of the seventeen tests I had were fine; two were impossible to satisfy without changing the signature.

The underlying error was assuming the previous state can be derived from the previous assertion. It can be derived, yes, but deriving it with today’s date gives you today’s state, not the one the platform last acted on. What was needed was not to recompute the past: it was to remember it.

Writing the test first did not prevent a wrong design. It brought it into the open before there was code defending it. Half an hour later I would have had the implementation done, and that case would have looked like an edge case rather than a signature error.

The design consequence, which is the uncomfortable one

An incremental read only brings back what the source flagged as changed. Transitions caused by the calendar, by definition, do not come through there: the full read is what finds them.

That turns “how often the full read runs” into a security decision rather than a cost one. It is the kind of parameter that ends up in a config file, gets lowered by somebody so the nightly window fits, and nobody ever looks at what depended on it again.

I am writing it down because it is not an identity governance problem. It belongs to any synchronisation with a change detector and any state that depends on the calendar: expiring subscriptions, temporary permissions, publication embargoes, trial periods. If your change detector watches the source, today is not a source.