Customize Scheduling
A schedulable Dayu policy is assembled from three surfaces:
- registered hook implementations under
dependency/core/lib/algorithms/; - a Scheduler template under
template/scheduler/that selects aliases and parameters; - an installable catalog entry in
template/scheduler_policies.yamlthat selects the Scheduler and its dependent Generator, Controller, Distributor, and Monitor templates.
Scheduler hook families
| Hook | Responsibility |
|---|---|
SCH_CONFIG_EXTRACTION | Load policy configuration spaces and mounted assets. |
SCH_SCENARIO_RETRIEVAL | Convert completed tasks into policy state. |
SCH_POLICY_RETRIEVAL | Recover the policy applied to a task. |
SCH_STARTUP_POLICY | Provide a safe schedule before the agent has enough state. |
SCH_SELECTION_POLICY | Select one source node from Backend-authorized candidates. |
SCH_INITIAL_DEPLOYMENT_POLICY | Return the first complete processor deployment plan. |
SCH_REDEPLOYMENT_POLICY | Return a later complete processor deployment plan. |
SCH_AGENT | Maintain per-source state and generate task schedule decisions. |
Current scheduling contracts
- Source selection operates only on the candidate scope supplied by Backend and must not discover cluster topology.
- Initial deployment and redeployment return a complete
logical service -> [node hostname, ...]map for the current DAG. Unknown services, empty placements, and non-candidate nodes fail validation. BaseAgentvalidates deployment plans against the current request and injected cloud identity.- The validated Scheduler result is the complete desired Processor topology. Backend materializes it unchanged and
never appends replicas. Policies select cloud placement explicitly through choices such as
cloud,full,source-edge-cloud, fixed@cloudtargets, orinclude_cloud;full-edgeremains edge-only. - Runtime routing is not a policy output. Scheduler and Backend attach the committed RuntimeDirectory revision and exact routes after validating the policy result.
- Immediate offloading decisions should use a
LIVEscheduling snapshot and select only replicas active in that revision. Commitment-aware planning should useCOMMITTED, which also includes reservations, active commitments, and task barriers. Telemetry must match the RuntimeDirectory revision being used. - Pipeline-only policies may use the shared edge-to-cloud partition helpers. General DAG policies must preserve the full graph and reject unsupported branches, joins, cycles, or inactive targets instead of silently linearizing them.
- A scheduling agent must not mutate the copied snapshot or other shared framework state.
Add a policy
- Start from the closest existing hook and template family.
- Implement a self-contained hook as a public
.pyentry, or use an algorithm package withhook.pywhen the policy owns helpers, models, or related variants. - Register each class with
@ClassFactory.register(ClassType.<TYPE>, alias="<name>"), expose it through__all__, and keep package internals explicitly imported fromhook.py. - Add constructor parameters through the matching
<TYPE>_PARAMETERSvalue in the Scheduler template. - Keep policy assets under an explicit mounted path and document whether optional ML dependencies are required.
- Add a unique policy ID to
template/scheduler_policies.yamland choose component dependencies appropriate to the policy's source and monitor needs. - Add focused tests for alias loading, request validation, schedule output, deployment-plan validation, and fallback behavior.
- Run
make validate-build, the relevant Python tests, andmake checkwhere dependencies are available.
Do not add Kubernetes clients or route lookup code to a policy. Backend owns cluster access, Scheduler owns route publication, and runtime tasks carry the exact route commitment.
The complete alias catalog and call signatures are maintained in the system repository: Hook Guide and Hook Catalog.