dynos-core 0.2.2__tar.gz → 0.2.5__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.
Files changed (22) hide show
  1. {dynos_core-0.2.2 → dynos_core-0.2.5}/PKG-INFO +1 -1
  2. {dynos_core-0.2.2 → dynos_core-0.2.5}/pyproject.toml +1 -1
  3. {dynos_core-0.2.2 → dynos_core-0.2.5}/src/dynos_core/__init__.py +30 -0
  4. dynos_core-0.2.5/src/dynos_core/atom.py +180 -0
  5. dynos_core-0.2.5/src/dynos_core/config.py +565 -0
  6. {dynos_core-0.2.2 → dynos_core-0.2.5}/src/dynos_core/factories.py +14 -2
  7. dynos_core-0.2.5/src/dynos_core/results.py +288 -0
  8. {dynos_core-0.2.2 → dynos_core-0.2.5}/src/dynos_core/state.py +5 -4
  9. {dynos_core-0.2.2 → dynos_core-0.2.5}/src/dynos_core/transition.py +29 -7
  10. {dynos_core-0.2.2 → dynos_core-0.2.5}/src/dynos_core/types.py +28 -0
  11. dynos_core-0.2.5/src/dynos_core/wire_types.py +71 -0
  12. {dynos_core-0.2.2 → dynos_core-0.2.5}/src/dynos_core.egg-info/PKG-INFO +1 -1
  13. {dynos_core-0.2.2 → dynos_core-0.2.5}/src/dynos_core.egg-info/SOURCES.txt +3 -0
  14. dynos_core-0.2.2/src/dynos_core/atom.py +0 -119
  15. {dynos_core-0.2.2 → dynos_core-0.2.5}/README.md +0 -0
  16. {dynos_core-0.2.2 → dynos_core-0.2.5}/setup.cfg +0 -0
  17. {dynos_core-0.2.2 → dynos_core-0.2.5}/src/dynos_core/backoff.py +0 -0
  18. {dynos_core-0.2.2 → dynos_core-0.2.5}/src/dynos_core/extension.py +0 -0
  19. {dynos_core-0.2.2 → dynos_core-0.2.5}/src/dynos_core/time_parse.py +0 -0
  20. {dynos_core-0.2.2 → dynos_core-0.2.5}/src/dynos_core.egg-info/dependency_links.txt +0 -0
  21. {dynos_core-0.2.2 → dynos_core-0.2.5}/src/dynos_core.egg-info/requires.txt +0 -0
  22. {dynos_core-0.2.2 → dynos_core-0.2.5}/src/dynos_core.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dynos-core
3
- Version: 0.2.2
3
+ Version: 0.2.5
4
4
  Summary: Core symbolic-planning types and protocols shared by DYNOS packages
5
5
  License: Apache-2.0
6
6
  Requires-Python: >=3.8
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "dynos-core"
7
- version = "0.2.2"
7
+ version = "0.2.5"
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" }
@@ -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
+ )