fold: deterministic CreatedAt from persisted applied_at#54
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR makes fold replay and runtime application deterministic by threading explicit timestamps through fold evaluation, so node/relation CreatedAt is derived from persisted log timestamps (AppliedAt, with Timestamp fallback) rather than the wall clock.
Changes:
- Add
fold.EvaluateAt/fold.EvaluateProgramAtand update runtime paths to pass the exact persistedAppliedAtsoCreatedAtmatches the log. - Update replay to use persisted timestamps (
AppliedAt→Timestamp→ zero time) to keep replay deterministic even for legacy/malformed log lines. - Strengthen determinism tests to assert full node equality and validate the timestamp fallback behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/kernel/runtime.go | Threads a single captured AppliedAt into fold evaluation for Apply/ApplyProgram/reactive/local_t so persisted timestamps match fold CreatedAt. |
| internal/fold/replay.go | Uses persisted AppliedAt/Timestamp (else stable zero time) when folding during replay to avoid wall-clock dependence. |
| internal/fold/program.go | Introduces EvaluateProgramAt to accept caller-supplied per-envelope timestamps for deterministic CreatedAt in batch evaluation. |
| internal/fold/evaluate.go | Introduces EvaluateAt and updates ADD/LINK folding to use provided timestamps for CreatedAt. |
| internal/fold/fold_test.go | Updates CI-4 determinism test to compare full nodes and asserts CreatedAt preservation + timestamp fallback. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
26
to
+30
| for i, env := range envelopes { | ||
| next, result, err := Evaluate(working, env) | ||
| ts := time.Now().UTC() | ||
| if i < len(appliedAt) { | ||
| ts = appliedAt[i] | ||
| } |
Fold Copilot PR #54 catch: partially-filled appliedAt now errors instead of falling back to wall-clock timestamps, preserving replay determinism guarantees. authored-by: agent:vscode.hp-laptop.wolfram / session:sam.kernel-proper / t250-createdat-determinism
Collaborator
Author
|
Folded Copilot catch from #147 conventions brief:
Validation: go test ./... passed. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
HG URN: urn:moos:session:sam.kernel-proper
Summary
Why
Replay determinism previously depended on runtime wall clock for ADD/LINK CreatedAt, which made reconstructed state time-dependent. This changes fold state derivation so structural CreatedAt is deterministic from persisted log payload.
Finding provenance
Validation
Notes