-
Notifications
You must be signed in to change notification settings - Fork 24
feat(gen-sim): add TaskSpec v0.1 and guarded E2 acceptance #613
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
yuecideng
wants to merge
5
commits into
ljd/action_engine_refactor
Choose a base branch
from
codex/taskspec-v01
base: ljd/action_engine_refactor
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.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
e64874f
feat(task-spec): add canonical contracts and explicit plan provenance
yuecideng 8be7051
fix(task-program): bind registered phase protections and recover empt…
yuecideng 7e5809d
feat(gen-sim): evaluate bounded TaskSpec goals before episode acceptance
yuecideng d0fed43
fix(task-program): hold retention motion until evidence is verified
yuecideng ac32028
docs(gen-sim): clarify measured witness qualification gate
yuecideng 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
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,73 @@ | ||
| # TaskSpec semantic protocol | ||
|
|
||
| `embodichain/task_spec/` owns pure JSON task meaning, canonical task identity | ||
| and content/evidence references. It depends only on the standard library. | ||
| It does not own LLM calls, scene creation, check execution, simulation | ||
| lifecycle, retries, dataset submission or persistence. | ||
|
|
||
| ## Owning entry points | ||
|
|
||
| - `validation.py` validates template fields, role references and capability | ||
| vocabulary; `expressions.py` validates bounded predicate AST and quantities. | ||
| - `registry.py` returns a detached semantic-version/predicate-revision snapshot. | ||
| This declares semantics, not installed checkers or Semantic Calls. | ||
| - `canonicalization.py` canonicalizes roles, inverse relations and SI units. | ||
| Top-level self hash is excluded; unknown execution fields are rejected. | ||
| - `contracts.py` validates the five records, computes exact instance content | ||
| identity, checks optional template/instance owners and applies certificate | ||
| required-check acceptance. URI/digest references are not resolved here. | ||
|
|
||
| Template v0.1 permits six roles, 128 predicate occurrences and depth 16. | ||
| Canonical quantity values are exact decimal strings; accepted units are | ||
| m/cm/mm, s/ms and rad. Role relabeling is independent of spelling/order, | ||
| including equal role declarations. Temporal sequence order remains normative. | ||
| These are restricted equivalences, not arbitrary formula equivalence. | ||
|
|
||
| SceneInstance owns grounded roles, assets, scene/embodiment and observed | ||
| initial-state references. Instance roles are canonical IDs; use | ||
| `canonical_role_map` to rekey author grounding and evaluate the corresponding | ||
| `canonical_template`. This prevents ambiguous physical meaning under role | ||
| alpha-renaming. ActionWitness owns graph/program/integration/policy/ | ||
| constraints and execution evidence; candidate execution is null. Existing | ||
| integration_fingerprint is reused. Certificate checks bind template, instance, | ||
| witness and one env/episode, with explicit versions, metrics and evidence. | ||
| Missing/not_run/unavailable/unsupported/failed required checks do not pass. | ||
| Hosts must verify evidence content before accepting report statuses. | ||
|
|
||
| ## GenSim boundary | ||
|
|
||
| `SemanticTaskPlanner.plan(task_template=..., scene_instance=...)` consumes | ||
| paired explicit inputs and emits a candidate `semantic_task_graph/v2`. | ||
| It verifies physical-object bindings and records template_hash, instance_hash | ||
| and legacy_plan_hash. The existing recipe remains a proposed solution and | ||
| does not redefine or prove the normative goal. | ||
|
|
||
| Without TaskSpec inputs, TaskCandidate and graph/v1 behavior is unchanged. | ||
| `task_program_bundle.py` and `_bundle_runner.py` refuse v2 export/execution | ||
| until measured instance/witness evidence qualification exists. | ||
|
|
||
| An independent opt-in E2 acceptance route passes an explicit template through | ||
| CLI `--task-template`, Workflow and bundle generation. It keeps graph/v1 as the | ||
| executable recipe and writes a strict template/binding sidecar referenced by | ||
| fingerprint/v3. `lab/task_evaluation.py` accepts only one local-+Z upright goal | ||
| and optional initially-not-upright constraint; other requirements fail early. | ||
| `compute/task_predicates.py` owns shared angle measurement. GenSim stability | ||
| policies derive their upright threshold from the explicit template. | ||
|
|
||
| The runner captures actual reset/settled poses and refuses invalid, unavailable | ||
| or trivial initial batches. Its final hook evaluates simultaneous final poses | ||
| after cleanup and before Gym metadata/commit/reset. Program and task results | ||
| are separate. The host owns evidence files, not the evaluator. The result is | ||
| observed-goal-only with certificate_status=unavailable: it does not construct | ||
| a qualified SceneInstance/ActionWitness or assert asset/whole-process/robustness | ||
| certification. TaskAgent migration, template-derived scene generation, other | ||
| predicate checkers, Workflow certificates and expansion hosting remain future | ||
| work. See [GenSim](../gen-sim/gen-sim.md). | ||
|
|
||
| ## Focused validation | ||
|
|
||
| Run `tests/task_spec/` for identity, schema, quantity and evidence boundaries. | ||
| Run `tests/gen_sim/task_engine/test_task_spec_planning.py` and existing | ||
| `test_agent.py`/`test_semantic_graph.py` for the paired planning entry, | ||
| graph versions and legacy compatibility. These CPU tests do not certify | ||
| physical rollout or installed predicate observers. |
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,17 @@ | ||
| Task observation evaluation | ||
| =========================== | ||
|
|
||
| These measurements and evaluators do not own simulation stepping, reset, | ||
| retries or persistence. The initial implementation qualifies instantaneous | ||
| local-+Z upright observations only; process and unsupported requirements are | ||
| rejected explicitly, and invalid pose rows are unavailable rather than passing. | ||
|
|
||
| .. autosummary:: | ||
|
|
||
| embodichain.compute.task_predicates.axis_tilt | ||
| embodichain.lab.task_evaluation.UprightTaskEvaluator | ||
|
|
||
| .. autofunction:: embodichain.compute.task_predicates.axis_tilt | ||
|
|
||
| .. autoclass:: embodichain.lab.task_evaluation.UprightTaskEvaluator | ||
| :members: |
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,78 @@ | ||
| TaskSpec semantic contracts | ||
| =========================== | ||
|
|
||
| TaskSpec v0.1 separates normative task identity from grounded instances and | ||
| candidate or executed solutions. All decoders return detached JSON records, | ||
| reject unknown fields and avoid simulator, execution and filesystem ownership. | ||
|
|
||
| Task identity includes roles, initial/final conditions, invariants, explicit | ||
| temporal sequences and capability requirements. It excludes concrete assets, | ||
| robots, plans and trajectories by rejecting them at the template boundary. | ||
| Canonical quantities use exact decimal strings in SI units; supported units are | ||
| m/cm/mm, s/ms and rad. Role renaming, inverse spatial relations and commutative | ||
| sorting are supported; arbitrary logical equivalence is not. | ||
|
|
||
| A certificate is a report record, not a verifier. Required checks must exist | ||
| and pass with matching input identities, checker/predicate versions and | ||
| evidence references. Hosts must verify referenced content and observations. | ||
| Unavailable/not-run/unsupported checks cannot be accepted as passes. | ||
|
|
||
| Public package interface | ||
| ------------------------ | ||
|
|
||
| .. automodule:: embodichain.task_spec | ||
| :members: | ||
| :imported-members: | ||
|
|
||
| Canonicalization | ||
| ---------------- | ||
|
|
||
| Templates are bounded to six roles, 128 predicate occurrences and logical depth | ||
| 16. Canonicalization compares all relabelings within equal role declarations, | ||
| preserving normative temporal order. The stored semantic hash is excluded only | ||
| at the top level, so hashing an already sealed template is stable. | ||
|
|
||
| .. automodule:: embodichain.task_spec.canonicalization | ||
| :members: | ||
|
|
||
| Records and acceptance | ||
| ---------------------- | ||
|
|
||
| Instances own grounded asset/component and observed initial-state references. | ||
| Instance bindings use canonical role IDs, obtained through canonical_role_map, | ||
| and checkers consume canonical_template against these bindings. Author labels | ||
| cannot be used directly: equivalent templates may permute their meanings. | ||
| Witnesses own program/integration/policy/constraint and execution references. | ||
| An expansion records lineage and invalidated checks without scheduling them. | ||
| A certificate binds checks to one template, instance, witness and episode. | ||
|
|
||
| .. automodule:: embodichain.task_spec.contracts | ||
| :members: | ||
|
|
||
| Expression and vocabulary boundaries | ||
| ------------------------------------- | ||
|
|
||
| Predicate quantities are explicit, dimensional and nonnegative except signed | ||
| revolute-joint positions. The coordinate convention is scene +X right, +Y front, | ||
| +Z up. The vocabulary describes bounded geometry and attachment observations; | ||
| it does not assert installed evaluators, liquid transfer, force support or | ||
| continuous-contact proof. | ||
|
|
||
| .. automodule:: embodichain.task_spec.expressions | ||
| :members: | ||
|
|
||
| .. automodule:: embodichain.task_spec.registry | ||
| :members: | ||
|
|
||
| .. automodule:: embodichain.task_spec.validation | ||
| :members: | ||
|
|
||
| GenSim candidate graph version | ||
| ------------------------------ | ||
|
|
||
| The optional TaskSpec planner entry preserves the legacy candidate step hash | ||
| as provenance, emits v2 candidate graphs and retains the v1 path unchanged. | ||
| Bundle export and execution reject v2 until final task evaluation is integrated before data | ||
| submission and reset. This interface is not a certified rollout path. | ||
|
|
||
| .. autodata:: embodichain.gen_sim.task_engine.semantic_graph.TASK_SPEC_GRAPH_SCHEMA |
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,39 @@ | ||
| # ---------------------------------------------------------------------------- | ||
| # Copyright (c) 2021-2026 DexForce Technology Co., Ltd. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # ---------------------------------------------------------------------------- | ||
|
|
||
|
|
||
| """Stateless batched measurements used by task policies and final evaluation.""" | ||
|
|
||
| from __future__ import annotations | ||
| import torch | ||
|
|
||
| __all__ = ["axis_tilt"] | ||
|
|
||
|
|
||
| def axis_tilt(pose: torch.Tensor, local_axis: torch.Tensor) -> torch.Tensor: | ||
| """Measure tilt with atan2, preserving small angles in float32 observations. | ||
|
|
||
| Args: | ||
| pose: Batched rigid transforms, shaped ``(N, 4, 4)``. | ||
| local_axis: Unit local axis, shaped ``(3,)``. | ||
|
|
||
| Returns: | ||
| Tilt in radians as float64, shaped ``(N,)``. Invalid numbers propagate. | ||
| """ | ||
| if pose.ndim != 3 or pose.shape[-2:] != (4, 4) or local_axis.shape != (3,): | ||
| raise ValueError("Expected poses (N, 4, 4) and one local axis (3,).") | ||
| axis = pose[:, :3, :3].double() @ local_axis.double() | ||
| return torch.atan2(torch.linalg.vector_norm(axis[:, :2], dim=-1), axis[:, 2]) | ||
Oops, something went wrong.
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.
This public API documents
local_axisas a unit vector but validates only its shape. A caller can pass a zero axis, for whichatan2(0, 0)produces a plausible zero tilt that downstream threshold checks may treat as upright. Validating or normalizing finite, nonzero axes here would prevent misleading orientation measurements.Prompt To Fix With AI