From 33d771438f1da363af7c9ff2d5f4c368c326e84d Mon Sep 17 00:00:00 2001 From: Lukasz Kasprzak Date: Thu, 17 Sep 2026 14:03:44 +0200 Subject: {now} is the start of the run, as the spec always said MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- internal/engine/session.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'internal/engine/session.go') 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, -- cgit v1.3