feat(schedules): PR-5a hardening — lean-image guard + clearable schedule fields#569
Merged
Merged
Conversation
…trands imports Add an AST-based test asserting the modules bundled into backend/Dockerfile.scheduled-runs (harness/, scheduled_prompts/, sessions_bff/, sessions/ + the two lambda handlers) never import agents/ or strands — top level OR lazy, since a deferred import still crashes at call time in the lean image. This is the guard that would have caught the ModuleNotFoundError shipped in the first cut of the worker. Co-Authored-By: Claude Opus 4.8 <[email protected]>
B1's update_scheduled_prompt skipped None, so a PATCH could never detach a schedule's assistant or reset its tool restriction — the SPA's clear checkboxes were inert (a bare null reads as 'leave unchanged'). Add an explicit clear contract: an UNSET sentinel in the service distinguishes 'omitted' (leave) from None (clear -> REMOVE the attribute). UpdateScheduleRequest gains clearAssistant/clearTools booleans (rejected if combined with a value). clearAssistant reverts to the default agent; clearTools re-snapshots the caller's current RBAC-allowed tools, mirroring creation so a schedule never stores an unresolved None. SPA sends the flags. Co-Authored-By: Claude Opus 4.8 <[email protected]>
27b6f78 to
794014e
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
PR-5a hardening for scheduled runs (follow-up to the #566/#567 lean-image fixes and #563 B1 CRUD). Two independent commits.
1. Lean-image import guard (test-only)
An AST test asserts the modules bundled into
Dockerfile.scheduled-runs(harness/,scheduled_prompts/,sessions_bff/,sessions/+ both lambda handlers) never importagents/strands— top level or lazy (a deferred import still crashes at call time in the lean image, as we saw live). This is the guard that would have caught theModuleNotFoundError: No module named 'agents'that shipped in the first worker cut. Deliberately narrower than forbidding allapis.shared → agents(e.g.quota.pylegitimately importsagentsand is not in the lean image).2. Clearable schedule fields (B1 gap)
update_scheduled_promptskippedNone, so a PATCH could never detach a schedule's assistant or reset its tool restriction — the SPA's clear checkboxes were inert (a bare null reads as "leave unchanged").UNSETsentinel distinguishes "omitted" (leave) fromNone(clear →REMOVEthe attribute).UpdateScheduleRequestgainsclearAssistant/clearToolsbooleans, rejected (422) if combined with a value.clearAssistantreverts to the default agent;clearToolsre-snapshots the caller's current RBAC-allowed tools (mirrors creation — a schedule never stores an unresolvedNone).Verification
ng test.Deferred (noted, not in this PR)
defaultrole grant before releasing scheduled runs tomain(dev-ai'sdefaulthas*, so it's effectively GA there).apis/shared/quota.pyhas the sameapis.shared → agentscoupling (not in the lean-image path).🤖 Generated with Claude Code