P2R-01 follow-up: WS-path tests + drop unused retention from backup dispatch

Adds p2r01_ws_test.go covering the two paths the original commit's
in-process tests couldn't reach without a live conn:

- maybeAutoInit dispatches command.run(init) on first hello when creds
  are bound, skips on second hello once a job row exists, and skips
  entirely when the host has no creds.
- dispatchScheduledJob iterates a schedule's source groups and emits
  one backup per group with the right Tag/Includes; persists job rows
  with actor_kind=schedule + scheduled_id; no-ops on a disabled
  schedule.

Drops RetentionPolicy from the per-group Run-now and schedule.fire
backup payloads — the agent's RunBackup ignores it (forget is the
only consumer). Adds Hub.Conn() so tests can grab the live *Conn
post-hello.
This commit is contained in:
2026-05-03 11:00:45 +01:00
parent ec0bf0f6c3
commit d692272d10
4 changed files with 426 additions and 13 deletions
+8 -7
View File
@@ -183,14 +183,15 @@ func (s *Server) dispatchBackupForGroup(ctx context.Context, conn *ws.Conn, host
"schedule_id", scheduleID, "group", g.Name, "err", err)
return
}
retention, _ := json.Marshal(g.RetentionPolicy)
// Backup ignores RetentionPolicy — the forget cadence lives on
// host_repo_maintenance and is driven by the server-side ticker
// (P2R-06). Don't ship the field on backup dispatches.
env, err := api.Marshal(api.MsgCommandRun, jobID, api.CommandRunPayload{
JobID: jobID,
Kind: api.JobBackup,
Includes: g.Includes,
Excludes: g.Excludes,
Tag: g.Name,
RetentionPolicy: retention,
JobID: jobID,
Kind: api.JobBackup,
Includes: g.Includes,
Excludes: g.Excludes,
Tag: g.Name,
})
if err != nil {
slog.Warn("schedule.fire: marshal command.run",