-
Notifications
You must be signed in to change notification settings - Fork 12
Let a plan name one task twice, and number its nodes #738
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
|
|
@@ -164,6 +164,8 @@ class TaskNode(Cascade): | |
|
|
||
| task_id: TaskRef | ||
| endpoints: list[Endpoint] | None = Field(default=None, min_length=1) | ||
| # This node's index in the plan's task list, stamped by `EvalPlan._number_the_nodes`. | ||
| position: int = Field(default=0, ge=0, exclude=True) | ||
|
|
||
| @model_validator(mode='before') | ||
| @classmethod | ||
|
|
@@ -223,8 +225,15 @@ def _states_a_count(self) -> Self: | |
| return self | ||
|
|
||
| @model_validator(mode='after') | ||
| def _each_task_appears_once(self) -> Self: | ||
| _require_unique_names([task.task_id for task in self.tasks], 'the plan') | ||
| def _number_the_nodes(self) -> Self: | ||
| """Stamp each node with its place in the list, which identifies it. | ||
|
|
||
| A plan may name one catalogue task twice, each node with its own scene, so `task_id` names | ||
| no single node and the position does. The stamp overwrites a value a caller sent: the index | ||
| is the only answer consistent with where the node sits. | ||
| """ | ||
| for position, task in enumerate(self.tasks): | ||
| task.position = position | ||
|
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.
Rule hidden-dependency violated: AGENTS.md reference: AGENTS.md:L7-L8 Useful? React with 👍 / 👎. |
||
| return self | ||
|
|
||
| @model_validator(mode='after') | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
Rule earn-its-place violated:
TaskNode.positionduplicates the index already encoded byEvalPlan.tasks; because these Pydantic models and their task lists remain mutable, reversing, inserting into, or appending totasksafter validation leaves the stored positions stale and can key coordinator records to the wrong nodes. Derive the position withenumerate()when filing nodes, or encapsulate all list mutation so numbering is recomputed.AGENTS.md reference: AGENTS.md:L7-L8
Useful? React with 👍 / 👎.