summaryrefslogtreecommitdiff
path: root/internal/engine/session.go
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-09-17 14:03:44 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-09-17 14:03:44 +0200
commit33d771438f1da363af7c9ff2d5f4c368c326e84d (patch)
tree32ecf16f57dcbd0edf762561dda602f37c38b657 /internal/engine/session.go
parenta65e8a0587d3e5c971bef3062dd0d8a3b5cb53b7 (diff)
downloadkrino-33d771438f1da363af7c9ff2d5f4c368c326e84d.tar.gz
krino-33d771438f1da363af7c9ff2d5f4c368c326e84d.zip
{now} is the start of the run, as the spec always said
The clock was read once per directory, so a run of several directories stamped several different times - and a review that took a few seconds could put one run's files into two folders, or at midnight two dates. The spec (ยง7.3) says "the start of the run"; krino.conf(5) documented the behaviour rather than the intent, so the two contradicted each other. The session now carries the run's clock and every directory plans with it. Engine.Plan keeps its meaning for a caller with no session of its own; Session.Plan passes the run's own start.
Diffstat (limited to 'internal/engine/session.go')
-rw-r--r--internal/engine/session.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/internal/engine/session.go b/internal/engine/session.go
index 8d5977a..09cf246 100644
--- a/internal/engine/session.go
+++ b/internal/engine/session.go
@@ -5,6 +5,7 @@ package engine
import (
"context"
"fmt"
+ "time"
"git.labunix.xyz/krino/internal/journal"
"git.labunix.xyz/krino/internal/lock"
@@ -27,6 +28,10 @@ type Session struct {
claims *plan.Claims
landed []string // where this run's applied files ended up, in order
dry bool
+
+ // started is the run's own clock: what {now:FMT} means for every
+ // directory of this run, fixed when the session begins.
+ started time.Time
}
// NewSession starts a run. The log is opened by OpenLog, or by the first
@@ -35,7 +40,7 @@ type Session struct {
// create a log a dry run would not. The caller closes the session when the
// run is over.
func (e *Engine) NewSession(dry bool) (*Session, error) {
- return &Session{e: e, claims: plan.NewClaims(), dry: dry}, nil
+ return &Session{e: e, claims: plan.NewClaims(), dry: dry, started: e.Now()}, nil
}
// OpenLog opens the log and takes the run id, once. A dry session does
@@ -86,9 +91,10 @@ func (s *Session) LockDirs(ctx context.Context, names []string, wait bool) ([]*l
return held, nil
}
-// Plan builds d's plan with the run's claims.
+// Plan builds d's plan with the run's claims, and the run's clock: every
+// directory of one run stamps {now:FMT} with the same moment.
func (s *Session) Plan(ctx context.Context, d *Dir) (*DirPlan, error) {
- return s.e.Plan(ctx, d, s.claims)
+ return s.e.PlanAt(ctx, d, s.claims, s.started)
}
// Apply carries out the approved files of dp and logs the run's steps,