-
Notifications
You must be signed in to change notification settings - Fork 0
Day 31 backlog: Go 1.26.8, backup pruning, three-runner smoke, and one honest permission answer #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
6e8e778
fe9d3f5
bd9547b
b1dd6fb
46d4d5e
ce80cd6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| package main | ||
|
|
||
| import ( | ||
| "testing" | ||
| "time" | ||
|
|
||
| "github.com/packetcode/packetcode/internal/config" | ||
| "github.com/packetcode/packetcode/internal/session" | ||
| ) | ||
|
|
||
| func TestBackupRetention(t *testing.T) { | ||
| tests := []struct { | ||
| name string | ||
| behavior config.BehaviorConfig | ||
| want time.Duration | ||
| }{ | ||
| {"unset uses the built-in default", config.BehaviorConfig{}, session.DefaultBackupMaxAge}, | ||
| {"a configured window is honoured", config.BehaviorConfig{BackupRetentionDays: 3}, 72 * time.Hour}, | ||
| {"a negative count falls back like every other cap", config.BehaviorConfig{BackupRetentionDays: -5}, session.DefaultBackupMaxAge}, | ||
| {"the disable switch beats a configured window", config.BehaviorConfig{BackupRetentionDays: 3, BackupPruneDisabled: true}, 0}, | ||
| {"the disable switch beats an unset window", config.BehaviorConfig{BackupPruneDisabled: true}, 0}, | ||
| } | ||
|
|
||
| for _, tc := range tests { | ||
| t.Run(tc.name, func(t *testing.T) { | ||
| if got := backupRetention(tc.behavior); got != tc.want { | ||
| t.Errorf("backupRetention() = %s, want %s", got, tc.want) | ||
| } | ||
| }) | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -242,6 +242,10 @@ func buildPacketRuntime(ctx context.Context, opts packetRuntimeConfig) (_ *packe | |
| } | ||
|
|
||
| rt.Backups = session.NewBackupManager(opts.BackupsDir, rt.SessionID) | ||
| // Undo cannot reach a previous run's backups, so they are dead weight on | ||
| // disk. Reclaim the stale ones once per start, before anything writes new | ||
| // ones, and never touch the tree this session is about to use. | ||
| session.PruneBackups(opts.BackupsDir, rt.SessionID, backupRetention(opts.Config.Behavior)) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
When more than one runtime is alive, age does not establish that a backup tree is unreachable. For example, an ACP server retains multiple independent runtimes in Useful? React with 👍 / 👎. |
||
| rt.Skills = skills.Load(opts.Root) | ||
| // Spilled tool output is per-session state, like the todo store: a | ||
| // background job must not be able to read or evict what the foreground | ||
|
|
@@ -474,3 +478,20 @@ func (rt *packetRuntime) Close() error { | |
| } | ||
| return errors.Join(errs...) | ||
| } | ||
|
|
||
| // backupRetention resolves the configured backup window into a duration. | ||
| // | ||
| // Zero or negative days selects the built-in default, which is how every | ||
| // other [behavior] cap reads a nonsensical value, and the explicit disable | ||
| // switch is what turns pruning off. That split matches | ||
| // loop_detection_disabled and post_edit_diagnostics_disabled rather than | ||
| // overloading the sign of a count. | ||
| func backupRetention(b config.BehaviorConfig) time.Duration { | ||
| if b.BackupPruneDisabled { | ||
| return 0 | ||
| } | ||
| if b.BackupRetentionDays <= 0 { | ||
| return session.DefaultBackupMaxAge | ||
| } | ||
| return time.Duration(b.BackupRetentionDays) * 24 * time.Hour | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As of this commit's 2026-09-05 date, Go 1.26.8 has not been released, so
actions/setup-gocannot resolve this exact version. Every job in.github/workflows/ci.ymlfails during toolchain setup, and the identical pin in.github/workflows/release.ymlalso prevents releases; use the current available 1.26 patch release instead.Useful? React with 👍 / 👎.