ZhYQ1 commented on code in PR #439:
URL: https://github.com/apache/hugegraph-ai/pull/439#discussion_r4661684878


##########
ontogeny/server/ontogeny/api/routes_objects.py:
##########
@@ -203,18 +204,49 @@ async def execute_action(
         started = time.perf_counter()
         from ..errors import PolicyDeniedError, RuleRejectedError
 
-        async with sc.sessionmaker() as s:
+        # Keep same-key executions serialized until the revision is committed;
+        # exiting the session first also rolls back failures before unlocking.
+        async with (
+            sc.runtime.idempotency_guard(action_name, principal, 
body.idempotency_key),

Review Comment:
   Took the "narrow the guarantee" option. A true reservation would hold the 
SQLite write lock across the whole LLM call (or need stale-claim cleanup), so 
it belongs in a separate PR. Documented explicitly in`idempotency_guard` 
,`execute_action` , and`docs/{en,zh}/architecture/01-overall-architecture.md` : 
the key guarantees at-most-once replay across workers; same-key execution is 
serialized only in-process, so function-backed actions must make outbound calls 
idempotent. Results stay deduplicated; only side effects may repeat. I can 
follow up with a DB-backed reservation separately.
   
   Verification:`tests/test_api.py` +`tests/test_action.py` → 52 passed; ruff 
clean. Pushed as`3877cd2` .



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to