fix: tier-targeting follow-ups — scheduler pool re-check, region job filter, tier UX, OpenAPI - #122
Conversation
…filter, tier UX, OpenAPI Closes the four non-critical findings from PR #121's review: - Scheduler re-checks session×pool composition each tick via the new pure sessionPoolViolation() (permissions.ts): a public/team schedule whose workflow LATER gains a login-class secret is disabled instead of emitting an unclaimable session job every tick. - Jobs-list filter moves from exact site to region base (?region=): matches claimed rows by site prefix AND pending pooled rows by targetRegion, so queued jobs no longer vanish under the filter; console dropdown now uses region options. - run-targets marks the team tier unavailable (reason "session-injected") when the run route would 403 it; both run dialogs hop the selected tier to the first available option when live tier data arrives. - OpenAPI: EvalJob.siteId nullable + targetRegion/targetTier documented. 🤖 Built with SMT <smt@agora.build>
🤖 Codex Code ReviewFindings
Notes
|
🤖 Claude Code ReviewOverall this is a solid, well-targeted follow-up — the scheduler re-check closes a real TOCTOU (mutable workflow secrets vs. a tier chosen at schedule-creation time), and the pooled-job region filter fixes a genuine "pending jobs vanish" bug. A few issues worth addressing: Medium1. The The PR fixes the Concrete failure: user X runs a public workflow owned by Y that references a login-class secret. const sessionDispatchAllowed = !needsSession ||
workflow.ownerId === user.id ||
(workflow.organizationId != null && sameOrg({ organizationId: user.organizationId }, { organizationId: workflow.organizationId }));and gating Related: if no tier is available the 2.
if (targetTier === "private") return null;
if (targetTier === "team") { ...check...; return null; }
return `credential-injected jobs cannot use the ${targetTier} pool`;That also future-proofs it if Low3. Region LIKE filter is over-inclusive across prefix-colliding baseIds —
Sites are always 4. 5. Silent API contract change. Nits
The new tests in |
… gate, exact region match PR #122 review round: private tier no longer advertised (and auto-hopped into) for a non-owner's session-injected workflow — all pooled tiers now mirror the run route's owner-or-org session rule; sessionPoolViolation is allowlist-shaped so reserved/unknown tiers fail closed; the region job filter anchors sites to <base>-NN (no prefix-collision with longer baseIds); the removed siteId filter param 400s with a pointer to region. 🤖 Built with SMT <smt@agora.build>
🤖 Codex Code ReviewFindings
Notes
|
🤖 Claude Code ReviewReviewed the full diff against merge base A few things worth addressing: 1. Region filter drops index usage (
The route already resolves the region location and has or(inArray(evalJobs.siteId, filters.sites), and(isNull(evalJobs.siteId), eq(evalJobs.targetRegion, filters.region)))2. Legacy schedules get hard-disabled with no user-visible reason ( Migration 3. Redundant disjunct in the team-tier gate (
4. Disabled tiers render with no reason text ( Only 5. Auto-hop has no all-unavailable branch (same two files) When 6. Minor: |
…dback Second review round on PR #122: - Scheduler runs the PURE session-need detector (evaluateSessionRequirement) BEFORE stampOwnerSession, so a schedule about to be disabled for a pool violation no longer burns one brokered login attempt via the mint pre-warm. - Drop the redundant team-gate disjunct (teamBlockedBySession subsumes it). - Disabled tiers now say why ("not allowed for credential-injected workflows"); pooled submit is gated when every tier is unavailable, so the Run button can no longer submit into a guaranteed 403. 🤖 Built with SMT <smt@agora.build>
🤖 Codex Code ReviewFindings
Notes
|
🤖 Claude Code ReviewThe changes are sound overall — the security posture is solid (the region value is whitelist-validated against 1. Region filter defeats the
|
…gate submit during fetch Third review round on PR #122: - run-now takes the same pure session×pool pre-check as the scheduler tick (400 with reason instead of minting + queueing an unclaimable job when the workflow gained login secrets after the schedule was created). - Region job filter narrows via a sargable range on the (status, site_id) b-tree before the exactness regex; storage-level test pins the prefix-colliding-baseId guard (na-us-ashburn vs na-us-ashburn-west). - Run buttons disabled while the run-targets query is in flight (fast click could previously submit into a 403 before tier data arrived); hoisted isTeamWorkflow; shared tier excluded from the all-unavailable check. 🤖 Built with SMT <smt@agora.build>
🤖 Claude Code ReviewFindings🔴 Blocking —
|
…ngle source Fourth review round on PR #122: - Drop the range bounds from the region job filter — the 'ï¿¿' sentinel is collation-dependent (glibc locales sort it BEFORE digits, silently hiding every claimed row on en_US.UTF-8 databases while alpine's C collation makes local tests falsely green). The regex alone is exact under all collations; migration 0023 guarantees site shape. - The run route's pooled session checks now CALL sessionPoolViolation instead of open-coding the same rule (the drift the helper exists to prevent); its doc comment states the deliberate scope (pool-composition arm only, not the dispatcher owner-or-org gate). - Region lookups use getRegionLocationByBaseId instead of scanning getAllRegionLocations per request (jobs filter, run route, schedule create/PATCH). 🤖 Built with SMT <smt@agora.build>
…ngle source Fourth review round on PR #122: - Drop the range bounds from the region job filter — the U+FFFF sentinel is collation-dependent (glibc locales sort it BEFORE digits, silently hiding every claimed row on en_US.UTF-8 databases while alpine's C collation makes local tests falsely green). The regex alone is exact under all collations; migration 0023 guarantees site shape. - The run route's pooled session checks now CALL sessionPoolViolation instead of open-coding the same rule (the drift the helper exists to prevent); its doc comment states the deliberate scope (pool-composition arm only, not the dispatcher owner-or-org gate). - Region lookups use getRegionLocationByBaseId instead of scanning getAllRegionLocations per request (jobs filter, run route, schedule create/PATCH). 🤖 Built with SMT <smt@agora.build>
7b35e12 to
485acfb
Compare
🤖 Codex Code ReviewNo findings. I reviewed the PR diff with a security/logic/performance focus. The scheduler re-check, region-based job filtering, tier availability changes, and OpenAPI updates look consistent with the described intent. I didn’t see a concrete auth bypass, secret exposure, injection issue, or behavior regression in the changed code. Residual risk: I did not run the test suite because the environment is read-only; this review is based on static inspection of the diff and surrounding context. |
🤖 Claude Code ReviewReviewReviewed the merge ref ( Security — no issues found.
Findings1.
2.
3. Agent picker still offers 403-guaranteed targets (never-offer-a-403 gap)
4.
Minor
Nothing here blocks merge; items 1–3 are follow-up candidates. |
🤖 Claude Code ReviewReviewThe core refactor is sound. Findings, roughly by importance: 1. The "single source of truth" is still triplicated (
2.
These converge today only because 3. The never-offer-a-403 contract doesn't cover the agent picker (
4. Re-enabling a schedule skips the composition re-check ( The session check inside the owner-gated block fires only on 5. The new guard queries the owner's/org's secrets, then 6. The region filter is no longer index-usable (
Smaller notes: The OpenAPI additions ( |
…flapping re-enable (#123) The two cheapest follow-ups from PR #122's final review: - Schedule POST and PATCH now CALL sessionPoolViolation instead of carrying byte-identical open-coded copies of the public/team session checks — the drift the helper exists to prevent (run route, scheduler tick, run-now, and both schedule writes now share one rule). - The PATCH re-check fires on re-enable as well as tier change: a schedule the scheduler auto-disabled for a pool violation previously re-enabled fine and was silently disabled again next tick (log-only flap); it now returns an actionable 403 telling the user to change the tier first. 🤖 Built with SMT <smt@agora.build>
Summary
Closes the four non-critical findings from PR #121's code review:
public/teamschedule whose workflow later gains a login-class secret would emit an unclaimable session-injected job every tick (each riding the 24h backstop). The scheduler now re-checks via a new puresessionPoolViolation()gate (unit-tested) and disables violating schedules, mirroring the existing misconfigured-credentials handling.GET /api/eval-jobsfilter moves from exact?siteId=to?region=<baseId>— matching claimed rows by site prefix AND pending pooled rows bytargetRegion, so queued jobs no longer disappear under the filter. Console dropdown switches to region options.run-targetsnow marksteamunavailable (reasonsession-injected) exactly when the run route would 403 it (personal session workflow); both run dialogs hop the selected tier to the first available option once live tier data arrives, so the default action can't 403.EvalJob.siteIdmarked nullable with claim-stamp semantics documented;targetRegion/targetTieradded.Test plan
sessionPoolViolation(public always blocked; team requires workflow∈creator's org; private never blocked).site-id-wire,api.test).tscclean; full gate: audio + E2E PASSED; unit 1583 passed with the only 2 failing files re-verified green in isolation (documented environmental races: parallel schema teardown in credits-repo; admin-org pollution from api.test's own org suite).Generated with SMT smt@agora.build