Repository navigation
feat(server): declare indexed_at for operation policies - #2447
Conversation
OperationInput.indexed_at was in the proto but absent from the operation CEL environment and never populated, so no operation policy could read it. Declare it as an optional timestamp and populate it at index, the one operation that holds a row: the reconciler reads records.created_at before it writes the row, so a record seen before answers the variable and a first index leaves it absent. push and autosync decide before any row exists and stay absent, as does prune, which does not decide through a policy yet. Absence is representable, so a policy reads it with hasValue()/orValue() instead of comparing against 1970. IndexedAt(t) is a DecideOption beside FromPeer, so prune can supply the same value when it starts deciding without a new API. Signed-off-by: Paolo Valletta <[email protected]>
2657a00 to
d90b1fc
Compare
|
Thanks @paoValle for this — it's a thoughtful piece of work, and I appreciate that the description is explicit about what it does and doesn't unlock. A few notes below, mostly small. I pulled the branch and confirmed it builds and tests green across Things I particularly liked: reading One thing I'd like changed before merge
Smaller suggestions, take or leave
On the scopeI want to think out loud about this rather than ask you to change anything, because I think your framing is right and I'd rather the reasoning be written down. At My conclusion is that this should still land now rather than wait for the prune increment. Thanks again — nice work. |
pullInput builds an OperationInput without going through the option loop, so any option added there later would dereference a nil Context. Guard it and pin it with a test. Signed-off-by: Paolo Valletta <[email protected]>
…out-param Signed-off-by: Paolo Valletta <[email protected]>
…ay what a re-indexed row reports Signed-off-by: Paolo Valletta <[email protected]>
|
Thanks for the careful read, and for pulling the branch.
One thing I did not take: the narrow interface in the indexer. On the scope: I read it the same way you do, and the doc says which operations leave the value absent rather than implying it is always there — the motivation stays with
|
tkircsi
left a comment
There was a problem hiding this comment.
Thanks for the quick turnaround — this is nearly there. The guard is exactly what I was after, and TestFromPeer_NoContextDoesNotPanic pins it at the right level: an input built outside the option loop, which is precisely the shape pullInput produces. The indexedAtOption signature reads much better than the out-param, the uv.lock revert is right, and the "current row's time and not necessarily the first one" wording on both GetRecordIndexedAt and the interface method is the honest version.
Thanks again for the care on this one.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Signed-off-by: Paolo Valletta <[email protected]>
|
|
tkircsi
left a comment
There was a problem hiding this comment.
Approving — thanks for seeing this through, and for the patience with my nitpicking on comment placement.
Nice work — this was a pleasure to review.
Closes #2428
OperationInput.indexed_atwas declared in the proto (field 6) but neither in the operation CEL environment nor populated, so no operation policy could read it — the age half of #2128's prune rule could not be written.This declares it as an optional timestamp and populates it at
index, the one operation that decides while holding a row: the reconciler readsrecords.created_atfor the record before writing the new row, so a record that was already indexed answers the variable and a first index leaves it absent.IndexedAt(t)is aDecideOptionbesideFromPeer, soprunecan supply the same value when it starts deciding through a policy, without a new API. The lookup is skipped entirely when no policy is configured atindex, asreadsVerdictsalready does for the verdict map.Absence stays representable, so a policy writes
indexed_at.orValue(...)or testshasValue()rather than comparing against a 1970 timestamp. The docs now say which operations answer it:pushandautosyncdecide from the record alone and never read its row, so they leave it absent even for a record already indexed;indexanswers it except on a first index. That gap is why this is not the whole of #2428 —prunedoes not decide through a policy yet, and wiring it is the increment where the motivating rule becomes writable.go test ./...passes inserverandreconciler; the CEL, OPA and indexer tests cover both the present and the absent case.