diff --git a/apps/server/src/test/kotlin/com/correx/apps/server/routes/EventInspectRoutesTest.kt b/apps/server/src/test/kotlin/com/correx/apps/server/routes/EventInspectRoutesTest.kt index 16291ab5..57e3aebd 100644 --- a/apps/server/src/test/kotlin/com/correx/apps/server/routes/EventInspectRoutesTest.kt +++ b/apps/server/src/test/kotlin/com/correx/apps/server/routes/EventInspectRoutesTest.kt @@ -268,7 +268,10 @@ class EventInspectRoutesTest { assertEquals(HttpStatusCode.OK, response.status) val array = testJson.parseToJsonElement(response.bodyAsText()) as JsonArray assertEquals(1, array.size) - assertEquals(1L, (array[0] as JsonObject)["sequence"]!!.jsonPrimitive.content.toLong()) + // Tail semantics: limit with no fromSeq returns the most recent events, so seq 3 (the + // last seeded event), not the oldest. A pending approval lives at the tail — this is the + // behaviour a headless operator needs. + assertEquals(3L, (array[0] as JsonObject)["sequence"]!!.jsonPrimitive.content.toLong()) val filtered = client.get("/sessions/s1/events?type=WorkspaceStateObserved&limit=1") val filteredArray = testJson.parseToJsonElement(filtered.bodyAsText()) as JsonArray @@ -277,6 +280,9 @@ class EventInspectRoutesTest { "WorkspaceStateObserved", (filteredArray[0] as JsonObject)["type"]!!.jsonPrimitive.content, ) + // Truncation is applied AFTER filtering: the tail of the two WorkspaceStateObserved + // events is seq 2, not the InitialIntent at seq 3. + assertEquals(2L, (filteredArray[0] as JsonObject)["sequence"]!!.jsonPrimitive.content.toLong()) } }