dynos-core 0.2.2__tar.gz → 0.3.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dynos_core-0.3.0/LICENSE +202 -0
- {dynos_core-0.2.2 → dynos_core-0.3.0}/PKG-INFO +11 -13
- {dynos_core-0.2.2 → dynos_core-0.3.0}/README.md +6 -12
- {dynos_core-0.2.2 → dynos_core-0.3.0}/pyproject.toml +7 -1
- {dynos_core-0.2.2 → dynos_core-0.3.0}/src/dynos_core/__init__.py +30 -0
- dynos_core-0.3.0/src/dynos_core/atom.py +180 -0
- dynos_core-0.3.0/src/dynos_core/config.py +565 -0
- dynos_core-0.3.0/src/dynos_core/domain_spec.py +472 -0
- {dynos_core-0.2.2 → dynos_core-0.3.0}/src/dynos_core/factories.py +37 -4
- dynos_core-0.3.0/src/dynos_core/results.py +288 -0
- {dynos_core-0.2.2 → dynos_core-0.3.0}/src/dynos_core/state.py +5 -4
- {dynos_core-0.2.2 → dynos_core-0.3.0}/src/dynos_core/transition.py +34 -7
- {dynos_core-0.2.2 → dynos_core-0.3.0}/src/dynos_core/types.py +30 -0
- dynos_core-0.3.0/src/dynos_core/wire_types.py +71 -0
- {dynos_core-0.2.2 → dynos_core-0.3.0}/src/dynos_core.egg-info/PKG-INFO +11 -13
- {dynos_core-0.2.2 → dynos_core-0.3.0}/src/dynos_core.egg-info/SOURCES.txt +5 -0
- dynos_core-0.2.2/src/dynos_core/atom.py +0 -119
- {dynos_core-0.2.2 → dynos_core-0.3.0}/setup.cfg +0 -0
- {dynos_core-0.2.2 → dynos_core-0.3.0}/src/dynos_core/backoff.py +0 -0
- {dynos_core-0.2.2 → dynos_core-0.3.0}/src/dynos_core/extension.py +0 -0
- {dynos_core-0.2.2 → dynos_core-0.3.0}/src/dynos_core/time_parse.py +0 -0
- {dynos_core-0.2.2 → dynos_core-0.3.0}/src/dynos_core.egg-info/dependency_links.txt +0 -0
- {dynos_core-0.2.2 → dynos_core-0.3.0}/src/dynos_core.egg-info/requires.txt +0 -0
- {dynos_core-0.2.2 → dynos_core-0.3.0}/src/dynos_core.egg-info/top_level.txt +0 -0
dynos_core-0.3.0/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright 2026 Christopher Thierauf
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: dynos-core
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.3.0
|
|
4
4
|
Summary: Core symbolic-planning types and protocols shared by DYNOS packages
|
|
5
|
+
Author: Chris Thierauf
|
|
5
6
|
License: Apache-2.0
|
|
7
|
+
Project-URL: Homepage, https://dynosplan.com
|
|
8
|
+
Project-URL: Source, https://git.whoi.edu/cthierauf/dynos_public
|
|
6
9
|
Requires-Python: >=3.8
|
|
7
10
|
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
8
12
|
Requires-Dist: varname
|
|
9
13
|
|
|
10
14
|
# dynos-core
|
|
@@ -13,7 +17,7 @@ Pure-Python types for describing a planning domain. Predicates, transitions,
|
|
|
13
17
|
object types, and the world states they describe. `dynos-core` is the data
|
|
14
18
|
layer that every other DYNOS package shares.
|
|
15
19
|
|
|
16
|
-
This contains no planner, no executor, and no network code,
|
|
20
|
+
This contains no planner, no executor, and no network code, only classes
|
|
17
21
|
that define a domain. The DYNOS backend reads these structures to
|
|
18
22
|
plan/execute/monitor/verify, clients read them to talk about goals, both share
|
|
19
23
|
the same in-memory representation.
|
|
@@ -26,6 +30,8 @@ client.
|
|
|
26
30
|
|
|
27
31
|
## Install
|
|
28
32
|
|
|
33
|
+
From PyPI:
|
|
34
|
+
|
|
29
35
|
```bash
|
|
30
36
|
pip install dynos-core
|
|
31
37
|
```
|
|
@@ -102,7 +108,7 @@ goto = Transition("goto", params_type=GotoParams).define(
|
|
|
102
108
|
|
|
103
109
|
The `define()` call stores the symbolic spec on the transition. The `dynos`
|
|
104
110
|
backend extends `Transition` with cost callbacks, applicability checks, and
|
|
105
|
-
execution hooks; this package's `Transition` is
|
|
111
|
+
execution hooks; this package's `Transition` is only data.
|
|
106
112
|
|
|
107
113
|
### Extensions
|
|
108
114
|
|
|
@@ -119,15 +125,7 @@ extend_object_type(Zone, depth=ValueField(float)) # backend-only addition
|
|
|
119
125
|
|
|
120
126
|
See `extension.py` for the full rules (additive only, must run before any plan construction, etc.).
|
|
121
127
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
- No planner. The actual planning lives in the `dynos` backend (not on PyPI).
|
|
125
|
-
- No `@Action` / `@Belief` / `@Script` decorators. Those run code; this package
|
|
126
|
-
is data only. They live in the backend (and you import them from
|
|
127
|
-
`dynos.databases.typed_action` when building a backend; or via the
|
|
128
|
-
conditional-import pattern documented in `dynos-client`'s README when
|
|
129
|
-
authoring client-only code).
|
|
130
|
-
- No network or robot connectivity. That's `dynos-client`.
|
|
128
|
+
Pure types; planning and execution happen in the hosted backend.
|
|
131
129
|
|
|
132
130
|
## Public API
|
|
133
131
|
|
|
@@ -137,7 +135,7 @@ See `extension.py` for the full rules (additive only, must run before any plan c
|
|
|
137
135
|
| `World` | Frozenset of `GroundAtom`; one snapshot of the symbolic state. |
|
|
138
136
|
| `FluentBase` | Base class for fluents (rarely instantiated directly). |
|
|
139
137
|
| `make_new_fluent(name, **types)` | Factory: returns a callable that produces `GroundAtom`. |
|
|
140
|
-
| `make_new_object(type, name, **fields)` | Factory:
|
|
138
|
+
| `make_new_object(type, name, **fields)` | Factory: returns a local `SymbolicObject` reference. |
|
|
141
139
|
| `Transition` | Action schema (preconditions, effects, parameter type). |
|
|
142
140
|
| `TransitionParams` | Base class for typed parameter dataclasses. |
|
|
143
141
|
| `PrimitiveAction` | Frozen `(action_name, parameters)` pair; what flows over the wire. |
|
|
@@ -4,7 +4,7 @@ Pure-Python types for describing a planning domain. Predicates, transitions,
|
|
|
4
4
|
object types, and the world states they describe. `dynos-core` is the data
|
|
5
5
|
layer that every other DYNOS package shares.
|
|
6
6
|
|
|
7
|
-
This contains no planner, no executor, and no network code,
|
|
7
|
+
This contains no planner, no executor, and no network code, only classes
|
|
8
8
|
that define a domain. The DYNOS backend reads these structures to
|
|
9
9
|
plan/execute/monitor/verify, clients read them to talk about goals, both share
|
|
10
10
|
the same in-memory representation.
|
|
@@ -17,6 +17,8 @@ client.
|
|
|
17
17
|
|
|
18
18
|
## Install
|
|
19
19
|
|
|
20
|
+
From PyPI:
|
|
21
|
+
|
|
20
22
|
```bash
|
|
21
23
|
pip install dynos-core
|
|
22
24
|
```
|
|
@@ -93,7 +95,7 @@ goto = Transition("goto", params_type=GotoParams).define(
|
|
|
93
95
|
|
|
94
96
|
The `define()` call stores the symbolic spec on the transition. The `dynos`
|
|
95
97
|
backend extends `Transition` with cost callbacks, applicability checks, and
|
|
96
|
-
execution hooks; this package's `Transition` is
|
|
98
|
+
execution hooks; this package's `Transition` is only data.
|
|
97
99
|
|
|
98
100
|
### Extensions
|
|
99
101
|
|
|
@@ -110,15 +112,7 @@ extend_object_type(Zone, depth=ValueField(float)) # backend-only addition
|
|
|
110
112
|
|
|
111
113
|
See `extension.py` for the full rules (additive only, must run before any plan construction, etc.).
|
|
112
114
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
- No planner. The actual planning lives in the `dynos` backend (not on PyPI).
|
|
116
|
-
- No `@Action` / `@Belief` / `@Script` decorators. Those run code; this package
|
|
117
|
-
is data only. They live in the backend (and you import them from
|
|
118
|
-
`dynos.databases.typed_action` when building a backend; or via the
|
|
119
|
-
conditional-import pattern documented in `dynos-client`'s README when
|
|
120
|
-
authoring client-only code).
|
|
121
|
-
- No network or robot connectivity. That's `dynos-client`.
|
|
115
|
+
Pure types; planning and execution happen in the hosted backend.
|
|
122
116
|
|
|
123
117
|
## Public API
|
|
124
118
|
|
|
@@ -128,7 +122,7 @@ See `extension.py` for the full rules (additive only, must run before any plan c
|
|
|
128
122
|
| `World` | Frozenset of `GroundAtom`; one snapshot of the symbolic state. |
|
|
129
123
|
| `FluentBase` | Base class for fluents (rarely instantiated directly). |
|
|
130
124
|
| `make_new_fluent(name, **types)` | Factory: returns a callable that produces `GroundAtom`. |
|
|
131
|
-
| `make_new_object(type, name, **fields)` | Factory:
|
|
125
|
+
| `make_new_object(type, name, **fields)` | Factory: returns a local `SymbolicObject` reference. |
|
|
132
126
|
| `Transition` | Action schema (preconditions, effects, parameter type). |
|
|
133
127
|
| `TransitionParams` | Base class for typed parameter dataclasses. |
|
|
134
128
|
| `PrimitiveAction` | Frozen `(action_name, parameters)` pair; what flows over the wire. |
|
|
@@ -4,12 +4,18 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "dynos-core"
|
|
7
|
-
version = "0.
|
|
7
|
+
version = "0.3.0"
|
|
8
8
|
description = "Core symbolic-planning types and protocols shared by DYNOS packages"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = { text = "Apache-2.0" }
|
|
11
|
+
authors = [{ name = "Chris Thierauf" }]
|
|
11
12
|
requires-python = ">=3.8"
|
|
12
13
|
dependencies = ["varname"]
|
|
13
14
|
|
|
14
15
|
[tool.setuptools.packages.find]
|
|
15
16
|
where = ["src"]
|
|
17
|
+
|
|
18
|
+
# Documentation (https://dynosplan.com/docs) is added when the docs site is live.
|
|
19
|
+
[project.urls]
|
|
20
|
+
Homepage = "https://dynosplan.com"
|
|
21
|
+
Source = "https://git.whoi.edu/cthierauf/dynos_public"
|
|
@@ -8,9 +8,26 @@ capabilities.
|
|
|
8
8
|
|
|
9
9
|
from .atom import GroundAtom, World
|
|
10
10
|
from .factories import FluentBase, make_new_fluent, make_new_object
|
|
11
|
+
from .results import (
|
|
12
|
+
ActionResult,
|
|
13
|
+
ActionResultStatus,
|
|
14
|
+
BeliefResult,
|
|
15
|
+
ObservedStateContract,
|
|
16
|
+
normalize_observed_state,
|
|
17
|
+
)
|
|
11
18
|
from .state import And, Not, Or, State
|
|
12
19
|
from .transition import PrimitiveAction, Transition, TransitionParams
|
|
13
20
|
from .types import ObjectType, SymbolicObject, ValueField
|
|
21
|
+
from .wire_types import (
|
|
22
|
+
BLOCK_ACTION,
|
|
23
|
+
BLOCK_ORDER,
|
|
24
|
+
BLOCK_PLAN,
|
|
25
|
+
BLOCK_TYPES,
|
|
26
|
+
OBJECT_COORDINATE,
|
|
27
|
+
OBJECT_ROUTE,
|
|
28
|
+
OBJECT_ZONE,
|
|
29
|
+
PUBLIC_OBJECT_TYPES,
|
|
30
|
+
)
|
|
14
31
|
|
|
15
32
|
# Register GroundAtom as a virtual State subclass so `isinstance(atom, State)`
|
|
16
33
|
# works without forcing GroundAtom to inherit (preserves __slots__).
|
|
@@ -32,4 +49,17 @@ __all__ = [
|
|
|
32
49
|
"SymbolicObject",
|
|
33
50
|
"ObjectType",
|
|
34
51
|
"ValueField",
|
|
52
|
+
"ActionResult",
|
|
53
|
+
"ActionResultStatus",
|
|
54
|
+
"BeliefResult",
|
|
55
|
+
"ObservedStateContract",
|
|
56
|
+
"normalize_observed_state",
|
|
57
|
+
"BLOCK_ACTION",
|
|
58
|
+
"BLOCK_PLAN",
|
|
59
|
+
"BLOCK_ORDER",
|
|
60
|
+
"BLOCK_TYPES",
|
|
61
|
+
"OBJECT_COORDINATE",
|
|
62
|
+
"OBJECT_ZONE",
|
|
63
|
+
"OBJECT_ROUTE",
|
|
64
|
+
"PUBLIC_OBJECT_TYPES",
|
|
35
65
|
]
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
"""Core GroundAtom and World types.
|
|
2
|
+
|
|
3
|
+
The backend extends GroundAtom with evaluation logic (eval_given(state)).
|
|
4
|
+
"""
|
|
5
|
+
|
|
6
|
+
from typing import Any, Iterable, Optional
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class GroundAtom:
|
|
10
|
+
"""A ground first-order proposition: a predicate applied to domain objects.
|
|
11
|
+
|
|
12
|
+
Created by calling a fluent (predicate schema) with domain objects::
|
|
13
|
+
|
|
14
|
+
robot_at(room_one) -> GroundAtom("robot_at", (room_one,))
|
|
15
|
+
|
|
16
|
+
fluent_name and args are the primary representation. This class
|
|
17
|
+
is pure data; it stores a proposition but cannot evaluate it.
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
__slots__ = ("_fluent_name", "_args", "_atom_name")
|
|
21
|
+
|
|
22
|
+
def __init__(self, fluent_name: str, args: Optional[tuple] = None) -> None:
|
|
23
|
+
if not isinstance(fluent_name, str) or not fluent_name:
|
|
24
|
+
raise ValueError(
|
|
25
|
+
f"GroundAtom requires a non-empty string fluent_name "
|
|
26
|
+
f"(got {fluent_name!r}). If this atom came from calling a "
|
|
27
|
+
"fluent (e.g. `box_at(room_one, box_a)`), the fluent "
|
|
28
|
+
"itself has no name; that usually means the "
|
|
29
|
+
"make_new_fluent() call tried to infer the name from its "
|
|
30
|
+
"assignment target and the inference returned nothing "
|
|
31
|
+
"usable (no `lhs = make_new_fluent(...)` pattern; "
|
|
32
|
+
"tuple-unpack, attribute, subscript, or interactive use "
|
|
33
|
+
"with no source file all defeat it). Re-declare the "
|
|
34
|
+
"fluent with name='your_name' explicitly or as a "
|
|
35
|
+
"single-target assignment so the name is set."
|
|
36
|
+
)
|
|
37
|
+
self._fluent_name = fluent_name
|
|
38
|
+
self._args: tuple = args if args else ()
|
|
39
|
+
# Lazily-built display-string memo. Atoms are immutable and their args
|
|
40
|
+
# are named domain objects whose str() is stable, so the first build is
|
|
41
|
+
# also the last; atom_name sits under every belief delta, world hash,
|
|
42
|
+
# and snapshot stringify, so rebuilding it per access was a measurable
|
|
43
|
+
# constant factor on hot paths.
|
|
44
|
+
self._atom_name: Optional[str] = None
|
|
45
|
+
|
|
46
|
+
@property
|
|
47
|
+
def fluent_name(self) -> str:
|
|
48
|
+
"""Name of the predicate, e.g. 'robot_at'."""
|
|
49
|
+
return self._fluent_name
|
|
50
|
+
|
|
51
|
+
@property
|
|
52
|
+
def args(self) -> tuple:
|
|
53
|
+
"""The grounded domain-object arguments, e.g. (room_one,)."""
|
|
54
|
+
return self._args
|
|
55
|
+
|
|
56
|
+
@property
|
|
57
|
+
def atom_name(self) -> str:
|
|
58
|
+
"""Canonical display string, e.g. 'robot_at(room_one)'. Built once."""
|
|
59
|
+
if self._atom_name is None:
|
|
60
|
+
if self._args:
|
|
61
|
+
self._atom_name = (
|
|
62
|
+
f"{self._fluent_name}({', '.join(str(a) for a in self._args)})"
|
|
63
|
+
)
|
|
64
|
+
else:
|
|
65
|
+
self._atom_name = self._fluent_name
|
|
66
|
+
return self._atom_name
|
|
67
|
+
|
|
68
|
+
def eval_given(self, world: "World") -> bool:
|
|
69
|
+
"""Check if this atom is true in world (simple containment)."""
|
|
70
|
+
return self in world
|
|
71
|
+
|
|
72
|
+
def children(self) -> tuple:
|
|
73
|
+
"""State-tree children (none; GroundAtom is a leaf node)."""
|
|
74
|
+
return ()
|
|
75
|
+
|
|
76
|
+
def __repr__(self) -> str:
|
|
77
|
+
return self.atom_name
|
|
78
|
+
|
|
79
|
+
def __str__(self) -> str:
|
|
80
|
+
return self.atom_name
|
|
81
|
+
|
|
82
|
+
def __eq__(self, other: object) -> bool:
|
|
83
|
+
if hasattr(other, "fluent_name") and hasattr(other, "args"):
|
|
84
|
+
return self._fluent_name == other.fluent_name and self._args == other.args
|
|
85
|
+
return NotImplemented
|
|
86
|
+
|
|
87
|
+
def __hash__(self) -> int:
|
|
88
|
+
return hash((self._fluent_name, self._args))
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
class World:
|
|
92
|
+
"""An immutable belief state: the ground atoms whose truth DIFFERS from
|
|
93
|
+
their predicate's default.
|
|
94
|
+
|
|
95
|
+
A world state is a total truth assignment over all ground atoms. The compact
|
|
96
|
+
encoding is closed-world-with-per-predicate-defaults: each predicate has a
|
|
97
|
+
default extension and the state stores only the EXCEPTIONS. This type carries
|
|
98
|
+
two exception sets -- explicit True-overrides (``_atoms``) and explicit
|
|
99
|
+
False-overrides (``_false``) -- and nothing else; an atom in neither is "at its
|
|
100
|
+
predicate default".
|
|
101
|
+
|
|
102
|
+
This type is domain-agnostic DATA: it does not know predicate defaults, so it
|
|
103
|
+
cannot resolve an absent atom's truth. Resolution lives in the domain-aware
|
|
104
|
+
evaluator (the backend ``GroundAtom.eval_given``, which looks up the fluent
|
|
105
|
+
default). Here, ``in`` means "explicitly asserted True" -- which coincides with
|
|
106
|
+
truth only for default-False predicates; callers that may touch a default-True
|
|
107
|
+
predicate must evaluate through ``eval_given``, not raw ``in``.
|
|
108
|
+
|
|
109
|
+
The common all-defaults-False case is simply ``_false`` empty, so
|
|
110
|
+
``World([atoms])`` constructs exactly the legacy closed-world true-set.
|
|
111
|
+
|
|
112
|
+
Constructed from any iterable of true atoms (and optionally false-overrides)::
|
|
113
|
+
|
|
114
|
+
world = World([robot_at(room_one), carrying(box_a)])
|
|
115
|
+
world = World([phase(at_depth)], false_atoms=[phase(predive)])
|
|
116
|
+
|
|
117
|
+
Supports set algebra (``|``, ``&``, ``-``), hashing, and equality (over
|
|
118
|
+
both sets).
|
|
119
|
+
"""
|
|
120
|
+
|
|
121
|
+
__slots__ = ("_atoms", "_false")
|
|
122
|
+
|
|
123
|
+
def __init__(
|
|
124
|
+
self,
|
|
125
|
+
atoms: Iterable["GroundAtom"] = (),
|
|
126
|
+
false_atoms: Iterable["GroundAtom"] = (),
|
|
127
|
+
) -> None:
|
|
128
|
+
self._atoms: frozenset = frozenset(atoms)
|
|
129
|
+
self._false: frozenset = frozenset(false_atoms)
|
|
130
|
+
|
|
131
|
+
@property
|
|
132
|
+
def true_atoms(self) -> frozenset:
|
|
133
|
+
"""The atoms explicitly asserted True (exceptions to default-False)."""
|
|
134
|
+
return self._atoms
|
|
135
|
+
|
|
136
|
+
@property
|
|
137
|
+
def false_atoms(self) -> frozenset:
|
|
138
|
+
"""The atoms explicitly asserted False (exceptions to default-True)."""
|
|
139
|
+
return self._false
|
|
140
|
+
|
|
141
|
+
def __contains__(self, atom: object) -> bool:
|
|
142
|
+
# "Explicitly True" -- NOT full truth resolution (that needs the predicate
|
|
143
|
+
# default; see the class docstring and backend eval_given).
|
|
144
|
+
return atom in self._atoms
|
|
145
|
+
|
|
146
|
+
def __iter__(self):
|
|
147
|
+
# Iterates the explicit True-overrides (the legacy "true atoms" view).
|
|
148
|
+
return iter(self._atoms)
|
|
149
|
+
|
|
150
|
+
def __len__(self) -> int:
|
|
151
|
+
return len(self._atoms)
|
|
152
|
+
|
|
153
|
+
def __or__(self, other: "World") -> "World":
|
|
154
|
+
return World(self._atoms | other._atoms, self._false | other._false)
|
|
155
|
+
|
|
156
|
+
def __and__(self, other: "World") -> "World":
|
|
157
|
+
return World(self._atoms & other._atoms, self._false & other._false)
|
|
158
|
+
|
|
159
|
+
def __sub__(self, other: "World") -> "World":
|
|
160
|
+
return World(self._atoms - other._atoms, self._false - other._false)
|
|
161
|
+
|
|
162
|
+
def __eq__(self, other: object) -> bool:
|
|
163
|
+
return (
|
|
164
|
+
isinstance(other, World)
|
|
165
|
+
and self._atoms == other._atoms
|
|
166
|
+
and self._false == other._false
|
|
167
|
+
)
|
|
168
|
+
|
|
169
|
+
def __hash__(self) -> int:
|
|
170
|
+
return hash((self._atoms, self._false))
|
|
171
|
+
|
|
172
|
+
def __repr__(self) -> str:
|
|
173
|
+
true_names = sorted(a.atom_name for a in self._atoms)
|
|
174
|
+
if not self._false:
|
|
175
|
+
return f"World({{{', '.join(true_names)}}})"
|
|
176
|
+
false_names = sorted(a.atom_name for a in self._false)
|
|
177
|
+
return (
|
|
178
|
+
f"World({{{', '.join(true_names)}}}, "
|
|
179
|
+
f"false={{{', '.join(false_names)}}})"
|
|
180
|
+
)
|