dynos-core 0.2.0__tar.gz → 0.2.2__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dynos-core
3
- Version: 0.2.0
3
+ Version: 0.2.2
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.0"
7
+ version = "0.2.2"
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" }
@@ -53,6 +53,21 @@ def _infer_name_from_assignment() -> Optional[str]:
53
53
  return None
54
54
 
55
55
 
56
+ def generate_object_name(type_name: str) -> str:
57
+ """Mint a unique, type-prefixed object name.
58
+
59
+ The shared fallback for when a domain object is created without an explicit
60
+ name and no assignment target can be inferred (the HTTP/servant paths, where
61
+ there is no ``lhs = make_new_object(...)`` source line to read). The type
62
+ prefix keeps the name readable and -- crucially -- distinct from the bare
63
+ type name: an object named after its own type collides with the type in the
64
+ planning problem (they share one namespace) and fails at plan time.
65
+ """
66
+ from uuid import uuid4
67
+
68
+ return f"{type_name}_{uuid4().hex[:8]}"
69
+
70
+
56
71
  class FluentBase:
57
72
  """Client-side fluent: calling it returns a GroundAtom.
58
73
 
@@ -145,13 +160,10 @@ def make_new_object(type_cls: Any, name: Optional[str] = None, **values: Any) ->
145
160
  if name is None:
146
161
  name = _infer_name_from_assignment()
147
162
  if not isinstance(name, str) or not name:
148
- raise ValueError(
149
- f"make_new_object({type_cls!r}) could not infer an object name. "
150
- "The factory tried to read the assignment target on the call "
151
- "site's source line and got nothing usable (no `lhs = make_new_object(...)` "
152
- "pattern; tuple-unpack, attribute, subscript, or interactive "
153
- "use with no source file all defeat it). Either pass "
154
- "name='your_name' explicitly or wrap the call in a single-target "
155
- "assignment like `your_name = make_new_object(...)`."
156
- )
163
+ # No explicit name and no inferable assignment target (comprehension,
164
+ # tuple-unpack, interactive, or a wire/servant caller). Mint a unique
165
+ # type-prefixed name rather than failing -- the same fallback the client
166
+ # create path uses, so an unnamed object always gets a usable, distinct
167
+ # identity instead of a collision-prone bare type name.
168
+ name = generate_object_name(type_name)
157
169
  return SymbolicObject(name=name, type_name=type_name)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: dynos-core
3
- Version: 0.2.0
3
+ Version: 0.2.2
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
File without changes
File without changes