Repository navigation
fleet(pools): refuse pool-drawn seatings at >=97% monthly, >1pp/h pace, or steward hard-stop (#2732) #12895
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
Open
dezren39
wants to merge
1
commit into
main
Choose a base branch
from
lane-code-i/2732-monthly-pace-guard
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+253
−5
Open
fleet(pools): refuse pool-drawn seatings at >=97% monthly, >1pp/h pace, or steward hard-stop (#2732) #12895
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,129 @@ | ||
| package placement | ||
|
|
||
| import ( | ||
| "strings" | ||
| "testing" | ||
| "time" | ||
| ) | ||
|
|
||
| // TestMonthlyPaceGuard is the first slice of issue #2732: a seating attempt | ||
| // against a pool at/above the 97% monthly guard, with a trailing pace above | ||
| // 1pp/h toward a wall, or under a steward hard-stop, is refused (with the | ||
| // pool, the % read, and the guard source in the refusal) instead of seating | ||
| // silently. Unknown state never refuses: a B4 reliance and a non-pool | ||
| // option proceed, per burn rules B4/B5. | ||
| func TestMonthlyPaceGuard(t *testing.T) { | ||
| p := testPolicy(t) | ||
| now := time.Date(2026, 11, 22, 3, 0, 0, 0, time.UTC) | ||
| fresh := now.Add(-10 * time.Minute) | ||
|
|
||
| pct := func(f float64) *float64 { return &f } | ||
| pace := func(f float64) *float64 { return &f } | ||
|
|
||
| judgement := func(pool string, monthly *float64, pph *float64, hardStop bool) Answers { | ||
| return Answers{ | ||
| Task: "queue task test / issue #2732", | ||
| Q4Judgement: true, | ||
| PoolReadAt: &fresh, | ||
| PoolID: pool, | ||
| PoolMonthlyPct: monthly, | ||
| PoolPacePph: pph, | ||
| PoolHardStop: hardStop, | ||
| } | ||
| } | ||
|
|
||
| t.Run("monthly at 97 refuses", func(t *testing.T) { | ||
| _, err := Evaluate(p, judgement("chatgpt-plan", pct(97.0), pace(0.1), false), now) | ||
| if err == nil { | ||
| t.Fatal("expected a monthly-guard refusal at 97%") | ||
| } | ||
| msg := err.Error() | ||
| for _, want := range []string{"chatgpt-plan", "97", "monthly"} { | ||
| if !strings.Contains(msg, want) { | ||
| t.Fatalf("refusal %q does not cite %q (pool, %%, guard source)", msg, want) | ||
| } | ||
| } | ||
| }) | ||
|
|
||
| t.Run("monthly below 97 seats", func(t *testing.T) { | ||
| rec, err := Evaluate(p, judgement("chatgpt-plan", pct(96.9), pace(0.1), false), now) | ||
| if err != nil { | ||
| t.Fatalf("Evaluate below the guard: %v", err) | ||
| } | ||
| if rec.Option != "Muse" || rec.Rule != "R6" { | ||
| t.Fatalf("got %s/%s, want Muse/R6", rec.Option, rec.Rule) | ||
| } | ||
| }) | ||
|
|
||
| t.Run("pace above 1pp/h refuses", func(t *testing.T) { | ||
| _, err := Evaluate(p, judgement("meta-pool", pct(90.0), pace(1.2), false), now) | ||
| if err == nil { | ||
| t.Fatal("expected a pace-guard refusal above 1pp/h") | ||
| } | ||
| msg := err.Error() | ||
| for _, want := range []string{"meta-pool", "pace"} { | ||
| if !strings.Contains(msg, want) { | ||
| t.Fatalf("refusal %q does not cite %q", msg, want) | ||
| } | ||
| } | ||
| }) | ||
|
|
||
| t.Run("pace at 1pp/h seats", func(t *testing.T) { | ||
| if _, err := Evaluate(p, judgement("meta-pool", pct(90.0), pace(1.0), false), now); err != nil { | ||
| t.Fatalf("Evaluate at exactly 1pp/h: %v", err) | ||
| } | ||
| }) | ||
|
|
||
| t.Run("steward hard-stop refuses at any pct", func(t *testing.T) { | ||
| _, err := Evaluate(p, judgement("plan-routes", pct(42.0), pace(0.0), true), now) | ||
| if err == nil { | ||
| t.Fatal("expected a hard-stop refusal") | ||
| } | ||
| if msg := err.Error(); !strings.Contains(msg, "hard-stop") { | ||
| t.Fatalf("refusal %q does not cite its guard source", msg) | ||
| } | ||
| }) | ||
|
|
||
| t.Run("B4 reliance proceeds despite the guard", func(t *testing.T) { | ||
| stale := now.Add(-2 * time.Hour) | ||
| rec, err := Evaluate(p, Answers{ | ||
| Task: "queue task test / issue #2732", | ||
| Q4Judgement: true, | ||
| PoolReadAt: &stale, | ||
| PoolReadUnobtainable: true, | ||
| PoolID: "chatgpt-plan", | ||
| PoolMonthlyPct: pct(99.5), | ||
| PoolHardStop: true, | ||
| }, now) | ||
| if err != nil { | ||
| t.Fatalf("B4 reliance must never refuse (B4 governs, not the guard): %v", err) | ||
| } | ||
| if !rec.B4Relied { | ||
| t.Fatal("record does not carry the B4 reliance") | ||
| } | ||
| }) | ||
|
|
||
| t.Run("non-pool option ignores guard inputs", func(t *testing.T) { | ||
| rec, err := Evaluate(p, Answers{ | ||
| Q1Mechanical: true, | ||
| PoolID: "chatgpt-plan", | ||
| PoolMonthlyPct: pct(99.5), | ||
| PoolHardStop: true, | ||
| }, now) | ||
| if err != nil { | ||
| t.Fatalf("non-pool placement must ignore the monthly guard: %v", err) | ||
| } | ||
| if rec.PoolReadAt != "n/a" { | ||
| t.Fatalf("pool_read_at = %q, want n/a", rec.PoolReadAt) | ||
| } | ||
| }) | ||
|
|
||
| t.Run("no monthly data seats on a fresh read", func(t *testing.T) { | ||
| if _, err := Evaluate(p, Answers{ | ||
| Q4Judgement: true, | ||
| PoolReadAt: &fresh, | ||
| }, now); err != nil { | ||
| t.Fatalf("a fresh read with no monthly data must seat: %v", err) | ||
| } | ||
| }) | ||
| } |
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
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.
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.
For an E1 exception choosing a pool-drawn option with a fresh read at ≥97%, pace >1pp/h, or a hard-stop,
exceptionRecordstill callsbuildRecord, so this unconditional check rejects the exception instead of emitting its record. This contradicts the newly documented E1 bypass inplacement/README.mdand prevents dispatchers from using the advertised recorded override. Skip the monthly guard whenruleID == "exception", while preserving the existing quota-read checks.Useful? React with 👍 / 👎.